# Generated by Django 5.2.8 on 2026-04-10 07:06

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('basic_info', '0025_customer_uniq_customer_merchant_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='Notifier',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=100, verbose_name='通知器名称')),
                ('event_key', models.CharField(choices=[('mission.created', '任务已创建'), ('mission.replied', '任务有新回应'), ('mission.completed', '任务已完成'), ('mission.reply_rejected', '任务回应已撤销'), ('mission.reopened', '任务已重新打开'), ('mission.cancelled', '任务已取消')], db_index=True, max_length=100, verbose_name='事件标识')),
                ('channel', models.CharField(choices=[('wecom_webhook', '企业微信机器人')], default='wecom_webhook', max_length=50, verbose_name='通知渠道')),
                ('template_key', models.CharField(max_length=100, verbose_name='模板标识')),
                ('is_enabled', models.BooleanField(db_index=True, default=True, verbose_name='是否启用')),
                ('config', models.JSONField(blank=True, default=dict, verbose_name='渠道配置')),
                ('description', models.TextField(blank=True, null=True, verbose_name='备注描述')),
                ('merchant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='notifiers', to='basic_info.merchant', verbose_name='所属商户')),
            ],
            options={
                'verbose_name': '通知器',
                'verbose_name_plural': '通知器',
                'indexes': [models.Index(fields=['merchant', 'event_key', 'is_enabled'], name='notifier_no_merchan_c59a7a_idx')],
                'constraints': [models.UniqueConstraint(fields=('merchant', 'name'), name='unique_notifier_name_per_merchant')],
            },
        ),
    ]
