Peter Shootring
Peter Shootring

Reputation: 51

Rebuild model without loss data in MySQL for Symfony

What is the best way to rebuild a model without loss data in MySQL for Symfony?

What if I have a big site, and a lot of data in the database and I would like after six months to add few new fields to database?

Upvotes: 3

Views: 1967

Answers (2)

denys281
denys281

Reputation: 2014

You can use migration.

Doctine manual

Symfony task for migrations

Slideshare presentation

Slideshare presentation

So you need write migrations, migrate, and build your models, forms, etc.

Upvotes: 6

Manse
Manse

Reputation: 38147

I suggest you use @denys281 for Symfony1.4 ....in Symfony2 however its VERY simple ... just use the command :

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

It compares what your database should look like (based on the mapping information of your entities) with how it actually looks, and generates the SQL statements needed to update the database to where it should be. In other words, if you add a new property with mapping metadata to Product and run this task again, it will generate the "alter table" statement needed to add that new column to the existing product table. So it doesnt remove any data

There is also a DoctrineMigrations bundle for Symfony2 if you fancy that route -> http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html

Upvotes: 3

Related Questions