Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Migrations not working after generating magic migration
  • I have generated a magic migration to rename a field in a table:

    php oil generate migration rename_field_price_to_retail_in_order_products

    I then added another migration manually be copying an existing migration to add a field and modifying it.

    When I ran "php oil r migrate" only the first (magic) migration ran. Now when I try and go up, I am receiving:

    Already on the latest migration for app:default.

    If I try and go back down, I get:

    There are no migrations installed to revert for app:default.

    I deleted the migrations file in app/config/development/migrations.php and checked that the migrations in my database are named/numbered correctly, and I can't seem to see any issues, but I am no longer able to go up or down with my migrations.

    I came across this issue which sounded like a similar issue:

    http://fuelphp.com/forums/discussion/12647/can039t-generate-migration

    Many thanks, James



  • Your database migration table and the contents of the migrations config file needds to be in sync, so deleting one of them can cause all kinds of issues.

    Possible reason for a migration not being picked up, is an incorrect class name (= doesn't match the filename without the sequence number), or a duplicate class name (you can't have 001_dothis.php and 002_dothis.php).
  • Hi Harro,

    Thanks for your response. As far as I understood, oil would look at the database migration table in the database if there wasn't a config file (and generate another), although this was in sync before I removed it. I can see how that would cause an issue though should the two get out of sync.

    The database seems to be completely in sync with my migrations, the issue just seems to have arisen after I generated a magic migration.

    The class name matches the file name, and I have checked the numbers are all sequential with no conflicts in names.

    On the topic I linked to in my original post, someone had left a comment saying that he believed an issue similar to this was caused by magic migrations. It sounds like I've run into a similar issue but I'm struggling to find any more information relating to the problem.

    Many thanks, James
  • Generated migrations don't do anything. Only a class file is generated with a DBUtil call, nothing more. I can't see how that would influence the way migrations run.

    Can you dump your migration table, add it to a zip together with the migrations config file, and all migration files, and email them to wanwizard <at> fuelphp.com, so I can have a look?
  • That would be great Harro, thank you. All my files are on my local machine at work, I will do this first thing in the morning.

    I don't have the migrations config after deleting it, and because my migrations will not run it has not generated another one, but I will send you a dump of the migration table along with a zip of the migrations.

    I didn't see how generating a magic migration would have caused me an issue, that was the only thing I had done differently to other migrations though, and then I came across that comment on the forums stating that magic migrations had caused someone else an issue for a similar problem.

    Appreciate you taking the time to take a look at this, and for your speedy reply!
  • Hi Harro,

    This morning I have deleted the 2 migrations that were causing me issues and re-added them. Now when I run my migrations, I am getting an error (which I have now resolved) on the second migration, and the migrations are working okay again.

    I'm not sure why it wouldn't give me this error yesterday, or why I couldn't migrate down, but it appears to be working now.

    Thank you very much for your help Harro.
  • No problem, glad you've got it sorted.

Howdy, Stranger!

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

In this Discussion