cli icon indicating copy to clipboard operation
cli copied to clipboard

Feature request - apply singular migrations

Open U-4-E-A opened this issue 7 years ago • 3 comments

I just started using sequelize cli, having moved over from using PHP migrations. I was surprised to find that it doesn't seem possible to apply/undo a single migration file at a time. I've worked this way when using PHP based migrations and I find it a lot easier to work this way than having to do/undo all migrations or specify a named migrations to be done next.

Is there any plans to include this as a feature? Thanks.

U-4-E-A avatar Jun 04 '18 10:06 U-4-E-A

It already exists. Keep in mind migrations are timestamped and thus run in a particular order. Knowing this you can use:

sequelize db:migrate --from <migration name> --to <migration name>

and list --from [desired migration -1] --to [desired migration] (note: --from is exclusive while --to is inclusive).

To undo:

sequelize db:migrate:undo --name <migration name>

If you want to see these for yourself, you can run: sequelize db:migrate --help and sequelize db:migrate:undo --help

greyscaled avatar Jun 10 '18 09:06 greyscaled

Thanks for your reply. However, I am not sure that answers the issue. I think it would be useful if there wasn't a need for naming the migration. For example, the Yii2 framework has these options: -

yii migrate/up 1
yii migrate/down 1

I find that a lot easier to work with.

U-4-E-A avatar Jun 10 '18 13:06 U-4-E-A

Any news on if this will be incorporated as a feature? It would be very handy indeed. I am still running Yii2 PHP migrations, would like to switch over to sequelize CLI but I would really like to have this feature available for ease of use when creating, modifying and testing a new migration. Thanks.

U-4-E-A avatar Oct 25 '18 18:10 U-4-E-A