# Generated by Django 4.2.11 on 2024-04-09 13:39
from __future__ import annotations

from typing import TYPE_CHECKING

from django.db import migrations

if TYPE_CHECKING:
    from django.db.backends.base.schema import BaseDatabaseSchemaEditor
    from django.db.migrations.state import StateApps


def _create_default_policy(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
    db_alias = schema_editor.connection.alias
    model_type = apps.get_model("slack_messages", "SlackMessagingPolicy")
    model_type.objects.using(db_alias).create(code="DEFAULT", enabled=False)


def _delete_default_policy(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
    db_alias = schema_editor.connection.alias
    model_type = apps.get_model("slack_messages", "SlackMessagingPolicy")
    model_type.objects.using(db_alias).filter(code="DEFAULT").delete()


class Migration(migrations.Migration):
    dependencies = [
        ("slack_messages", "0001_initial"),
    ]

    operations = [
        migrations.RunPython(
            code=_create_default_policy,
            reverse_code=_delete_default_policy,
        ),
    ]
