Question

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.

Was it helpful?

Solution

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

OTHER TIPS

In Yii 1.1 - to redo just one historic migration you need a few steps.

  1. Make a note of the full name of the latest migration you have run (the last displayed in your migrations table) and the full name of the migration you want to run again:

m210905_112345_to_run_again
m210906_125400_latest_one

  1. Go back in time:
    yiic migrate mark m210905_112345_to_run_again

  2. Run that one migration again
    yiic migrate redo 1

  3. Go forward in time to latest
    yii migrate mark m210906_125400_latest_one

For Yii 2 it should be (although I haven't tested this set of commands):

  1. Go back in time:
    yiic migrate/mark m210905_112345_to_run_again

  2. Run that one migration again
    yiic migrate/redo 1

  3. Go forward in time to latest
    yii migrate/mark m210906_125400_latest_one

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top