sheerun / knex-migrate

Modern database migration toolkit for knex.js
MIT License
342 stars 39 forks source link

Migrations started with knex_migrate do not have '_lock' table #40

Open mashaalmemon opened 5 years ago

mashaalmemon commented 5 years ago

Using knex when a migration is performed for the first type typically we'll get two tables created automatically by knex:

migrations
migrations_lock

However when using knex-migrate, and stepping forward a specific number of 'step' only one table is created, not the 'lock' table:

migrations

Any idea why this is happening? I have knex 0.15.2 installed in my environment. I am using a postgresql database.

mashaalmemon commented 5 years ago

Anyone maintaining this project?

sheerun commented 5 years ago

Why do you need _lock table?

hudsonma commented 5 years ago

My project was bit by this too. If knex-migrate is tied into application startup, and you have more than one instance of your application, then you create a potential race condition on the execution of migrations. Having a lock table ensures only one instance can make database changes at a time, guaranteeing execution in the proper order and no duplication.

We are going to get around this by adding a pre-deployment hook to execute the migrations from a single process, but I think if this library is going to tout 100% compatibility with knex, then the lock tables need to be created. If not, there should be a disclaimer section containing all the features not supported from knex.

sheerun commented 5 years ago

I'd accept PR fixing this