Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 run only specific migration

In Yii2, when I use the

yii migrate

command, I get a long list of remaining migrations. How can I only run one specific migration in the list without performing the others?

like image 814
mrateb Avatar asked Dec 02 '22 11:12

mrateb


1 Answers

Run migrate/history to list migrations have been applied:

./yii migrate/history 

Copy the name of migration you want to return to later (lets say it is 'm160101_185401_initial_migration'). Save it somewhere because you're going to need this later.

Mark migration history at the one just before the one you need to run:

./yii migrate/mark m170101_185401_create_news_table

Run one migration:

./yii migrate 1

Reset migration history:

./yii migrate/mark m160101_185401_initial_migration
like image 159
Anton Rybalko Avatar answered Dec 24 '22 10:12

Anton Rybalko