summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRĂ³man Joost <rjoost@redhat.com>2018-05-02 14:18:05 +1000
committerRoman Joost <rjoost@redhat.com>2018-05-10 04:42:05 +0000
commit719e2a47649deb3e19334d38f8bd6c1945afa1fe (patch)
tree0150fbf6d52d6f9f5827f319afe1c5abcd02c6cd
parent4834f263a3e2ee2b9d22a226a07278a57d528e13 (diff)
Make the previous installation online migration a NOOP
The online migration has no value and does nothing. It was replaced by the 'insert-installation-row-for-recipes-before-25-take-2' online migration. Change-Id: I19f8e4155a05b29399f37d3817f5de9df1b46ad0
-rw-r--r--IntegrationTests/src/bkr/inttest/server/test_database_migration.py6
-rw-r--r--Server/bkr/server/data-migrations/insert-installation-row-for-scheduled-recipes-before-25.py27
2 files changed, 10 insertions, 23 deletions
diff --git a/IntegrationTests/src/bkr/inttest/server/test_database_migration.py b/IntegrationTests/src/bkr/inttest/server/test_database_migration.py
index aaac5cb..b6b8a5f 100644
--- a/IntegrationTests/src/bkr/inttest/server/test_database_migration.py
+++ b/IntegrationTests/src/bkr/inttest/server/test_database_migration.py
@@ -1461,10 +1461,16 @@ class MigrationTest(unittest.TestCase):
self.assertIsNone(recipe.installation)
self.migration_session.close()
+ # This migration has become a NOOP
migration = DataMigration(name=u'insert-installation-row-for-scheduled-recipes-before-25')
finished = migration.migrate_one_batch(self.migration_metadata.bind)
self.assertTrue(finished)
+ # This is the right data migration
+ migration = DataMigration(name=u'insert-installation-row-for-recipes-before-25-take-2')
+ finished = migration.migrate_one_batch(self.migration_metadata.bind)
+ self.assertTrue(finished)
+
recipe = self.migration_session.query(Recipe).get(1)
self.assertIsNotNone(recipe.installation)
self.assertEqual(recipe.installation.distro_tree_id, 1)
diff --git a/Server/bkr/server/data-migrations/insert-installation-row-for-scheduled-recipes-before-25.py b/Server/bkr/server/data-migrations/insert-installation-row-for-scheduled-recipes-before-25.py
index 2219379..d958108 100644
--- a/Server/bkr/server/data-migrations/insert-installation-row-for-scheduled-recipes-before-25.py
+++ b/Server/bkr/server/data-migrations/insert-installation-row-for-scheduled-recipes-before-25.py
@@ -19,27 +19,8 @@ logger = logging.getLogger(__name__)
def migrate_one_batch(engine):
- with engine.begin() as connection:
- result = connection.execute("""
- INSERT INTO installation
- (created, distro_tree_id, recipe_id, arch_id, distro_name, osmajor, osminor, variant)
- SELECT UTC_TIMESTAMP(),
- recipe.distro_tree_id,
- recipe.id,
- distro_tree.arch_id,
- distro.name,
- osmajor.osmajor,
- osversion.osminor,
- distro_tree.variant
- FROM recipe
- INNER JOIN distro_tree ON distro_tree.id = recipe.distro_tree_id
- INNER JOIN distro ON distro.id = distro_tree.distro_id
- INNER JOIN osversion ON osversion.id = distro.osversion_id
- INNER JOIN osmajor ON osmajor.id = osversion.osmajor_id
- LEFT OUTER JOIN installation ON installation.recipe_id = recipe.id
- WHERE recipe.status = 'Scheduled'
- AND installation.recipe_id is NULL;
- """)
-
- logger.info('Created installation row for %d recipes', result.rowcount)
+ # This migration turned out to be not effective. There were more jobs in
+ # different states affected than just a forgotten 'Scheduled' recipe state.
+ # See insert-installation-row-for-recipes-before-25-take-2.py for the
+ # actual online migration which fixes this.
return True