Sunday, January 23, 2011

Work with Doctrine Migration in Symfony

To update your schema, classes, database without losing data, try to do this...
  1. Change your schema.yml file.
  2. Use the symfony doctrine:generate-migrations-diff command to generate the differences between the current classes and the changed schema. These changes are converted by Doctrine into a migrations files, you can find them in the lib/migration directory. In the filename you will see a version number.
  3. Type the symfony doctrine:migrate x command to update your database. x is the version number you found in the filename of the last migration file.
  4. Type the symfony doctrine:build --all-classes command to generate new classes for symfony.
Symfony will create a migration_version table in the database to store the current migration version number.

No comments:

Post a Comment