migrations: Create realm reactivation ContentType if required.

Because Django's ContentType objects are, by default, created lazily
when an actual object is created that will use them, this migration
would fail on any server that actually had RealmReactivationStatus
objects already, and had not yet created the ContentType for them.

ContentType objects are very simple:

zulip=> select * from django_content_type where model = 'realmreactivationstatus';
 id | app_label |          model
----+-----------+-------------------------
 85 | zerver    | realmreactivationstatus

So we can simply patch this by using get_or_create.
This commit is contained in:
Tim Abbott 2022-08-07 22:15:41 -07:00
parent 98c7427bfc
commit 7661df20a9
1 changed files with 1 additions and 1 deletions

View File

@ -32,7 +32,7 @@ def fix_old_realm_reactivation_confirmations(
return return
# .content_type of these old Confirmation will be changed to this. # .content_type of these old Confirmation will be changed to this.
realm_reactivation_status_content_type = ContentType.objects.get( realm_reactivation_status_content_type, created = ContentType.objects.get_or_create(
model="realmreactivationstatus", app_label="zerver" model="realmreactivationstatus", app_label="zerver"
) )