mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Partition *all* job event tables
This commit is contained in:
parent
2ffa22e38f
commit
ec484f81cf
@ -24,14 +24,11 @@ def migrate_event_data(apps, schema_editor):
|
||||
# All events for a given job should be placed in
|
||||
# a partition based on the job's _created time_.
|
||||
|
||||
# Only partitioning main_jobevent on first pass
|
||||
#
|
||||
#for tblname in (
|
||||
# 'main_jobevent', 'main_inventoryupdateevent',
|
||||
# 'main_projectupdateevent', 'main_adhoccommandevent',
|
||||
# 'main_systemjobevent'
|
||||
#):
|
||||
for tblname in ('main_jobevent',):
|
||||
for tblname in (
|
||||
'main_jobevent', 'main_inventoryupdateevent',
|
||||
'main_projectupdateevent', 'main_adhoccommandevent',
|
||||
'main_systemjobevent'
|
||||
):
|
||||
with connection.cursor() as cursor:
|
||||
# mark existing table as *_old;
|
||||
# we will drop this table after its data
|
||||
|
||||
@ -1026,8 +1026,8 @@ def deepmerge(a, b):
|
||||
return b
|
||||
|
||||
|
||||
def create_partition(start=None, end=None, partition_label=None, minutely=True):
|
||||
"""Creates new partition tables for events.
|
||||
def create_partition(tblname, start=None, end=None, partition_label=None, minutely=False):
|
||||
"""Creates new partition table for events.
|
||||
- start defaults to beginning of current hour
|
||||
- end defaults to end of current hour
|
||||
- partition_label defaults to YYYYMMDD_HH
|
||||
@ -1055,16 +1055,8 @@ def create_partition(start=None, end=None, partition_label=None, minutely=True):
|
||||
partition_label = start.strftime('%Y%m%d_%H')
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
# Only partitioning main_jobevent on first pass
|
||||
#
|
||||
#for tblname in (
|
||||
# 'main_jobevent', 'main_inventoryupdateevent',
|
||||
# 'main_projectupdateevent', 'main_adhoccommandevent',
|
||||
# 'main_systemjobevent'
|
||||
#):
|
||||
for tblname in ('main_jobevent',):
|
||||
cursor.execute(
|
||||
f'CREATE TABLE IF NOT EXISTS {tblname}_{partition_label} '
|
||||
f'PARTITION OF {tblname} '
|
||||
f'FOR VALUES FROM (\'{start_timestamp}\') to (\'{end_timestamp}\');'
|
||||
)
|
||||
cursor.execute(
|
||||
f'CREATE TABLE IF NOT EXISTS {tblname}_{partition_label} '
|
||||
f'PARTITION OF {tblname} '
|
||||
f'FOR VALUES FROM (\'{start_timestamp}\') to (\'{end_timestamp}\');'
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user