From 4c2f6fee6907db503504ec38af947ce790a2d38d Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 7 Sep 2012 13:59:29 -0700 Subject: Refer to correct column names in migration 98 Database migration 98 was referring to local variables rather than actual column names in update calls. This patch changes those references to be the actual column names. Fixes bug 1047633 Change-Id: I8ceead5be32f5f56b7d15c8bed23836b29fb382a --- .../versions/098_update_volume_attach_time.py | 4 ++-- nova/tests/test_migrations.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'nova') diff --git a/nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py b/nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py index 5a239030d..1d16f093b 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/098_update_volume_attach_time.py @@ -35,7 +35,7 @@ def upgrade(migrate_engine): volumes.c.id == v['id']) volumes.update().\ where(volumes.c.id == v['id']).\ - values(attach_datetime=attach_time).execute() + values(attachtime_datetime=attach_time).execute() except Exception: attach_datetime.drop() raise @@ -62,7 +62,7 @@ def downgrade(migrate_engine): volumes.c.id == v['id']) volumes.update().\ where(volumes.c.id == v['id']).\ - values(attach_string=attach_time).execute() + values(attachtime_string=attach_time).execute() except Exception: attach_string.drop() raise diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index 1e3ca5888..9487443a2 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -303,3 +303,23 @@ class TestMigrations(test.TestCase): self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY)) + + def test_migration_98(self): + """Test that migration 98 runs + + This test exists to prove bug 1047633 has been fixed + """ + for key, engine in self.engines.items(): + migration_api.version_control(engine, TestMigrations.REPOSITORY, + migration.INIT_VERSION) + migration_api.upgrade(engine, TestMigrations.REPOSITORY, 97) + + # Set up a single volume, values don't matter + metadata = sqlalchemy.schema.MetaData() + metadata.bind = engine + volumes = sqlalchemy.Table('volumes', metadata, autoload=True) + vol_id = '9db3c2e5-8cac-4e94-9e6c-b5f750736727' + volumes.insert().values(id=vol_id).execute() + + migration_api.upgrade(engine, TestMigrations.REPOSITORY, 98) + migration_api.downgrade(engine, TestMigrations.REPOSITORY, 97) -- cgit