# Generated by Django 5.0 on 2026-02-22 00:20

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='MailEmail',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('account', models.CharField(choices=[('xserver', 'Xserver'), ('gmail', 'Gmail'), ('hotmail', 'Hotmail')], max_length=20, verbose_name='アカウント')),
                ('message_id', models.CharField(max_length=500, unique=True, verbose_name='Message-ID')),
                ('sender_email', models.EmailField(max_length=254, verbose_name='送信者アドレス')),
                ('sender_domain', models.CharField(max_length=255, verbose_name='送信者ドメイン')),
                ('subject', models.CharField(max_length=500, verbose_name='件名')),
                ('body_preview', models.TextField(verbose_name='本文冒頭')),
                ('received_at', models.DateTimeField(verbose_name='受信日時')),
                ('llm_verdict', models.CharField(choices=[('important', '重要'), ('not_important', '重要でない')], max_length=20, verbose_name='LLM判定')),
                ('notified_at', models.DateTimeField(blank=True, null=True, verbose_name='LINE通知日時')),
                ('feedback', models.CharField(blank=True, choices=[('important', '重要だった'), ('not_important', '普通のメール'), ('never_notify', '今後通知しない')], max_length=20, null=True, verbose_name='フィードバック')),
                ('feedback_at', models.DateTimeField(blank=True, null=True, verbose_name='フィードバック日時')),
            ],
            options={
                'verbose_name': '受信メール',
                'verbose_name_plural': '受信メール',
                'ordering': ['-received_at'],
            },
        ),
        migrations.CreateModel(
            name='MailSender',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name='メールアドレス')),
                ('domain', models.CharField(blank=True, max_length=255, null=True, verbose_name='ドメイン')),
                ('rule', models.CharField(choices=[('never_notify', '通知しない')], default='never_notify', max_length=20, verbose_name='ルール')),
                ('note', models.TextField(blank=True, verbose_name='メモ')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': '送信者ルール',
                'verbose_name_plural': '送信者ルール',
            },
        ),
        migrations.CreateModel(
            name='MailNotificationToken',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('token', models.UUIDField(default=uuid.uuid4, unique=True, verbose_name='トークン')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('email', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='notification_token', to='mail.mailemail', verbose_name='メール')),
            ],
            options={
                'verbose_name': '通知トークン',
                'verbose_name_plural': '通知トークン',
            },
        ),
        migrations.AddConstraint(
            model_name='mailsender',
            constraint=models.CheckConstraint(check=models.Q(models.Q(('domain__isnull', True), ('email__isnull', False)), models.Q(('domain__isnull', False), ('email__isnull', True)), _connector='OR'), name='mail_sender_email_or_domain'),
        ),
    ]
