QueryInterface removeConstraint method fails to remove CHECK constraints (MySQL) #17382
Open
3 of 6 tasks
Labels
pending-approval
Bug reports that have not been verified yet, or feature requests that have not been accepted yet
Issue Creation Checklist
Bug Description
Context: I'm using sequelize migrations to drop an existing
CHECK
constraint on one of our tables. The dialect is MySQL Community Server 8.1When
removeConstraint
is invoked with correct schema and constraint name, it returns this error:Error Code: 1091. Can't DROP 'constraint_to_delete'; check that column/key exists
. I have verified that this constraint definitely exists.I debugged
removeConstraint
function further with logging and found out that internally it runs these SQL commands:Note that it tries to use
DROP INDEX
to drop the constraint. At least in MySQLDROP INDEX
doesnt seem to work for dropping constraints.If I run this SQL query
ALTER TABLE mytable DROP CONSTRAINT constraint_to_delete
It gets removed as expected.Reproducible Example
Here is the link to the SSCCE for this issue: n/a
What do you expect to happen?
The CHECK constraint should be dropped.
What is actually happening?
removeConstraint
throws this error:Error Code: 1091. Can't DROP 'constraint_to_delete'; check that column/key exists
despite the CHECK constraint definitely existing.Environment
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: