You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Altering a column never backs up its foreign keys on MySQL and SQL Server #306
Altering a column that a foreign key uses never drops and restores that foreign key on MySQL and SQL Server. MySQLHandler::alterColumn() (line 87) and SQLServerHandler::alterColumn() (line 181) select the keys to back up with $column->getName() === $foreign->getColumns(), comparing a string with an array, so the condition is always false: no key is dropped before the ALTER and none is restored after it.
Is this a regression?
Not checked; it dates from when getColumns() started returning an array.
To Reproduce
MySQL or SQL Server; table post with user_id and a foreign key on it to user.id.
Change the type or size of post.user_id through the schema and save().
The ALTER runs with the foreign key still in place (the database rejects it, or the key is left as is), instead of the key being dropped and recreated around it.
Expected behaviour
in_array($column->getName(), $foreign->getColumns(), true): keys using the column are backed up, dropped and restored.
Activity