[Question] Concurrency management #519
Replies: 2 comments 2 replies
-
Hi @pedroneves - currently there isn't in-built locking support, since this best way to lock varies quite a lot between SQL dialects/implementations. If you're using postgres, you could try @slonik/migrator which does support this via If you're not using postgres, you could take a look at the implementation - it overrides the import {Umzug} from 'umzug'
export class MyMigrator extends Umzug {
async runCommand(command, cb) {
if (command === 'up' || command === 'down') {
return super.runCommand(command, async params => {
await acquireLock() // implement `acquireLock` however makes sense for your system. You could also pass in `params.context` here.
try {
return cb(params)
} finally {
await releaseLock()
}
})
}
return super.runCommand(command, cb)
}
} Then instantiate and use |
Beta Was this translation helpful? Give feedback.
-
Hey @mmkal ! Thank you so much for your quick reply. I still did not have the chance to try your suggestions, but I'll post here how it went. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hello everyone 👋
I have a situation where I need to use Umzug fine control migrations during boot time for my app. The problem is that I must run multiple instances of my service, so the migration script will run for every instance before the app starts.
Is there any built-in concurrency management mechanism in Umzug or this is a concern I should take care of?
Also, if this is something I should address in the code, is there an official recommendation on how to proceed (lib I should use or process I should follow for example)? So far, I only found this lib called umzug-sync.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions