set event horizon to -1 for empty tables

This commit is contained in:
Jim Ladd 2021-03-25 14:23:53 -07:00
parent 7e1814e234
commit 14168297bd

View File

@ -181,7 +181,7 @@ def unpartitioned_event_horizon(cls):
with connection.cursor() as cursor:
try:
cursor.execute(f'SELECT MAX(id) FROM _unpartitioned_{cls._meta.db_table}')
return cursor.fetchone()[0]
return cursor.fetchone()[0] or -1
except ProgrammingError:
return 0