# Generated by Django 5.2.1 on 2025-12-23 08:47

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='AlertMetricDefinition',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(help_text="Unique identifier for this metric (e.g., 'max_price_diff_pct')", max_length=50, unique=True)),
                ('label', models.CharField(help_text="Human-readable label (e.g., 'Max Price Difference %')", max_length=100)),
                ('description', models.TextField(blank=True, help_text='Detailed description of what this metric measures')),
                ('default_operator', models.CharField(choices=[('gt', 'Greater Than (>)'), ('gte', 'Greater Than or Equal (≥)'), ('lt', 'Less Than (<)'), ('lte', 'Less Than or Equal (≤)'), ('eq', 'Equal (=)'), ('ne', 'Not Equal (≠)')], default='gte', help_text='Default comparison operator for this metric', max_length=10)),
                ('from_settings', models.BooleanField(default=False, help_text='True if this metric was synced from settings.py')),
                ('is_active', models.BooleanField(default=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('applicable_content_types', models.ManyToManyField(blank=True, help_text='Models that can use this metric. Leave empty for all models.', related_name='alert_metrics', to='contenttypes.contenttype')),
            ],
            options={
                'verbose_name': 'Alert Metric',
                'verbose_name_plural': 'Alert Metrics',
                'ordering': ['label'],
            },
        ),
        migrations.CreateModel(
            name='AlertThreshold',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField()),
                ('level', models.IntegerField(choices=[(1, 'Info'), (2, 'Warning'), (3, 'Critical'), (4, 'Emergency')], help_text='Alert severity level')),
                ('threshold_value', models.DecimalField(blank=True, decimal_places=8, help_text='Threshold value. Leave empty to disable this alert level.', max_digits=24, null=True)),
                ('operator', models.CharField(choices=[('gt', 'Greater Than (>)'), ('gte', 'Greater Than or Equal (≥)'), ('lt', 'Less Than (<)'), ('lte', 'Less Than or Equal (≤)'), ('eq', 'Equal (=)'), ('ne', 'Not Equal (≠)')], default='gte', help_text='Comparison operator for threshold check', max_length=10)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='alert_thresholds', to='contenttypes.contenttype')),
                ('metric', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='thresholds', to='alert_thresholds.alertmetricdefinition')),
            ],
            options={
                'verbose_name': 'Alert Threshold',
                'verbose_name_plural': 'Alert Thresholds',
                'ordering': ['metric', 'level'],
                'indexes': [models.Index(fields=['content_type', 'object_id'], name='alert_thres_content_38b6b0_idx'), models.Index(fields=['metric', 'level'], name='alert_thres_metric__06ea77_idx')],
                'unique_together': {('content_type', 'object_id', 'metric', 'level')},
            },
        ),
    ]
