# Generated migration for automation models

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('igny8_core_auth', '0004_add_invoice_payment_models'),
    ]

    operations = [
        migrations.CreateModel(
            name='AutomationConfig',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_enabled', models.BooleanField(default=False, help_text='Enable/disable automation for this site')),
                ('frequency', models.CharField(
                    choices=[('daily', 'Daily'), ('weekly', 'Weekly'), ('monthly', 'Monthly')],
                    default='daily',
                    max_length=20
                )),
                ('scheduled_time', models.TimeField(default='02:00', help_text='Time of day to run automation (HH:MM)')),
                ('stage_1_batch_size', models.IntegerField(default=20, help_text='Keywords → Clusters batch size')),
                ('stage_2_batch_size', models.IntegerField(default=1, help_text='Clusters → Ideas batch size')),
                ('stage_3_batch_size', models.IntegerField(default=20, help_text='Ideas → Tasks batch size')),
                ('stage_4_batch_size', models.IntegerField(default=1, help_text='Tasks → Content batch size')),
                ('stage_5_batch_size', models.IntegerField(default=1, help_text='Content → Image Prompts batch size')),
                ('stage_6_batch_size', models.IntegerField(default=1, help_text='Image Prompts → Images batch size')),
                ('last_run_at', models.DateTimeField(blank=True, null=True)),
                ('next_run_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='igny8_core_auth.account')),
                ('site', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='automation_config', to='igny8_core_auth.site')),
            ],
            options={
                'db_table': 'igny8_automation_configs',
            },
        ),
        migrations.CreateModel(
            name='AutomationRun',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('run_id', models.CharField(max_length=100, unique=True)),
                ('trigger_type', models.CharField(
                    choices=[('manual', 'Manual'), ('scheduled', 'Scheduled')],
                    default='manual',
                    max_length=20
                )),
                ('status', models.CharField(
                    choices=[
                        ('running', 'Running'),
                        ('paused', 'Paused'),
                        ('completed', 'Completed'),
                        ('failed', 'Failed')
                    ],
                    default='running',
                    max_length=20
                )),
                ('current_stage', models.IntegerField(default=1, help_text='Current stage (1-7)')),
                ('stage_1_result', models.JSONField(blank=True, null=True)),
                ('stage_2_result', models.JSONField(blank=True, null=True)),
                ('stage_3_result', models.JSONField(blank=True, null=True)),
                ('stage_4_result', models.JSONField(blank=True, null=True)),
                ('stage_5_result', models.JSONField(blank=True, null=True)),
                ('stage_6_result', models.JSONField(blank=True, null=True)),
                ('stage_7_result', models.JSONField(blank=True, null=True)),
                ('total_credits_used', models.IntegerField(default=0)),
                ('error_message', models.TextField(blank=True, null=True)),
                ('started_at', models.DateTimeField(auto_now_add=True)),
                ('completed_at', models.DateTimeField(blank=True, null=True)),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='igny8_core_auth.account')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='automation_runs', to='igny8_core_auth.site')),
            ],
            options={
                'db_table': 'igny8_automation_runs',
                'ordering': ['-started_at'],
                'indexes': [
                    models.Index(fields=['site', 'status'], name='automation_site_status_idx'),
                    models.Index(fields=['site', 'started_at'], name='automation_site_started_idx'),
                ],
            },
        ),
    ]
