From b539b6acea4797954ff45ad96904dc9e08691525 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 19 Nov 2012 15:58:29 -0500 Subject: Convert migrations.instance_uuid to String(36). Updates the length of the instance_uuid column in the migrations to match the length of UUID's in Nova. Fixes LP Bug #1080854. Change-Id: I213c48835f9efa4a9a84932c343c1079c5cc65ca --- .../141_update_migrations_instance_uuid.py | 33 ++++++++++++++++++++++ nova/db/sqlalchemy/models.py | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/141_update_migrations_instance_uuid.py (limited to 'nova') diff --git a/nova/db/sqlalchemy/migrate_repo/versions/141_update_migrations_instance_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/141_update_migrations_instance_uuid.py new file mode 100644 index 000000000..086435022 --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/141_update_migrations_instance_uuid.py @@ -0,0 +1,33 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright (c) 2012 Red Hat, Inc. +# +# 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, String, Table + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + migrations = Table('migrations', meta, autoload=True) + migrations.c.instance_uuid.alter(String(36)) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + migrations = Table('migrations', meta, autoload=True) + migrations.c.instance_uuid.alter(String(255)) diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index fbcfe7668..5716f9ecd 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -635,7 +635,7 @@ class Migration(BASE, NovaBase): dest_host = Column(String(255)) old_instance_type_id = Column(Integer()) new_instance_type_id = Column(Integer()) - instance_uuid = Column(String(255), ForeignKey('instances.uuid'), + instance_uuid = Column(String(36), ForeignKey('instances.uuid'), nullable=True) #TODO(_cerberus_): enum status = Column(String(255)) -- cgit