English 中文(简体)
How does one call the down method for a Doctrine migration in Symfony 1.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.

最佳回答

If you are at Migration Version N, then

./symfony doctrine:migrate N-1

will call the down method on the Nth migration.

问题回答

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





相关问题
Copy data from Access to SQL

I am in the process of migrating an existing Access database to a SQL database with a web front-end. I have successfully copied the database to SQL using the SQL Server Migration tool and am working ...

MongoMapper and migrations

I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...

Switching to WPF. Is it time?

I m considering switching from MFC to WPF. My first concern is that there are too many users who don t have .NET with WPF installed yet. Can anybody point to a source containing the WPF penetration ...

rake db:migrate running all migrations correctly

I m fairly new to Ruby on Rails here. I have 2 migrate files that were provided. The first one, prefixed with 001, creates a table and some columns for that table. The next migrate file, prefixed ...

Migrate Java Applet to what/where?

I am reviewing currently a medium size code base (around 30K LOC) which uses a huge Applet and interfaces with other systems. It s a tool to create custom labels, so we need drag-n-drop and other ...

热门标签