Closed seanadkinson closed 2 months ago
I'm running into this as well.
I'm having this issue with the same setup: running the migration function programmatically and with an external dbClient
. Although my scenario is a bit different, as I first encountered the problem running tests (thus running pgMigrate
more than once because of some test cases).
I think @seanadkinson explanation on the connection status when using an external client makes sense: with the current setup, the status will remain ConnectionStatus.DISCONNECTED
when using an external client, then unlock
is never called.
I tried running pgMigrate
with the option noLock: true
and indeed I no longer get the error.
Hi there,
I am running
pgMigrate
programmatically on app startup via something similar to the following:You can see I am providing an external
dbClient
.When running my app with multiple nodes, the first node successfully runs the migrations, but every subsequent node gets "Error: Another migration is already running"
I believe this is happening because when you check that the database is connected before unlocking here, it is always
false
, since you don't set theconnectionStatus
for external clients here. This means that the database remains locked forever.I think if you set
connectionStatus = ConnectionStatus.CONNECTED
for external clients, this should solve the issue. Thoughts?