summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-20 00:33:48 +0000
committerGerrit Code Review <review@openstack.org>2012-09-20 00:33:48 +0000
commite7e1cfc8ab9792654c8c09f35f8cf98fe463ba66 (patch)
treebd08e73525fd2d9be6132eaec4dcaf4720f96477 /nova
parent848af020a1f91b4638c07206667e48570fe7d2d6 (diff)
parenta5dbdb53da470916248c8ef8715ef6e06dfa1d0f (diff)
Merge "Fix aggregate_hosts.host migration for sqlite"
Diffstat (limited to 'nova')
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py3
-rw-r--r--nova/tests/test_migrations.py24
2 files changed, 25 insertions, 2 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py b/nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py
index 0c97112ce..df4a83843 100644
--- a/nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py
+++ b/nova/db/sqlalchemy/migrate_repo/versions/111_general_aggregates.py
@@ -43,8 +43,7 @@ def upgrade(migrate_engine):
aggregate_hosts = Table('aggregate_hosts', meta, autoload=True)
if dialect.startswith('sqlite'):
- aggregate_hosts.drop_column('host')
- aggregate_hosts.create_column(Column('host', String(255)))
+ aggregate_hosts.c.host.alter(unique=False)
elif dialect.startswith('postgres'):
ucon = UniqueConstraint('host',
name='aggregate_hosts_host_key',
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py
index 73b50c280..1e8714b94 100644
--- a/nova/tests/test_migrations.py
+++ b/nova/tests/test_migrations.py
@@ -456,3 +456,27 @@ class TestMigrations(test.TestCase):
sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall()
self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]),
set([vol1_id]))
+
+ def test_migration_111(self):
+ for key, engine in self.engines.items():
+ migration_api.version_control(engine, TestMigrations.REPOSITORY,
+ migration.INIT_VERSION)
+ migration_api.upgrade(engine, TestMigrations.REPOSITORY, 110)
+
+ metadata = sqlalchemy.schema.MetaData()
+ metadata.bind = engine
+ aggregate_hosts = sqlalchemy.Table('aggregate_hosts', metadata,
+ autoload=True)
+ host = 'host'
+ aggregate_hosts.insert().values(id=1,
+ aggregate_id=1, host=host).execute()
+
+ migration_api.upgrade(engine, TestMigrations.REPOSITORY, 111)
+ agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first()
+ self.assertEqual(host, agg.host)
+ aggregate_hosts.insert().values(id=2,
+ aggregate_id=2, host=host).execute()
+
+ migration_api.downgrade(engine, TestMigrations.REPOSITORY, 111)
+ agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first()
+ self.assertEqual(host, agg.host)