]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix usage drop_constraint in 2a1ee2fb59e0 migration
authorAnn Kamyshnikova <akamyshnikova@mirantis.com>
Fri, 13 Feb 2015 12:52:49 +0000 (15:52 +0300)
committerAnn Kamyshnikova <akamyshnikova@mirantis.com>
Fri, 13 Feb 2015 12:56:39 +0000 (15:56 +0300)
Downgrade for migration 2a1ee2fb59e0_add_mac_address_unique_constraint
fails as it gets wrong parameters name, source and local_cols,
although it expects name, source and type_.

Also as MySQL creates index for unique constraint it should be used
"with migration.remove_fks_from_table".

Closes-bug: #1421631

Change-Id: Id86b2f339a6fb33fc4fd637ffbfc2cb6e75ef4fb

neutron/db/migration/alembic_migrations/versions/2a1ee2fb59e0_add_mac_address_unique_constraint.py

index c5af2d81b76b65e410b16a0b798abdd870a94997..ab8dc1cfee9d9b1a52fc38aa3b09cbf139132ff2 100644 (file)
@@ -27,6 +27,7 @@ down_revision = '41662e32bce2'
 
 from alembic import op
 
+from neutron.db import migration
 
 TABLE_NAME = 'ports'
 CONSTRAINT_NAME = 'uniq_ports0network_id0mac_address'
@@ -41,8 +42,9 @@ def upgrade():
 
 
 def downgrade():
-    op.drop_constraint(
-        name=CONSTRAINT_NAME,
-        source=TABLE_NAME,
-        local_cols=['network_id', 'mac_address']
-    )
+    with migration.remove_fks_from_table(TABLE_NAME):
+        op.drop_constraint(
+            CONSTRAINT_NAME,
+            TABLE_NAME,
+            type_='unique'
+        )