Revert Only One of Two Migrations in Sequelize-CLI?
Asked Answered
U

1

29

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.

Unduly answered 8/2, 2020 at 21:16 Comment(0)
P
59

Use name option:

db:migrate:undo --name 20180704124934-create-branch.js
Panther answered 9/2, 2020 at 0:22 Comment(3)
This worked! Although I must admit, I'm much more used to the idea of "stepping" backwards through a migration. I guess using the name makes it more explicit to what point you're exactly migrating back to - just a bit non-standard for the frameworks I've used.Irizarry
Thanks man. it works. Perhaps if sequelize cli is installed globally, a person should run the command from terminal like this npx sequelize-cli db:migrate:undo --name db:migrate:undo --name 20180704124934-create-branch.jsUella
npx sequelize-cli db:migrate :undo --name 20230406073112-create-history Unknown arguments: name, :undo "sequelize": "^6.6.5", "sequelize-cli": "^6.2.0",Vulgate

© 2022 - 2024 — McMap. All rights reserved.