Give new primary key constraint unique name, create first live partition

This commit is contained in:
Jim Ladd
2021-02-19 14:31:32 -08:00
parent ba45592d93
commit 0c289205de
2 changed files with 17 additions and 8 deletions

View File

@@ -1009,7 +1009,6 @@ def truncate_stdout(stdout, size):
return stdout + u'\u001b[0m' * (set_count - reset_count)
def deepmerge(a, b):
"""
Merge dict structures and return the result.
@@ -1027,12 +1026,16 @@ def deepmerge(a, b):
return b
def create_partition(partition_label, start, end=None):
"""Creates new partition tables for events."""
def create_partition(start, end=None, partition_label=None):
"""Creates new partition tables for events.
If not specified, end is set to the end of the current hour."""
if not end:
end = (now() + timedelta(hours=1))
start_timestamp = start.strftime('%Y-%m-%d %H:00:00.000000%z')
end_timestamp = end.strftime('%Y-%m-%d %H:00:00.000000%z')
end = start.replace(microsecond=0, second=0, minute=0) + timedelta(hours=1)
start_timestamp = str(start)
end_timestamp = str(end)
if not partition_label:
partition_label = start.strftime('%Y_%m_%d_%H')
with connection.cursor() as cursor:
# Only partitioning main_jobevent on first pass