Change id column in LogEntry to a BigInt and migrate back to using that table

This commit is contained in:
Joseph Schorr 2018-07-27 17:46:46 -04:00
parent 5e4d52f1fd
commit 7325b22c90
8 changed files with 56 additions and 22 deletions

View file

@ -60,19 +60,19 @@ class PreOCIModel(LogEntryDataInterface):
limit=20)
return LogEntryPage([_create_log(log) for log in logs], next_page_token)
# First check the LogEntry2 table for the most recent logs, unless we've been expressly told
# to look inside the first table.
TOKEN_TABLE_KEY = 'ttk'
is_old_table = page_token is not None and page_token.get(TOKEN_TABLE_KEY) == 1
if is_old_table:
page_result = get_logs(database.LogEntry)
else:
# First check the LogEntry table for the most recent logs, unless we've been expressly told
# to look inside the "second" table.
TOKEN_TABLE_KEY2 = 'ttk2'
is_temp_table = page_token is not None and page_token.get(TOKEN_TABLE_KEY2) == 1
if is_temp_table:
page_result = get_logs(database.LogEntry2)
else:
page_result = get_logs(database.LogEntry)
if page_result.next_page_token is None and not is_old_table:
page_result = page_result._replace(next_page_token={TOKEN_TABLE_KEY: 1})
elif is_old_table and page_result.next_page_token is not None:
page_result.next_page_token[TOKEN_TABLE_KEY] = 1
if page_result.next_page_token is None and not is_temp_table:
page_result = page_result._replace(next_page_token={TOKEN_TABLE_KEY2: 1})
elif is_temp_table and page_result.next_page_token is not None:
page_result.next_page_token[TOKEN_TABLE_KEY2] = 1
return page_result