diff options
| author | Chuck Short <chuck.short@canonical.com> | 2012-01-17 14:24:09 -0500 |
|---|---|---|
| committer | Chuck Short <chuck.short@canonical.com> | 2012-01-17 14:26:29 -0500 |
| commit | 35df99cf1dca5d9b0ca1cb09039845aa8bd3a49b (patch) | |
| tree | 2a0ff6504f5d2920aaa981c1daafd3056dfa2620 /nova | |
| parent | 8c1e0022028a454f536ff211aa200cab9b0111aa (diff) | |
| download | nova-35df99cf1dca5d9b0ca1cb09039845aa8bd3a49b.tar.gz nova-35df99cf1dca5d9b0ca1cb09039845aa8bd3a49b.tar.xz nova-35df99cf1dca5d9b0ca1cb09039845aa8bd3a49b.zip | |
Drop FK constraint if it exists in migration 064
Fixes LP bug 916992
A workaround was originally applied to fix a FK constraint problem in migration
064. The original bug only affected MySQL+InnoDB databases and was masked by
using MySQL+MyISAM. Commit d503d6b1079f9eafe0430754214fc5b6d4e32c09 attempted
to improve the workaround, though it caused issues on databases not using
InnoDB, so it was reverted enitrely and we are back with the original bug.
This change will attempt to drop the FK constraint only if it exists. This
should now support MySQL installations that are configured both
default_storage_engine=MyISAM (oneiric) and default_storage_engine=InnoDB
(precise)
Change-Id: Ie2cfa32d8f52b163f513679649da52a73fc501df
Signed-off-by: Adam Gandleman <adam.gandleman@canonical.com>
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py b/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py index df9d73028..1bff3b5af 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py @@ -17,6 +17,7 @@ import sqlalchemy from sqlalchemy import select, Column, ForeignKey, Integer, String +from migrate import ForeignKeyConstraint from nova import log as logging @@ -31,6 +32,7 @@ def _get_table(name): def upgrade(migrate_engine): meta.bind = migrate_engine + dialect = migrate_engine.url.get_dialect().name instance_actions = _get_table('instance_actions') instances = _get_table('instances') uuid_column = Column('instance_uuid', String(36), @@ -48,6 +50,18 @@ def upgrade(migrate_engine): uuid_column.drop() raise + if not dialect.startswith('sqlite'): + fkeys = list(instance_actions.c.instance_id.foreign_keys) + if fkeys: + try: + fkey_name = fkeys[0].constraint.name + ForeignKeyConstraint(columns=[instance_actions.c.instance_id], + refcolumns=[instances.c.id], + name=fkey_name).drop() + except: + logging.error(_("foreign key constraint couldn't be removed")) + raise + instance_actions.c.instance_id.drop() |
