diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-11-26 21:43:09 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-26 21:43:09 +0000 |
| commit | 0e4e6edb06951dc836651697c2dc6bd0a7d0f862 (patch) | |
| tree | 9c1aa6119f695fa037e7e162045b3daeaf83455a | |
| parent | b1e8c29bd95874eb8a3d210b40da200051836aa8 (diff) | |
| parent | 6d65637dec129863ac4a96bb28b476f032bbff84 (diff) | |
| download | nova-0e4e6edb06951dc836651697c2dc6bd0a7d0f862.tar.gz nova-0e4e6edb06951dc836651697c2dc6bd0a7d0f862.tar.xz nova-0e4e6edb06951dc836651697c2dc6bd0a7d0f862.zip | |
Merge "Rename instance_info_cache unique key constraints."
| -rw-r--r-- | nova/db/sqlalchemy/migrate_repo/versions/143_rename_instance_info_cache_sequence.py | 65 |
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() |
