import: Rewrite "delivered_message" column of scheduled messages.

This also requires shuffling the message import to before the
scheduled messages.

Fixes: #28690.
This commit is contained in:
Alex Vandiver 2024-01-24 20:18:08 +00:00
parent ffc1056c45
commit c974b421e3
1 changed files with 6 additions and 3 deletions

View File

@ -1337,6 +1337,9 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int = 1) -> Rea
sender_map = {user["id"]: user for user in data["zerver_userprofile"]}
# Import zerver_message and zerver_usermessage
import_message_data(realm=realm, sender_map=sender_map, import_dir=import_dir)
if "zerver_scheduledmessage" in data:
fix_datetime_fields(data, "zerver_scheduledmessage")
re_map_foreign_keys(data, "zerver_scheduledmessage", "sender", related_table="user_profile")
@ -1346,6 +1349,9 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int = 1) -> Rea
)
re_map_foreign_keys(data, "zerver_scheduledmessage", "stream", related_table="stream")
re_map_foreign_keys(data, "zerver_scheduledmessage", "realm", related_table="realm")
re_map_foreign_keys(
data, "zerver_scheduledmessage", "delivered_message", related_table="message"
)
fix_upload_links(data, "zerver_scheduledmessage")
@ -1358,9 +1364,6 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int = 1) -> Rea
update_model_ids(ScheduledMessage, data, "scheduledmessage")
bulk_import_model(data, ScheduledMessage)
# Import zerver_message and zerver_usermessage
import_message_data(realm=realm, sender_map=sender_map, import_dir=import_dir)
re_map_foreign_keys(data, "zerver_reaction", "message", related_table="message")
re_map_foreign_keys(data, "zerver_reaction", "user_profile", related_table="user_profile")
re_map_realm_emoji_codes(data, table_name="zerver_reaction")