Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
migration not working after table deleted
  • I accidentally deleted a table by hand, as well as the model and migration that corresponded to it... Next I generated the same model and migration again using php oil.... When I tried to migrate again in order to create the same table for a second time, it told me that I'm on the latest migration... Now I'm going to create the table by hand because I don't know what is going on..
    Has anyone had this problem? how did you solve it?
  • HarroHarro
    Accepted Answer
    You can run migrations only once. The Migrate class keeps track of migrations in both the migrations table and the migrations config file, and both have to be in sync.

    If you only have a problem locally (i.e. it is not a deployed application), you could create a dummy migration for the number you deleted, then migrate down to that number, replace the dummy with the newly created migration, and migrate up again. That would cause dataloss if that means tables would be deleted.

    If that is not possible, leave the dummy migration (with an empty up() and down() method), and create a new migration with the next new sequence number to create the table again, and migrate up like normal.

    If this is a deployed application, get the migration file and table (structure) back from your deployment, problem solved.

    Oh, and while you are at it: start using a versioning system like git, and commit your changes regularly. And never loose anything again.
  • Thank you once again Harro Verton

Howdy, Stranger!

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

In this Discussion