models: Migration of Message.pub_date to date_sent, part 2.

Fixes #1727.

With the server down, apply migrations 0245 and 0246. 0246 will remove
the pub_date column, so it's essential that the previous migrations
ran correctly to copy data before running this.
This commit is contained in:
Mateusz Mandera
2019-08-28 02:43:19 +02:00
committed by Tim Abbott
parent f198475281
commit dbe508bb91
37 changed files with 206 additions and 129 deletions

View File

@@ -1091,7 +1091,7 @@ def get_incoming_message_ids(import_dir: Path,
ids, which can be millions of integers for some installations.
And then we sort the list. This is necessary to ensure
that the sort order of incoming ids matches the sort order
of pub_date, which isn't always guaranteed by our
of date_sent, which isn't always guaranteed by our
utilities that convert third party chat data. We also
need to move our ids to a new range if we're dealing
with a server that has data for other realms.
@@ -1115,7 +1115,7 @@ def get_incoming_message_ids(import_dir: Path,
del data['zerver_usermessage']
for row in data['zerver_message']:
# We truncate pub_date to int to theoretically
# We truncate date_sent to int to theoretically
# save memory and speed up the sort. For
# Zulip-to-Zulip imports, the
# message_id will generally be a good tiebreaker.
@@ -1128,8 +1128,8 @@ def get_incoming_message_ids(import_dir: Path,
message_id = row['id']
if sort_by_date:
pub_date = int(row['pub_date'])
tup = (pub_date, message_id)
date_sent = int(row['date_sent'])
tup = (date_sent, message_id)
tups.append(tup)
else:
message_ids.append(message_id)