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
Let's assume that we have in current database some foreign key on location.instrument_id. Lets assume that we are deleting this column. This won't work because there is existing foriegn key.
ERROR: SQLSTATE[HY000]: General error: 1828 Cannot drop c
olumn 'instrument_id': needed in a foreign key constraint 'suzuki_test/location_ibfk_2'
Phalcon migration should check if there is any foreign key like:
select COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_COLUMN_NAME, REFERENCED_TABLE_NAME
from information_schema.KEY_COLUMN_USAGE
where TABLE_NAME = :currentTable: AND COLUMN_NAME = :currentColumn: AND REFERENCED_COLUMN_NAME IS NOT NULL;
Then on result from it it should delete all constraint with CONSTRAINT_NAME.
The text was updated successfully, but these errors were encountered:
Jurigag
changed the title
[NFR]Drop indexes before column drop
[NFR]Drop foreign keys before column drop
Sep 28, 2016
@Jurigag I'm not sure that deleting is good way. FK is may cause problems when during on generating or running migration. But we can implement workflow with FK to store keys in the file. For example: user runs command generate --FK and DevTools will create file called foreignKeys.sql with real SQL. After that we can delete it from DB. I guess this way is better. How do you think about this?
Let's assume that we have in current database some foreign key on
location.instrument_id
. Lets assume that we are deleting this column. This won't work because there is existing foriegn key.Phalcon migration should check if there is any foreign key like:
Then on result from it it should delete all constraint with CONSTRAINT_NAME.
The text was updated successfully, but these errors were encountered: