# Generated by Django 5.2 on 2025-07-24 16:23

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


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0057_taskcredit_available_credits'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='UsageThresholdSent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('period_ym', models.CharField(help_text="Billing month in 'YYYYMM' format (e.g. '202507').", max_length=6)),
                ('threshold', models.PositiveSmallIntegerField(help_text='Integer percent of quota crossed (75, 90, 100).')),
                ('sent_at', models.DateTimeField(auto_now_add=True, help_text='Timestamp when we first emitted the threshold event.')),
                ('plan_limit', models.PositiveIntegerField(help_text='Task quota that applied at the time of the event (100 or 500).')),
                ('user', models.ForeignKey(help_text='User who crossed the threshold.', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'usage_threshold_sent',
                'ordering': ['-sent_at'],
                'constraints': [models.UniqueConstraint(fields=('user', 'period_ym', 'threshold'), name='unique_user_month_threshold')],
            },
        ),
    ]
