Symfony2 Doctrine schema update fails

前端 未结 5 1203
不知归路
不知归路 2021-02-07 11:53

I created database on my local machine. After moving my project to server I imported backup from local (because I had some important data there).

Now,when I\'m trying t

5条回答
  •  心在旅途
    2021-02-07 12:48

    Schema update with foreign-key checks disabled

    If Doctrine schema updates fail because of foreign-key constraints, you simply need to disable foreign-key checks for this particular update.

    As a one-liner you can run:

    mysql -e "set foreign_key_checks = 0; `app/console doctrine:schema:update --dump-sql`"
    

    This prepends set foreign_key_checks = 0; to the output of app/console doctrine:schema:update --dump-sql so it actually calls exactly what Doctrine would call but with foreign-key checks disabled. Configure the mysql call to your needs.

    Your schema is updated and depending on your changes no data is lost.

    Keep in mind that sometimes the order of the queries is important and Doctrine simply didn't order them right. In this case you have to order the queries correctly by your own and then use that ordered list of queries instead.

提交回复
热议问题