summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorRick Harris <rick.harris@rackspace.com>2011-06-16 16:03:04 +0000
committerRick Harris <rick.harris@rackspace.com>2011-06-16 16:03:04 +0000
commit7e63dff37b01500a90f60f9c54e45d29d959a207 (patch)
tree974e389d82c887fc001117dc391eaa7b91138257 /nova
parent70685ba0ed01685f8643c499ca78ef57763ed3b5 (diff)
Added UUID migration
Diffstat (limited to 'nova')
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/024_add_uuid_to_instances.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/024_add_uuid_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/024_add_uuid_to_instances.py
new file mode 100644
index 000000000..fff194531
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/024_add_uuid_to_instances.py
@@ -0,0 +1,41 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2011 OpenStack LLC.
+#
+# 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.
+
+import uuid
+
+from sqlalchemy import Column, Integer, MetaData, String, Table
+
+
+meta = MetaData()
+
+instances = Table("instances", meta,
+ Column("id", Integer(), primary_key=True, nullable=False))
+uuid_column = Column("uuid", String(36))
+
+
+def upgrade(migrate_engine):
+ meta.bind = migrate_engine
+ instances.create_column(uuid_column)
+
+ rows = migrate_engine.execute(instances.select())
+ for row in rows:
+ instance_uuid = uuid.uuid4().hex
+ migrate_engine.execute(instances.update().values(uuid=instance_uuid))
+
+
+def downgrade(migrate_engine):
+ meta.bind = migrate_engine
+ instances.drop_column(uuid_column)