Skip to content

Commit

Permalink
Fix broken queries on rerun
Browse files Browse the repository at this point in the history
After the update to the leapp db table names, the rerun command fails.
This commit fixes the issue by using the current schema.
  • Loading branch information
dkubek committed Jun 6, 2024
1 parent 03c651c commit cc83dff
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions leapp/utils/audit/contextclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

0 comments on commit cc83dff

Please sign in to comment.