What's the best way to make small schema updates with Doctrine/Symfony?

ε祈祈猫儿з 提交于 2019-12-06 20:29:27
Arthur Frankel

Look at this post:

Can you generate a migration from an existing table with Doctrine?

and this link: http://www.doctrine-project.org/documentation/cookbook/1_0/en/code-igniter-and-doctrine:setup-command-line-interface

We have been generating the changes from doctrine by changing the yaml file, running the doctrine command with generate-migrations-diff option to produce a migration file, then using the migrate option to migrate the change.

I know exactly what you mean. There are two ways you can tell symfony what your database structure looks like:

  1. Create yaml file -> run build-sql command -> run insert-sql command
  2. Create database within your RDBMS -> run build-schema command

With method 1, your data gets wiped out each time. With method 2, your data remains intact. The only problem with method 2 is that you'll wipe out any doctrine-specific attributes that you had in your yaml file and you'll have to add those back in. To me, though, that's a lot less of a pain in the ass than to have to reload your data into your database.

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