-
-
Notifications
You must be signed in to change notification settings - Fork 530
Description
Feature Description
Is your feature request related to a problem? Please describe.
Yes, migrations should be run as groups. If I have 3 new migrations that I created and I run db:migrate
it will execute all 3 migrations.
The issue is if I need to rollback the migrations because all 3 migrations are not rolled back when I run db:migrate:undo
. Only the last migration is rolled back. I need to run db:migrate:undo
3 times in order to completely roll back.
While frustrating, this is fine for local development. If this was a production environment where migrations are triggered automattically during the deploy sequence, this would be an issue. Now the rollback mechanism needs to have some kind of context around how many migrations last ran and how many times it needs to run db:migrate:undo
Describe the solution you'd like
Store a group_id
number associated with each group of migrations that are run. That way, db:migrate:undo
just needs to undo all of the migrations in the most recent migration group. This is how the Laravel framework solves this problem.
Now running db:migrate:undo
would undo all 3 migrations rather than just the most recent one.
Why should this be in Sequelize
Because people rely on this library in production environments, and the need to rollback atomic changes to the database should work the same way as applying migrations.
Describe alternatives/workarounds you've considered
calling db:migrate:undo
multiple times. Would need to build some sort of context to know how many migrations. previously ran.
Additional context
Feature Request Checklist
Is this feature dialect-specific?
- No. This issue is relevant to Sequelize as a whole.
- Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
Would you be willing to implement this feature by submitting a Pull Request?
- Yes, I have the time and I know how to start.
- Yes, I have the time but I don't know how to start, I would need guidance.
- No, I don't have the time, although I believe I could do it if I had the time...
- No, I don't have the time and I wouldn't even know how to start.