@@ -0,0 +1,2574 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4%0A%0A# Copyright (c) 2012 Red Hat, Inc.%0A# All Rights Reserved.%0A#%0A#    Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A#    not use this file except in compliance with the License. You may obtain%0A#    a copy of the License at%0A#%0A#         http://www.apache.org/licenses/LICENSE-2.0%0A#%0A#    Unless required by applicable law or agreed to in writing, software%0A#    distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A#    License for the specific language governing permissions and limitations%0A#    under the License.%0A%0Afrom migrate.changeset import UniqueConstraint%0Afrom sqlalchemy import MetaData, Table%0A%0A%0AOLD_MYSQL_NAME = 'instance_id'%0ANEW_MYSQL_NAME = 'instance_uuid'%0A%0AOLD_PG_NAME = 'instance_info_caches_instance_id_key'%0ANEW_PG_NAME = 'instance_info_caches_instance_uuid_key'%0A%0A%0Adef upgrade(migrate_engine):%0A    meta = MetaData()%0A    meta.bind = migrate_engine%0A%0A    # NOTE(dprince): Rename the unique key constraints for both MySQL%0A    # and PostgreSQL so they reflect the most recent UUID conversions%0A    # from Folsom.%0A    instance_info_caches = Table('instance_info_caches', meta, autoload=True)%0A%0A    if migrate_engine.name == %22mysql%22:%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=NEW_MYSQL_NAME).create()%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=OLD_MYSQL_NAME).drop()%0A    if migrate_engine.name == %22postgresql%22:%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=NEW_PG_NAME).create()%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=OLD_PG_NAME).drop()%0A%0A%0Adef downgrade(migrate_engine):%0A    meta = MetaData()%0A    meta.bind = migrate_engine%0A%0A    instance_info_caches = Table('instance_info_caches', meta, autoload=True)%0A%0A    if migrate_engine.name == %22mysql%22:%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=OLD_MYSQL_NAME).create()%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=NEW_MYSQL_NAME).drop()%0A    if migrate_engine.name == %22postgresql%22:%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=OLD_PG_NAME).create()%0A        UniqueConstraint('instance_uuid', table=instance_info_caches,%0A                         name=NEW_PG_NAME).drop()%0A

Rename instance_info_cache unique key constraints.