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