Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to undo "grouped" migrations (applied with the same command) with only one command #1264

Open
ciePIC opened this issue Mar 10, 2023 · 0 comments

Comments

@ciePIC
Copy link

ciePIC commented Mar 10, 2023

Hello,
I am self-taught in DataBase management and usage. First I was using no tools to interface my program to the DB. I was writing all manualy. Next I have used the interface of Laravel in PHP ("Eloquent"). Now, I use Sequelize in my NodeJS project.

I have not found any information about my followinf suggestion but if it's already addressed, please just tell me.

I suggest to add a feature for migration to the sequelize CLI and maybe also to ohter sequelize parts (I don't knw how you are managing migration).
I suggest to add the possibility to undo all migration that are apply by the same command (like in Laravel Eloquent).

For exemple, If there are 5 migration applied and 3 pending migration. When you execute the migrate command, Sequelize will migrate the 3 pending migration. If you want to revert it, you have to undo 3 time or precize the migration name. I propose to add a command (maybe "db:migrate:undo:group") to automaticaly revert migrations that was applied by the same migrate command.

This is very usefull for production usage. When customer deploy an application, he as to migrate a first time, OK all migrations are applied. Next, I send an application update, the customer migrate simply migrate again and all new migration are applied. Now if the customer need to comeback to the previous version, he as to undo migration so, actually, he need to check name of last migration of the previous version. With my proposition, customer simply undo the last "group" (same time migration) and the app revert the the previous version because all migrations of the new version was applied by the same command.

To do it, I suggest to add a boolean column to the "sequelizemeta" table named "grouped". Migration row is set to false for first applied migration done by a migrate command and all next migrations applied by this same command is set to true because they are "grouped" with precedent. So at eatch execution of the migration command, a row and only one is set to false. The "undo:group" command has just to undo last migration and check if this unded migration was set to true. If yes, automatically undo the previous migration and so one while "grouped" field is true.

I can develop more or explain differently but I realy think that it can be a very good addition for production and most generaly to don't care of migration name while migrate or revert between program version.

Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant