2017-11-15 23:43:01 +01:00
|
|
|
# Generated by Django 1.11.5 on 2017-10-19 22:01
|
|
|
|
|
|
|
|
import django.db.models.deletion
|
2020-01-14 21:59:46 +01:00
|
|
|
from django.db import migrations, models
|
2020-04-27 07:19:08 +02:00
|
|
|
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
2017-11-15 23:43:01 +01:00
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2017-11-15 23:43:01 +01:00
|
|
|
def set_initial_value_for_signup_notifications_stream(
|
2021-02-12 08:19:30 +01:00
|
|
|
apps: StateApps, schema_editor: DatabaseSchemaEditor
|
|
|
|
) -> None:
|
2017-11-15 23:43:01 +01:00
|
|
|
realm_model = apps.get_model("zerver", "Realm")
|
|
|
|
realms = realm_model.objects.exclude(notifications_stream__isnull=True)
|
|
|
|
for realm in realms:
|
|
|
|
realm.signup_notifications_stream = realm.notifications_stream
|
|
|
|
realm.save(update_fields=["signup_notifications_stream"])
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2017-11-15 23:43:01 +01:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("zerver", "0120_botuserconfigdata"),
|
2017-11-15 23:43:01 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
2021-02-12 08:20:45 +01:00
|
|
|
model_name="realm",
|
|
|
|
name="signup_notifications_stream",
|
2021-02-12 08:19:30 +01:00
|
|
|
field=models.ForeignKey(
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
on_delete=django.db.models.deletion.CASCADE,
|
2021-02-12 08:20:45 +01:00
|
|
|
related_name="+",
|
|
|
|
to="zerver.Stream",
|
2021-02-12 08:19:30 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
migrations.RunPython(
|
|
|
|
set_initial_value_for_signup_notifications_stream,
|
|
|
|
reverse_code=migrations.RunPython.noop,
|
|
|
|
elidable=True,
|
2017-11-15 23:43:01 +01:00
|
|
|
),
|
|
|
|
]
|