Rebuild model without loss data in MySQL for Symfony

倖福魔咒の 提交于 2019-12-04 13:10:19
denys281

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!