Problem:
- I have a symfony project with a database full of production data
- I want to change its structure (add/drop a table or add/drop/change an existing field)
How do I do that without wiping my database ?
Because when you change your schema.yml, you need to doctrine build --all if you want your changes to take place in the database, and this task wipes out the database, the production database.
Things I tried:
This blog basically says to do the following:
php symfony doctrine:data-dump
php symfony doctrine:build --all
phpsymfony doctrine:data-load data/fixtures/data.yml #default name for fixtures file
But it prints an error about a foreign key constraint. (In my case, I am trying to add a table with a foreign key in an existing one).
Based on the same idea: I tried the following:
mysqldump -u root -p > DBexport.sql
php symfony doctrine:build --all
# open DBexport.sql in a text editor and remove all queries for
# creating the structure of the database
mysql -u root -p shop < DBexport_data.sql
But I have this error:
ERROR 1136 (21S01) at line 34: Column count doesn’t match value count
at row 1
Because in a table I have added a field and the old database doesn’t have the right field count…
I may be misunderstanding the question, but won’t Migrations solve your problem?