Symfony2 differences between doctrine:schema:update and doctrine:migrations

When you have to create or update your database schema from entities, you are used to type these commands:

php app/console doctrine:schema:update --dump-sql
php app/console doctrine:schema:update --force

Doctrine offers another extension called Migrations that helps you:
– Save your different database schemas during the life of your project
– Move tables and databases with their content, what a simple doctrine:schema:update can’t do.
– Generate accessible migrations queries from the difference between your entities and your database schema.
– Include your own migration queries.

To use doctrine migrations, you will often use these commands:

php app/console doctrine:migrations:diff #Generate migrations queries
php app/console doctrine:migrations:migrate #Refresh your database schema from migrations queries

Finally, for rapid schema updates, use doctrine:schema:update, but, for complex modifications in your database, prefer doctrine:migrations.

Advertisements
Symfony2 differences between doctrine:schema:update and doctrine:migrations

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s