# Generated by Django 6.0.3 on 2026-03-17 18:03

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


def backfill_signal_slot_keys(apps, schema_editor):
    AutomatedUserSignal = apps.get_model('signals', 'AutomatedUserSignal')
    for signal in AutomatedUserSignal.objects.all().iterator():
        if signal.slot_key:
            continue
        signal.slot_key = f'daily-{signal.signal_date.isoformat()}'
        signal.save(update_fields=['slot_key'])


class Migration(migrations.Migration):

    dependencies = [
        ('signals', '0003_backfill_signal_plans_for_approved_deposits'),
        ('wallet', '0002_withdrawalrequest'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name='automatedusersignal',
            name='unique_plan_signal_per_day',
        ),
        migrations.AddField(
            model_name='automatedusersignal',
            name='slot_key',
            field=models.CharField(blank=True, default='', max_length=40),
        ),
        migrations.AddField(
            model_name='signalprogramsettings',
            name='test_interval_minutes',
            field=models.PositiveIntegerField(default=5),
        ),
        migrations.AddField(
            model_name='signalprogramsettings',
            name='test_mode_enabled',
            field=models.BooleanField(default=False),
        ),
        migrations.RunPython(backfill_signal_slot_keys, migrations.RunPython.noop),
        migrations.AddConstraint(
            model_name='automatedusersignal',
            constraint=models.UniqueConstraint(fields=('plan', 'slot_key'), name='unique_plan_signal_per_slot'),
        ),
    ]
