Skip to content

Comments

Allow running certain migrations outside of a transaction.#1140

Open
jwoertink wants to merge 1 commit intomainfrom
issues/1129
Open

Allow running certain migrations outside of a transaction.#1140
jwoertink wants to merge 1 commit intomainfrom
issues/1129

Conversation

@jwoertink
Copy link
Member

Fixes #1129
Closes #1021

This allows you to specify that your migration is going to potentially run some "unsafe" code which basically just means that you're going to run it outside of a transaction. This can be used for when engines like Cockroach DB require running outside of a migration, or for things like creating indexes concurrently in postgres.

You just add the unsafe_migration call to the top of the migration.

class MyUnsafeMigration::V1234 < Avram::Migrator::Migration::V1
  unsafe_migration

  def migrate
    execute "some sql that won't run inside of a transaction"
  end

  def rollback
    execute "a rollback that also can't run inside of a transaction"
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow running migrations outside of a transaction

1 participant