cakephp / phinx

PHP Database Migrations for Everyone
https://phinx.org
MIT License
4.47k stars 890 forks source link

Forcibly re-run a migration #717

Open anwar-gazi opened 8 years ago

anwar-gazi commented 8 years ago

I executed a migration which gone wrong, so next time I fixed the code inside that migration and then tried the php -f migration command but this time that migration didn't run

robmorgan commented 8 years ago

@minhaj-resgef there is not currently a force command, although I have plans for one.

proposed syntax:

phinx migrate --force 2923092109
anwar-gazi commented 8 years ago

hi dev, thanks, is there any way to manually clear that cache?

Sent from my phone. On Dec 15, 2015 3:57 PM, "Rob Morgan" notifications@github.com wrote:

@minhaj-resgef https://github.com/minhaj-resgef there is not currently a force command, although I have plans for one.

— Reply to this email directly or view it on GitHub https://github.com/robmorgan/phinx/issues/717#issuecomment-164707429.

robmorgan commented 8 years ago

@minhaj-resgef yes, open your database. Find the phinxlog table and deleted the specified row that represents your migration.,

anwar-gazi commented 8 years ago

I've written a php script to do that automatically. And further, added a -f switch to delete migration history and run again. I want to share the code.

igorsantos07 commented 8 years ago

The best way I have to try out migrations while developing is this:

  1. run migration, but only part of it works
  2. comment out what reverts in down() what has not run
  3. migrate rollback
  4. fix up(), uncomment pieces of down()
  5. migrate
  6. did not work? repeat.

You basically revert the half-migration using its own down() until you get it right. This way you do not have to deal with half-changes in the database or phinxlog table by hand.