Merge "Add uuid to migration table"

This commit is contained in:
Jenkins 2017-09-05 20:21:10 +00:00 committed by Gerrit Code Review
commit 0fde14a493
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,27 @@
# 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 sqlalchemy import MetaData, Column, Table, Index
from sqlalchemy import String
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
for prefix in ('', 'shadow_'):
migrations = Table('%smigrations' % prefix, meta, autoload=True)
if not hasattr(migrations.c, 'uuid'):
uuid = Column('uuid', String(36))
migrations.create_column(uuid)
idx = Index('%smigrations_uuid' % prefix,
migrations.c.uuid, unique=True)
idx.create(migrate_engine)

View File

@ -752,6 +752,7 @@ class Migration(BASE, NovaBase, models.SoftDeleteMixin):
Index('migrations_by_host_nodes_and_status_idx', 'deleted',
'source_compute', 'dest_compute', 'source_node', 'dest_node',
'status'),
Index('migrations_uuid', 'uuid', unique=True),
)
id = Column(Integer, primary_key=True, nullable=False)
# NOTE(tr3buchet): the ____compute variables are instance['host']
@ -765,6 +766,7 @@ class Migration(BASE, NovaBase, models.SoftDeleteMixin):
old_instance_type_id = Column(Integer())
new_instance_type_id = Column(Integer())
instance_uuid = Column(String(36), ForeignKey('instances.uuid'))
uuid = Column(String(36), nullable=True)
# TODO(_cerberus_): enum
status = Column(String(255))
migration_type = Column(Enum('migration', 'resize', 'live-migration',

View File

@ -965,6 +965,9 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
def _check_362(self, engine, data):
self.assertColumnExists(engine, 'pci_devices', 'uuid')
def _check_373(self, engine, data):
self.assertColumnExists(engine, 'migrations', 'uuid')
class TestNovaMigrationsSQLite(NovaMigrationsCheckers,
test_base.DbTestCase,