sequelize-mig
sequelize-mig copied to clipboard
Migration Reversion Breaks with Foreign Keys
Creating and running the migrations from models works like a charm (thank you!), but the migration reversion is broken when foreign key constraints apply. The generated actions summary shows that the first tables created are ones with no dependencies, and the ones created following that use those as dependencies (this makes sense).
Here's an example structure:
However, it appears that the order in which tables are dropped does not match this. Instead, it goes alphabetically (either implicitly, because of how files are sorted in the file system, or explicitly).
Here's a small example of the rollbackCommands applied to:
For migration reversion to work appropriately, first the tables with dependencies must be dropped. If reversion happens in the reverse order they were created, this problem would be solved.