Permalink
Browse files

Ensure fkey is dropped before removing instance_id

This fixes Bug #904888

On MySQL databases that use InnoDB by default (ie, at the point when
database is being first migrated), extra care needs to be taken to
ensure FKs are dropped before columns because they are not automatically.

Patch from Adam Gandelman and Scott Moser.

Change-Id: I32919a46bb76f524e064098738ad98248b2f1c0e
  • Loading branch information...
1 parent fb8a7a6 commit 5a28a07b10c4f7fef2046c4e84929706c8351e19 @ttx ttx committed with vishvananda Dec 15, 2011
View
7 ...db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py
@@ -48,6 +48,13 @@ def upgrade(migrate_engine):
uuid_column.drop()
raise
+ if migrate_engine.name == "mysql":
+ try:
+ migrate_engine.execute("ALTER TABLE instance_actions " \
+ "DROP FOREIGN KEY instance_actions_ibfk_1;")
+ except Exception: # Don't care, just fail silently.
+ pass
+
instance_actions.c.instance_id.drop()

0 comments on commit 5a28a07

Please sign in to comment.