Files
zulip/zerver/migrations/0317_migrate_to_invite_to_realm_policy.py
sahil839 4c8339fa8c settings: Replace invite_by_admins_policy with invite_to_realm_policy.
This commit replaces invite_by_admins_policy, which was a bool field,
with a new enum field invite_by_realm_policy.

Though the final goal is to add moderators and full members option
using COMMON_POLICY_TYPES, but this will be done in a separate
commit to make this easy for review.
2021-04-07 09:02:33 -07:00

31 lines
1023 B
Python

# Generated by Django 3.1.7 on 2021-04-01 19:27
from django.db import migrations
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def migrate_to_invite_to_realm_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
Realm = apps.get_model("zerver", "Realm")
Realm.INVITE_TO_REALM_POLICY_MEMBERS_ONLY = 1
Realm.INVITE_TO_REALM_POLICY_ADMINS_ONLY = 2
Realm.objects.filter(invite_by_admins_only=False).update(
invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_MEMBERS_ONLY
)
Realm.objects.filter(invite_by_admins_only=True).update(
invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_ADMINS_ONLY
)
class Migration(migrations.Migration):
dependencies = [
("zerver", "0316_realm_invite_to_realm_policy"),
]
operations = [
migrations.RunPython(
migrate_to_invite_to_realm_policy, reverse_code=migrations.RunPython.noop, elidable=True
),
]