summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRĂ³man Joost <rjoost@redhat.com>2018-05-02 14:20:20 +1000
committerRoman Joost <rjoost@redhat.com>2018-05-10 04:42:05 +0000
commit5634c7abdc7efe3cea27979b9e41b1c986ab53bf (patch)
tree20ba14322183bdd000c4285ead792cf7dd8a1c58
parent719e2a47649deb3e19334d38f8bd6c1945afa1fe (diff)
Update original installation row migration
This migration now uses the SQL statement implemented in an online migration for Bug 1568224 Change-Id: Ia54b798df687c03c246b3ea2bd1dbfd6a5559e1e
-rw-r--r--IntegrationTests/src/bkr/inttest/server/test_database_migration.py5
-rw-r--r--Server/bkr/server/alembic/versions/3ba776df4c76_add_distro_metadata_columns_to_installation.py4
2 files changed, 4 insertions, 5 deletions
diff --git a/IntegrationTests/src/bkr/inttest/server/test_database_migration.py b/IntegrationTests/src/bkr/inttest/server/test_database_migration.py
index b6b8a5f..0e7f2e1 100644
--- a/IntegrationTests/src/bkr/inttest/server/test_database_migration.py
+++ b/IntegrationTests/src/bkr/inttest/server/test_database_migration.py
@@ -1408,15 +1408,12 @@ class MigrationTest(unittest.TestCase):
connection.execute(
"INSERT INTO recipe_set (job_id, status) "
"VALUES (1, 'Queued')")
- # should create an entry in the installation table during migration
connection.execute(
"INSERT INTO recipe (type, recipe_set_id, distro_tree_id, status) "
"VALUES ('machine_recipe', 1, 1, 'Queued')")
- # should create an entry in the installation table during migration
connection.execute(
"INSERT INTO recipe (type, recipe_set_id, distro_tree_id, status) "
"VALUES ('machine_recipe', 1, 1, 'Processed')")
- # should not create an installation entry during migration
connection.execute(
"INSERT INTO recipe (type, recipe_set_id, distro_tree_id, status) "
"VALUES ('machine_recipe', 1, 1, 'Aborted')")
@@ -1427,7 +1424,7 @@ class MigrationTest(unittest.TestCase):
# All is fixed upgrade again
upgrade_db(self.migration_metadata)
with self.migration_metadata.bind.connect() as connection:
- self.assertEqual(2,
+ self.assertEqual(3,
connection.scalar('SELECT count(*) FROM installation;'))
# https://bugzilla.redhat.com/show_bug.cgi?id=1568224
diff --git a/Server/bkr/server/alembic/versions/3ba776df4c76_add_distro_metadata_columns_to_installation.py b/Server/bkr/server/alembic/versions/3ba776df4c76_add_distro_metadata_columns_to_installation.py
index 9a7f2cb..171a166 100644
--- a/Server/bkr/server/alembic/versions/3ba776df4c76_add_distro_metadata_columns_to_installation.py
+++ b/Server/bkr/server/alembic/versions/3ba776df4c76_add_distro_metadata_columns_to_installation.py
@@ -62,8 +62,10 @@ def upgrade():
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
+ INNER JOIN recipe_set ON recipe_set.id = recipe.recipe_set_id
+ INNER JOIN job ON job.id = recipe_set.job_id
LEFT OUTER JOIN installation ON installation.recipe_id = recipe.id
- WHERE recipe.status IN ('New', 'Processed', 'Queued', 'Scheduled')
+ WHERE job.status not in ('Completed', 'Cancelled', 'Aborted')
AND installation.recipe_id is NULL;
""")