[NFR] Drop foreign keys before column drop
Open
@Jeckerson is already working on this.
Since Jan 28, 2020.
NFR
- Dominant language
- PHP
- Stars
- 28
- Forks
- 25
- Avg merge
- 9h 39m
- Merged PRs (30d)
- 2
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.