leapp/0023-Fix-broken-queries-on-rerun.patch
Toshio Kuratomi 1be26899be LEAPP Release CTC-2 candidate 1 (8.10/9.5)
- Fix broken leapp db queries on rerun
- Port all code to be Python-3.12 compatible.
- Resolves: RHEL-40363
2024-07-24 19:18:17 -07:00

47 lines
2.2 KiB
Diff

From fcd13bc8720cd7efdf5398387307971f6f8afc76 Mon Sep 17 00:00:00 2001
From: David Kubek <dkubek@redhat.com>
Date: Thu, 6 Jun 2024 15:08:44 +0200
Subject: [PATCH 23/23] Fix broken queries on rerun
After the update to the leapp db table names, the rerun command fails.
This commit fixes the issue by using the current schema.
---
leapp/utils/audit/contextclone.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/leapp/utils/audit/contextclone.py b/leapp/utils/audit/contextclone.py
index 1c80f2c..d988d06 100644
--- a/leapp/utils/audit/contextclone.py
+++ b/leapp/utils/audit/contextclone.py
@@ -70,14 +70,14 @@ def _dup_audit(db, message, data_source, newcontext, oldcontext):
return lookup
-def _dup_metadata(db, newcontext, oldcontext):
- for row in _fetch_table_for_context(db, 'metadata', oldcontext):
- # id context kind name metadata
- row_id, kind, name, metadata = _row_tuple(row, 'id', 'kind', 'name', 'metadata')
+def _dup_entity(db, newcontext, oldcontext):
+ for row in _fetch_table_for_context(db, 'entity', oldcontext):
+ # id context kind name metadata_hash
+ row_id, kind, name, metadata_hash = _row_tuple(row, 'id', 'kind', 'name', 'metadata_hash')
db.execute(
- 'INSERT INTO metadata (context, kind, name, metadata) VALUES(?, ?, ?, ?)',
- (newcontext, kind, name, metadata))
+ 'INSERT INTO entity (context, kind, name, metadata_hash) VALUES(?, ?, ?, ?)',
+ (newcontext, kind, name, metadata_hash))
def _dup_dialog(db, data_source, newcontext, oldcontext):
@@ -102,5 +102,5 @@ def clone_context(oldcontext, newcontext, use_db=None):
message = _dup_message(db=db, data_source=data_source, newcontext=newcontext, oldcontext=oldcontext)
# Last clone message entries and use the lookup table generated by the data_source and message duplications
_dup_audit(db=db, data_source=data_source, message=message, newcontext=newcontext, oldcontext=oldcontext)
- _dup_metadata(db=db, oldcontext=oldcontext, newcontext=newcontext)
+ _dup_entity(db=db, oldcontext=oldcontext, newcontext=newcontext)
_dup_dialog(db=db, data_source=data_source, oldcontext=oldcontext, newcontext=newcontext)
--
2.42.0