sequelize / cli

The Sequelize CLI
MIT License
2.53k stars 528 forks source link

Prevent duplicate identifiers in migrations #354

Open twolfson opened 7 years ago

twolfson commented 7 years ago

I'm setting up a new project with sequelize but am missing a safety feature that I had in alembic (migration library for Python's SQLAlchemy) and a Ruby gem that I can't recall the name of. The missing feature is migrations were defined in a linear fashion so every migration was required to state its parent migration (e.g. 0002 had a parent of 0001).

If there were multiple migrations pointing to the same parent (e.g. 2 potentially related PRs were landed at the same time), then it was considered a conflict and nothing would happen until the conflict was resolved.

For the interim, I've forked and made a monkey patch for the feature but I was wondering if we would be interested in adding such a feature to this repo. Here's my current overrides:

https://github.com/sequelize/cli/compare/sequelize:99878bc...twolfson:0f69f49

felixfbecker commented 7 years ago

That is a general problem with sequential identifiers for migrations :/ I think an error here is a good change. Feel free to do a PR. I actually experimented with my own migration tool a while ago that uses UUID instead of sequential numbers and then git log to get the order of migrations.

twolfson commented 7 years ago

I'm fine with opening a PR but shouldn't it be under an opt-in flag? It's possible that someone uses a naming convention (e.g. camel case, non-digit-identifiers like UUID) where this feature would break their setup unnecessarily