mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 21:37:42 -02:30
Fix migration for _all_ job event tables
- each job event table has a different name for the fk referencing the unified job id - create a mapping so that we get the col name correct for each table
This commit is contained in:
@@ -69,12 +69,18 @@ def migrate_event_data(apps, schema_editor):
|
|||||||
create_partition(tblname, current_time)
|
create_partition(tblname, current_time)
|
||||||
|
|
||||||
# copy over all job events into partitioned table
|
# copy over all job events into partitioned table
|
||||||
# TODO: https://github.com/ansible/awx/issues/9257
|
# TODO: bigint style migration (https://github.com/ansible/awx/issues/9257)
|
||||||
|
tblname_to_uj_fk = {'main_jobevent': 'job_id',
|
||||||
|
'main_inventoryupdateevent': 'inventory_update_id',
|
||||||
|
'main_projectupdateevent': 'project_update_id',
|
||||||
|
'main_adhoccommandevent': 'ad_hoc_command_id',
|
||||||
|
'main_systemjobevent': 'system_job_id'}
|
||||||
|
uj_fk_col = tblname_to_uj_fk[tblname]
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
f'INSERT INTO {tblname} '
|
f'INSERT INTO {tblname} '
|
||||||
f'SELECT {tblname}_old.*, main_unifiedjob.created '
|
f'SELECT {tblname}_old.*, main_unifiedjob.created '
|
||||||
f'FROM {tblname}_old '
|
f'FROM {tblname}_old '
|
||||||
f'INNER JOIN main_unifiedjob ON {tblname}_old.job_id = main_unifiedjob.id;'
|
f'INNER JOIN main_unifiedjob ON {tblname}_old.{uj_fk_col} = main_unifiedjob.id;'
|
||||||
)
|
)
|
||||||
|
|
||||||
# drop old table
|
# drop old table
|
||||||
|
|||||||
Reference in New Issue
Block a user