summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2012-11-19 14:42:54 -0500
committerDan Prince <dprince@redhat.com>2012-11-25 23:34:39 -0500
commit6d65637dec129863ac4a96bb28b476f032bbff84 (patch)
tree0f6980225fe0eaabd0a95dad27db9a4b062c4284 /nova
parenta42ebf01f6c321a851ddea337bc7365abff2f1d2 (diff)
downloadnova-6d65637dec129863ac4a96bb28b476f032bbff84.tar.gz
nova-6d65637dec129863ac4a96bb28b476f032bbff84.tar.xz
nova-6d65637dec129863ac4a96bb28b476f032bbff84.zip
Rename instance_info_cache unique key constraints.
Rename (via drop and recreate) the instance_uuid unique constraints on the instance_info_cache table so they reflect the column change name (UUID conversion) we complete in Folsom. Fixes LP Bug #1080837. Change-Id: I9dd01ebc896c1d7b51c212980e48db16bad18dec
Diffstat (limited to 'nova')
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/143_rename_instance_info_cache_sequence.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/143_rename_instance_info_cache_sequence.py b/nova/db/sqlalchemy/migrate_repo/versions/143_rename_instance_info_cache_sequence.py
new file mode 100644
index 000000000..b7b867358
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/143_rename_instance_info_cache_sequence.py
@@ -0,0 +1,65 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2012 Red Hat, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from migrate.changeset import UniqueConstraint
+from sqlalchemy import MetaData, Table
+
+
+OLD_MYSQL_NAME = 'instance_id'
+NEW_MYSQL_NAME = 'instance_uuid'
+
+OLD_PG_NAME = 'instance_info_caches_instance_id_key'
+NEW_PG_NAME = 'instance_info_caches_instance_uuid_key'
+
+
+def upgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+
+ # NOTE(dprince): Rename the unique key constraints for both MySQL
+ # and PostgreSQL so they reflect the most recent UUID conversions
+ # from Folsom.
+ instance_info_caches = Table('instance_info_caches', meta, autoload=True)
+
+ if migrate_engine.name == "mysql":
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=NEW_MYSQL_NAME).create()
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=OLD_MYSQL_NAME).drop()
+ if migrate_engine.name == "postgresql":
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=NEW_PG_NAME).create()
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=OLD_PG_NAME).drop()
+
+
+def downgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+
+ instance_info_caches = Table('instance_info_caches', meta, autoload=True)
+
+ if migrate_engine.name == "mysql":
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=OLD_MYSQL_NAME).create()
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=NEW_MYSQL_NAME).drop()
+ if migrate_engine.name == "postgresql":
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=OLD_PG_NAME).create()
+ UniqueConstraint('instance_uuid', table=instance_info_caches,
+ name=NEW_PG_NAME).drop()