mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
import: Merge mirrordummy users _before_ recipients are stripped out.
`remove_denormalized_recipient_column_from_data` removes the `recipient` data from `zerver_userprofile`, but did not remove it from `zerver_userprofile_mirrordummy`, which was later appended to the list of `zerver_userprofile` objects. This led to failure when inserting, as the mirrordummy objects still tried to reference their previous `recipient_id`s. Move the merging of the two sets earlier, before we call `remove_denormalized_recipient_column_from_data`.
This commit is contained in:
committed by
Tim Abbott
parent
cfda414277
commit
207cfe49cf
@@ -938,6 +938,12 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int = 1) -> Rea
|
||||
logging.info("Importing realm data from %s", realm_data_filename)
|
||||
with open(realm_data_filename, "rb") as f:
|
||||
data = orjson.loads(f.read())
|
||||
|
||||
# Merge in zerver_userprofile_mirrordummy
|
||||
data["zerver_userprofile"] = data["zerver_userprofile"] + data["zerver_userprofile_mirrordummy"]
|
||||
del data["zerver_userprofile_mirrordummy"]
|
||||
data["zerver_userprofile"].sort(key=lambda r: r["id"])
|
||||
|
||||
remove_denormalized_recipient_column_from_data(data)
|
||||
|
||||
sort_by_date = data.get("sort_by_date", False)
|
||||
@@ -1013,11 +1019,6 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int = 1) -> Rea
|
||||
new_recipient_id = Recipient.objects.get(type=Recipient.PERSONAL, type_id=new_user_id).id
|
||||
update_id_map(table="recipient", old_id=item["recipient_id"], new_id=new_recipient_id)
|
||||
|
||||
# Merge in zerver_userprofile_mirrordummy
|
||||
data["zerver_userprofile"] = data["zerver_userprofile"] + data["zerver_userprofile_mirrordummy"]
|
||||
del data["zerver_userprofile_mirrordummy"]
|
||||
data["zerver_userprofile"].sort(key=lambda r: r["id"])
|
||||
|
||||
# To remap foreign key for UserProfile.last_active_message_id
|
||||
update_message_foreign_keys(import_dir=import_dir, sort_by_date=sort_by_date)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user