views:

85

answers:

2

I am using Symfony 1.2 with the sfDoctrinePlugin.

I couldn't find any command to call the down method on a migration, neither the documentation suggests any related arguments to the existing doctrine migrate command.
What would be a way to rollback the migration I just ran successfully? Creating a new migration to undo is an option, but that is almost blasphemous and plainly stupid.

+1  A: 

Just give the migration number you would like to migrate to and Doctrine will determine whether to call up or down. See the API docs for migrate in 1.2:

(integer) migrate($to = null, $dryRun = false)

Perform a migration process by specifying the migration number/version to migrate to. It will automatically know whether you are migrating up or down based on the current version of the database.

returns Version number migrated to

throws Doctrine_Exception

Gordon
Right. Had to read the code to figure that out. Didn't read the docs you mentioned.
Swanand
I was more inclined to find the command line way to run that method.
Swanand
+2  A: 

If you are at Migration Version N, then

./symfony doctrine:migrate N-1

will call the down method on the Nth migration.

Swanand