Php – Standard idiom for adding new models to an app built on Symfony + Doctrine

doctrinephpsymfony1

What is the a standard way of adding new model to my app built on Symfony + Doctrine while maintaining all previous models and their meta-data (like relationships).

What am I really looking for: A command / procedure that will be equivalent of ./script/generate model FooModel in Ruby on Rails (which does not have any sort of reset db / reset models while generating)

If these two are different things, and I am chasing the wrong ghost (I would like to think I am not), please let me know.

EDIT: Updated the question.

Best Solution

Standard process is to add the new model and any relationships it requires to schema.yml

Then do ./symfony doctrine:build-all (or :build --all for symfony 1.3/1.4)

As richsage says, you shouldn't be editing the base classes, so this operation is totally non destructive.

Doctrine also has functionality for migrations so that you an update the database schema easily as you deploy the new code into production:

http://www.doctrine-project.org/documentation/cookbook/1_0/en/symfony-and-doctrine-migrations

Newer versions of doctrine (1.1 +, symfony 1.3+) include the generate-migrations-diff task, which can create migrations for you. This is covered very well here:

Extra changeColumns in Doctrine generate-migrations-diff

[edit: the author of the question above has copy/pasted it below as well now]

Related Question