Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run single migration (not newest) in Yii

I have few migrations files.How can I run single migration down or up, if this migration isn't the newest, but some steps in the migrations history?

When I run yiic migrate up 1, it runs the latest migration. Running migration command using migration version as parameter also doesn't help.

like image 311
Thomas Avatar asked Feb 22 '14 08:02

Thomas


People also ask

How do I run a specific migration file in yii2?

To run specific migration, you can mark(skip) migrations upto just before one you want run. You can mark migration by using one of following command: Using timestamp to specify the migration yii migrate/mark 150101_185401. Using a string that can be parsed by strtotime() yii migrate/mark "2015-01-01 18:54:01"

What is migration in Yii?

Yii provides the database migration feature that allows you to keep track of database changes. Yii provides the following migration command line tools − Create new migrations. Revert migrations. Apply migrations.


1 Answers

Please check documentation about redoing-migrations section:

yiic migrate redo [step]

If you want to undo/redo only one specific migration in your migration history. You have to modify your migration history :

yiic migrate mark 101129_185401
yiic migrate redo
like image 127
phemios Avatar answered Oct 20 '22 06:10

phemios