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
This commit is contained in:
Thierry Carrez 2011-12-15 21:54:07 +01:00 committed by Vishvananda Ishaya
parent fb8a7a6195
commit 5a28a07b10
1 changed files with 7 additions and 0 deletions

View File

@ -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()