Phinx: Forcibly re-run a migration

Created on 15 Dec 2015  Â·  5Comments  Â·  Source: cakephp/phinx

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

feature

Most helpful comment

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.

All 5 comments

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

proposed syntax:

phinx migrate --force 2923092109

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" [email protected] 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.

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

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jeckerson picture Jeckerson  Â·  3Comments

nickcv-ln picture nickcv-ln  Â·  5Comments

dfsoeten picture dfsoeten  Â·  3Comments

amcoho picture amcoho  Â·  4Comments

rquadling picture rquadling  Â·  4Comments