Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Revert Only One of Two Migrations in Sequelize-CLI?

If we created 2 new migration scripts and ran

sequelize-cli db:migrate

, both migration scripts will run.

Both migrations are also reverted when we ran once the command

sequelize-cli db:migrate:undo

Question: Can we undo only the latest of the 2 migrations?

Using node 13.7.0, sequelize 5.21.3, sequelize-cli 5.5.1, PostgreSQL 11.2.

like image 973
Nyxynyx Avatar asked Feb 08 '20 21:02

Nyxynyx


People also ask

How do I undo one migration in Sequelize?

Undoing Migrations​ With migration you can revert to old state by just running a command. You can use db:migrate:undo , this command will revert most the recent migration.

How do I rollback migrations?

To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one. After doing so, you can check the status again to be fully confident.

How do I delete a migration in Sequelize?

“delete migration record sequelize” Code Answer's // You can use db:migrate:undo, this command will revert most recent migration.


1 Answers

Use name option:

db:migrate:undo --name 20180704124934-create-branch.js
like image 52
Buszmen Avatar answered Oct 03 '22 02:10

Buszmen