# Generated by Django 6.0.3 on 2026-03-17 12:49

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


def seed_signal_program_settings(apps, schema_editor):
    SignalProgramSettings = apps.get_model('signals', 'SignalProgramSettings')
    if not SignalProgramSettings.objects.exists():
        SignalProgramSettings.objects.create()


def unseed_signal_program_settings(apps, schema_editor):
    SignalProgramSettings = apps.get_model('signals', 'SignalProgramSettings')
    SignalProgramSettings.objects.all().delete()


class Migration(migrations.Migration):

    dependencies = [
        ('deposits', '0001_initial'),
        ('signals', '0001_initial'),
        ('wallet', '0002_withdrawalrequest'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='SignalProgramSettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_enabled', models.BooleanField(default=True)),
                ('target_multiplier', models.DecimalField(decimal_places=2, default=2.0, max_digits=5)),
                ('completion_days', models.PositiveIntegerField(default=35)),
                ('daily_signal_time', models.TimeField(default=datetime.time(19, 0))),
                ('signal_expiry_minutes', models.PositiveIntegerField(default=10)),
                ('default_signal_type', models.CharField(choices=[('BUY', 'Buy'), ('SELL', 'Sell')], default='BUY', max_length=10)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('default_coin', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='signal_program_settings', to='signals.coin')),
            ],
            options={
                'verbose_name': 'Signal Program Setting',
                'verbose_name_plural': 'Signal Program Settings',
            },
        ),
        migrations.CreateModel(
            name='UserSignalPlan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('principal_amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('target_multiplier', models.DecimalField(decimal_places=2, default=2.0, max_digits=5)),
                ('target_amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('target_profit_amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('credited_profit_amount', models.DecimalField(decimal_places=2, default=0.0, max_digits=15)),
                ('daily_profit_amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('completion_days', models.PositiveIntegerField(default=35)),
                ('accepted_days', models.PositiveIntegerField(default=0)),
                ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('COMPLETED', 'Completed'), ('CANCELLED', 'Cancelled')], default='ACTIVE', max_length=20)),
                ('started_at', models.DateTimeField()),
                ('completed_at', models.DateTimeField(blank=True, null=True)),
                ('cancelled_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('deposit', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='signal_plan', to='deposits.deposit')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='signal_plans', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'User Signal Plan',
                'verbose_name_plural': 'User Signal Plans',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='AutomatedUserSignal',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('signal_type', models.CharField(choices=[('BUY', 'Buy'), ('SELL', 'Sell')], default='BUY', max_length=10)),
                ('signal_date', models.DateField()),
                ('day_number', models.PositiveIntegerField(default=1)),
                ('scheduled_for', models.DateTimeField()),
                ('expires_at', models.DateTimeField()),
                ('accepted_at', models.DateTimeField(blank=True, null=True)),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('ACCEPTED', 'Accepted'), ('EXPIRED', 'Expired'), ('CANCELLED', 'Cancelled')], default='PENDING', max_length=20)),
                ('profit_amount', models.DecimalField(decimal_places=2, max_digits=15)),
                ('entry_price', models.DecimalField(decimal_places=8, default=0, max_digits=20)),
                ('target_price', models.DecimalField(decimal_places=8, default=0, max_digits=20)),
                ('stop_loss', models.DecimalField(decimal_places=8, default=0, max_digits=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('coin', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='automated_signals', to='signals.coin')),
                ('transaction', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='automated_signal', to='wallet.transaction')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='automated_signals', to=settings.AUTH_USER_MODEL)),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='daily_signals', to='signals.usersignalplan')),
            ],
            options={
                'verbose_name': 'Automated User Signal',
                'verbose_name_plural': 'Automated User Signals',
                'ordering': ['-scheduled_for', '-created_at'],
                'constraints': [models.UniqueConstraint(fields=('plan', 'signal_date'), name='unique_plan_signal_per_day')],
            },
        ),
        migrations.RunPython(seed_signal_program_settings, unseed_signal_program_settings),
    ]
