How does one call the down method for a Doctrine migration in Symfony 1.2?
Question
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.
Solution 2
If you are at Migration Version N, then
./symfony doctrine:migrate N-1
will call the down method on the Nth migration.
OTHER TIPS
You could also do
./symfony doctrine:migrate --down
as by the docu:
symfony doctrine:migrate [--application[="..."]] [--env="..."] [--up] [--down] [--dry-run] [version]
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