Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how to execute a specific migration
  • I have multiple migrations spanning from 001_ to 011...
    I would like to run migration 007_ only. How?
  • HarroHarro
    Accepted Answer
    You can not, migrations have to run in sequence. They are an incremental evolution if you will from the schema/state of your database.

    So if you want to run 7, you need to "undo" 8 to 11:

    php oil r migrate:down --v=7

    will migrate down to 7. After that, you can do

    php oil r migrate --all

    to migrate all up again.

    Obviously, this only works if you have designed your migrations properly, and each down() method of each migration undoes exactly what it's up() has created.

    If not, do what I suggested in my other reply: create 007 with an empty up() and down() method, and create a new 012 which will contain what your missing migrations contained. And then just run your migrations like normal.
  • Thank you..
    So, if I want to invert the order of migrations, I should change the file names altering the numbers? The issue is that I created a new relationship in my mysql tables and one of the foreign keys of the table created in migration 7 is in another table created in migration 12.
  • HarroHarro
    Accepted Answer
    You should not alter anything in a migration that has run. Either locally or after deployment (and that includes team members that work on the same code and have a local db too).

    If you haven't deployed yet, and you only have local code and a local database, migrate down to revert your schema to a point before where you want to make changes, then make the changes, then migrate up again.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion