# Generated by Django 5.2.8 on 2025-12-12 11:26

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


class Migration(migrations.Migration):

    dependencies = [
        ('billing', '0013_add_webhook_config'),
        ('igny8_core_auth', '0013_plan_max_clusters_plan_max_content_ideas_and_more'),
    ]

    operations = [
        migrations.CreateModel(
            name='PlanLimitUsage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('limit_type', models.CharField(choices=[('content_ideas', 'Content Ideas'), ('content_words', 'Content Words'), ('images_basic', 'Basic Images'), ('images_premium', 'Premium Images'), ('image_prompts', 'Image Prompts')], db_index=True, help_text='Type of limit being tracked', max_length=50)),
                ('amount_used', models.IntegerField(default=0, help_text='Amount used in current period', validators=[django.core.validators.MinValueValidator(0)])),
                ('period_start', models.DateField(help_text='Start date of billing period')),
                ('period_end', models.DateField(help_text='End date of billing period')),
                ('metadata', models.JSONField(blank=True, default=dict, help_text='Additional tracking data (e.g., breakdown by site)')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
            ],
            options={
                'verbose_name': 'Plan Limit Usage',
                'verbose_name_plural': 'Plan Limit Usage Records',
                'db_table': 'igny8_plan_limit_usage',
                'ordering': ['-period_start', 'limit_type'],
                'indexes': [models.Index(fields=['account', 'limit_type'], name='igny8_plan__tenant__993f7b_idx'), models.Index(fields=['account', 'period_start', 'period_end'], name='igny8_plan__tenant__aba01f_idx'), models.Index(fields=['limit_type', 'period_start'], name='igny8_plan__limit_t_d0f5ef_idx')],
                'unique_together': {('account', 'limit_type', 'period_start')},
            },
        ),
    ]
