need operation to drop foreign key #44
Comments
Michael Bayer (@zzzeek) wrote: dropping a foreign key is via the op.drop_constraint() operation. it requires the name of the constraint be given. |
Changes by Michael Bayer (@zzzeek):
|
aodag (@aodag) wrote: On mysql, op.drop_constraint() causes error. For example, op.drop_constraint('fk_id', 't1') generate sql, "ALTER TABLE t1 DROP fk_id'. drop_constraint uses schema.Constraint, but mysql dialects requires subclasses of Constraint (e.g ForeignKeyConstraint, PrimaryKeyConstraint..) Maybe drop_constraint must detect kind of constraints. |
Changes by aodag (@aodag):
|
Changes by aodag (@aodag):
|
Michael Bayer (@zzzeek) wrote: can you show me the correct syntax for MySQL ? yes, the answer would be an extra parameter to drop_constraint() to suit MySQL's incompatibility here. |
Michael Bayer (@zzzeek) wrote: needs params for CHECK and UNIQUE as well, mysql breaking all the rules here. drop_constraint() alone should fail when run with MySQL if this param isn't present. |
aodag (@aodag) wrote: For drop foreign key, correct statement is" ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol". These statements seems supported by sqlalchemy.dialects.mysql. reference: |
Michael Bayer (@zzzeek) wrote: here's what I need you to test:
|
Michael Bayer (@zzzeek) wrote: we would need new tests both for sqlalchemy and alembic here, since this suggests sqlalchemy has a bug too regarding CHECK and generic constraints. |
aodag (@aodag) wrote: I tryed workaround for foreignkey constraint too. https://bitbucket.org/aodag/alembic/changeset/17ae9180ee40550f4160ea745e6c895e469c15e0 ForeignKeyConstraint requries arguments of cols and refcols. |
Michael Bayer (@zzzeek) wrote: modify ForeignKeyConstraint in SQLAlchemy to accept just "name" alone as a kw arg if no column lists are given. all of these constraints need to be able to exist as "name only" objects. |
Michael Bayer (@zzzeek) wrote: SQLA is on 0.8 right now, I can backport whatever to 0.7.7. |
Michael Bayer (@zzzeek) wrote: another thought - we should fix sqlalchemy but let's put the full series of DROP CONSTRAINT compilations into alembic, just to make things easy for now. |
Michael Bayer (@zzzeek) wrote: mysql has no CHECK constraint - brilliant ! I think i used to know this. |
Michael Bayer (@zzzeek) wrote: fixed in [[https://bitbucket.org/zzzeek/alembic/changeset/494ac8d84a4e827fcf7dc117b84ba76f442d60a2|494ac8d84a4e827fcf7dc117b84ba76f442d60a2]], please verify I got it right, thanks ! |
Changes by Michael Bayer (@zzzeek):
|
Migrated issue, originally created by aodag (@aodag)
The text was updated successfully, but these errors were encountered: