back to notes

migrations

Migrations

when starting to use migrations :

## on your DEV system!

./symfony doctrine:generate-migrations-models
# -> will generate migration classes that upgrade from a blank database to the current status

./symfony doctrine:drop-db
# -> will drop the whole database including your tables and data

./symfony doctrine:create-db
# -> will recreate the database without tables

./symfony doctrine:migrate
# -> will run the migration to create all tables including a new table to store the current migration version

./symfony doctrine:data-load
# -> will reload all your fixtures


when changing the database:

./symfony doctrine:generate-migrations-diff
# -> This will generate more migration classes.

./symfony doctrine:migrate
# -> This will update your database to the changes you just made to your schema.

./symfony doctrine:build --all-classes
# -> This will update all your model related classes (models, forms, filters) to the same changes.


When rebuilding with fixtures :

./symfony doctrine:build --db --and-migrate --and-load


When removing a table :

./symfony doctrine:clean-model-files


When deploying to production :

./symfony project:disable prod
# -> After this the users will be presented with the unavailable.php page telling them to come back in a moment.

#-> rsync

./symfony doctrine:migrate --env=staging
OR
./symfony doctrine:migrate --env=prod
#-> This will replay all the changes to your dev database on your live database.

./symfony cc
#-> Clear the cache

./symfony project:enable prod
#-> The users are now back on the now upgraded project.


last updated november 2012