# Generated by Django 5.2.7 on 2025-11-08 13:55

from django.db import migrations, models
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps


def set_send_channel_events_messages_for_existing_organizations(
    apps: StateApps, schema_editor: BaseDatabaseSchemaEditor
) -> None:
    # We're preserving the `True` prior behavior for existing organizations,
    # while setting the default for new organizations to `False`.
    Realm = apps.get_model("zerver", "Realm")
    Realm.objects.all().update(send_channel_events_messages=True)


class Migration(migrations.Migration):
    dependencies = [
        ("zerver", "0760_preregistrationuser_is_realm_importer"),
    ]

    operations = [
        migrations.AddField(
            model_name="realm",
            name="send_channel_events_messages",
            field=models.BooleanField(default=False),
        ),
        migrations.RunPython(
            set_send_channel_events_messages_for_existing_organizations, elidable=True
        ),
    ]
