Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable wrapping migration in a transaction with Node db-migrate

I need to use db-migrate to add an index to a Postgres database with CREATE INDEX CONCURRENTLY. However, db-migrate wraps all migrations in a transaction by default, and trying to create a concurrent index inside a transaction results in this error code:

CREATE INDEX CONCURRENTLY cannot run inside a transaction block

I can't find any way to disable transactions as part of the db-migrate options, either CLI options or (preferably) as a configuration directive on the migration itself. Any idea if this can be accomplished?

like image 809
JSBձոգչ Avatar asked Dec 21 '25 03:12

JSBձոգչ


1 Answers

It turns out that this can be solved on the command line by using --non-transactional. Reading the source, I can see that this sets an internal flag called notransactions, but it's not clear to me whether this can be set as part of the migration configuration or must be passed on the command line.

like image 75
JSBձոգչ Avatar answered Dec 22 '25 23:12

JSBձոգչ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!