updateSchema runs well with an empty database, but the second time I get the following MySQL error:
SQLSTATE[HY000]: General error: 1025 Error on rename of
'./mydatabase/#sql-7f5_2b' to
'./mydatabase/mytable' (errno: 150)
According to a quick search this error happens on foreign constraint violations. The right approach would be for doctrine to disable foreign key checks when ALTERing a table.
Is there something I can do about this (besides patching Dcotrine)?
Further more I’m specifying:
'engine' => 'myisam',
… in the connectionOptions, but it gets ignored.
Edit:
When I remove foreign keys from other tables containing reference to mytable the error won’t happen (it will happen with the next table which is still referenced by FKs but not with mytable).
Unfortunately, Doctrine doesn’t handle this situation completely right.
You should disable the constraints by yourself and let Doctrine to recreate them.
To disable constraints, connect to MySQL and type:
It will give you the SQL needed to create the table, where you’ll see the constraint creation directive. Suppose the constraint is called ‘mytable_fk’, then you need to issue the command:
The next time you run updateSchema, Doctrine will detect the missing restriction and will recreate it if needed.