Peewee: Drop Constraint Syntax Error in MySQL 8.0.18

Created on 23 Jul 2020  路  4Comments  路  Source: coleifer/peewee

Hi,

I'm using peewee.playhouse.migrate.drop_constraint to do some migrations on MySQL 8.0.18.
If failed with error message:

`Error in query (1064): Syntax error near 'CONSTRAINT `constraint_name`' at line 1`

I've checked the SQL.
This will fail:

ALTER TABLE xxx DROP CONSTRAINTS XXX

This will succeed:
ALTER TABLE xxx DROP FOREIGN KEY XXX

Is there anything peewee can improve? Or configurations in MySQL I ignored?

Thanks for your help!

Most helpful comment

I couldn't find it in peewee's documentation. Maybe could add it later. Thanks!

All 4 comments

For MySQL you would use the drop_foreign_key_constraint migrator method.

I couldn't find it in peewee's documentation. Maybe could add it later. Thanks!

Oh, it's spent a lot of time to find drop_foreign_key_constraint method... It will be very usefull to add it to the docs.

The foreign-key constraint should be dropped automatically when dropping a foreign-key column.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aellwein picture aellwein  路  3Comments

mmongeon-aa picture mmongeon-aa  路  4Comments

dev-zero picture dev-zero  路  4Comments

mikemill picture mikemill  路  3Comments

alexpantyukhin picture alexpantyukhin  路  5Comments