2017-10-08 21:16:51 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Generated by Django 1.11.5 on 2017-10-08 18:37
|
2019-02-02 23:53:20 +01:00
|
|
|
from django.db import migrations, models
|
2017-10-08 21:16:51 +02:00
|
|
|
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
|
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2017-10-26 11:36:30 +02:00
|
|
|
def populate_is_zephyr(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
2017-10-08 21:16:51 +02:00
|
|
|
Realm = apps.get_model("zerver", "Realm")
|
|
|
|
Stream = apps.get_model("zerver", "Stream")
|
|
|
|
|
|
|
|
realms = Realm.objects.filter(
|
|
|
|
string_id='zephyr',
|
|
|
|
)
|
|
|
|
|
|
|
|
for realm in realms:
|
|
|
|
Stream.objects.filter(
|
|
|
|
realm_id=realm.id
|
|
|
|
).update(
|
|
|
|
is_in_zephyr_realm=True
|
|
|
|
)
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
('zerver', '0109_mark_tutorial_status_finished'),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
|
|
|
model_name='stream',
|
|
|
|
name='is_in_zephyr_realm',
|
|
|
|
field=models.BooleanField(default=False),
|
|
|
|
),
|
|
|
|
migrations.RunPython(populate_is_zephyr,
|
|
|
|
reverse_code=migrations.RunPython.noop),
|
|
|
|
]
|