CogitoErgoSum
CogitoErgoSum

Reputation: 2907

Symfony Update a Model Schema

So heres the scenario:

Currently we have a development site with 3 models. We found we didn't like our initial schema and added a few rows. We re-generated the schema (doctrine:build-sql).

Now it forced us to drop and re-create all the tables and dump back in all the information as no ALTERS were created but rather CREATE statements only. Not a problem...

The big problem came to updating the models. After we ran a build-all and such a few errors popped up i.e. "Widget sort not found" etc. We figured out we needed to rebuild the models. So we can a symfony doctrine:build-models course Course (Course was the table name...course the models). This worked great and fixed the broken links within Symfony.

The downside is all custom code in the actions.class.php file was lost as were customizations to the _form.php page.

My question on this is, how do we store our own actions so they are not lost if you update a models schema? Similarly templates and such are re-generated to but do not hold any customizations.

There surely must be a simple solution to updating a model's schema in symfony?

Upvotes: 1

Views: 3013

Answers (2)

CogitoErgoSum
CogitoErgoSum

Reputation: 2907

Found my answer to this. You don't update the module per say but the models of the database. You can change your schema.yml file and do a symfony migration

http://www.slideshare.net/denderello/symfony-live-2010-using-doctrine-migrations

Upvotes: 2

benlumley
benlumley

Reputation: 11382

If you just want CRUD/minimal customisation, you can do this with the admin generator:

./symfony doctrine:generate-admin appname Course

A regular module can't be updated once generated without losing customisations - they are intended to be a starting point.

Upvotes: 0

Related Questions