db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 360 forks source link

Feature Request: Transaction configuration on a per migration basis #659

Open gibsonjoshua55 opened 4 years ago

gibsonjoshua55 commented 4 years ago

I'm submitting a...

Current behavior

There is no way to turn off transactions for individual migrations.

Expected behavior

Certain migrations need to be run outside of a transaction. For example, in PostgreSQL, ALTER TYPE type_name ADD new_value cannot be run in a transaction. The rest of the migrations, however should be run in a transaction. There is currently no way to configure individual migrations to not use a transaction block. It would be extremely helpful to allow this to be part of the configuration for a single migration.

gilly3 commented 4 years ago

Here's the hack I use, as a work around:

await db.endMigration();
await db.runSql(sqlScript);

Agreed, it would be better to have proper support for this.

wzrdtales commented 4 years ago

this would be easy to add, if someone feels to push out a pr, it would be a target to be included in the setup routine of a migration.

gibsonjoshua55 commented 4 years ago

Here's the hack I use, as a work around:

await db.endMigration();
await db.runSql(sqlScript);

Agreed, it would be better to have proper support for this.

Thank you so much! This is exactly what I've been looking.

theresasogunle commented 1 year ago

Is anyone working on this yet? I’d like to pick this up