# Generated by Django 5.2.8 on 2025-11-07 10:06

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


class Migration(migrations.Migration):

    dependencies = [
        ('igny8_core_auth', '0008_passwordresettoken_alter_industry_options_and_more'),
        ('system', '0003_add_image_generation_integration_type'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='AISettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('integration_type', models.CharField(db_index=True, help_text="Integration type (e.g., 'openai', 'runware')", max_length=50)),
                ('config', models.JSONField(default=dict, help_text='Integration configuration (API keys, settings, etc.)')),
                ('model_preferences', models.JSONField(default=dict, help_text='Model preferences per operation type')),
                ('cost_limits', models.JSONField(default=dict, help_text='Cost limits and budgets')),
                ('is_active', models.BooleanField(default=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'igny8_ai_settings',
                'ordering': ['integration_type'],
            },
        ),
        migrations.CreateModel(
            name='ModuleSettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('config', models.JSONField(default=dict, help_text='Settings configuration as JSON')),
                ('is_active', models.BooleanField(default=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('module_name', models.CharField(db_index=True, help_text="Module name (e.g., 'planner', 'writer')", max_length=100)),
                ('key', models.CharField(db_index=True, help_text='Settings key identifier', max_length=255)),
            ],
            options={
                'db_table': 'igny8_module_settings',
                'ordering': ['module_name', 'key'],
            },
        ),
        migrations.CreateModel(
            name='SystemSettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(db_index=True, help_text='Settings key identifier', max_length=255, unique=True)),
                ('value', models.JSONField(default=dict, help_text='Settings value as JSON')),
                ('description', models.TextField(blank=True, help_text='Description of this setting')),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'igny8_system_settings',
                'ordering': ['key'],
            },
        ),
        migrations.CreateModel(
            name='TenantSettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('config', models.JSONField(default=dict, help_text='Settings configuration as JSON')),
                ('is_active', models.BooleanField(default=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('key', models.CharField(db_index=True, help_text='Settings key identifier', max_length=255)),
            ],
            options={
                'db_table': 'igny8_tenant_settings',
                'ordering': ['key'],
            },
        ),
        migrations.CreateModel(
            name='UserSettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(db_index=True, help_text='Settings key identifier', max_length=255)),
                ('value', models.JSONField(default=dict, help_text='Settings value as JSON')),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'igny8_user_settings',
                'ordering': ['key'],
            },
        ),
        migrations.RenameIndex(
            model_name='aiprompt',
            new_name='igny8_ai_pr_prompt__4b2dbe_idx',
            old_name='igny8_ai_pr_prompt__idx',
        ),
        migrations.RenameIndex(
            model_name='aiprompt',
            new_name='igny8_ai_pr_tenant__9e7b95_idx',
            old_name='igny8_ai_pr_tenant__idx',
        ),
        migrations.RenameIndex(
            model_name='integrationsettings',
            new_name='igny8_integ_integra_5e382e_idx',
            old_name='igny8_integ_integra_idx',
        ),
        migrations.RenameIndex(
            model_name='integrationsettings',
            new_name='igny8_integ_tenant__5da472_idx',
            old_name='igny8_integ_tenant__idx',
        ),
        migrations.AlterField(
            model_name='aiprompt',
            name='prompt_type',
            field=models.CharField(choices=[('clustering', 'Clustering'), ('ideas', 'Ideas Generation'), ('content_generation', 'Content Generation'), ('image_prompt_extraction', 'Image Prompt Extraction'), ('image_prompt_template', 'Image Prompt Template'), ('negative_prompt', 'Negative Prompt')], db_index=True, max_length=50),
        ),
        migrations.AddField(
            model_name='aisettings',
            name='tenant',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.tenant'),
        ),
        migrations.AddField(
            model_name='modulesettings',
            name='tenant',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.tenant'),
        ),
        migrations.AddIndex(
            model_name='systemsettings',
            index=models.Index(fields=['key'], name='igny8_syste_key_20500b_idx'),
        ),
        migrations.AddField(
            model_name='tenantsettings',
            name='tenant',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.tenant'),
        ),
        migrations.AddField(
            model_name='usersettings',
            name='tenant',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_settings', to='igny8_core_auth.tenant'),
        ),
        migrations.AddField(
            model_name='usersettings',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_settings', to=settings.AUTH_USER_MODEL),
        ),
        migrations.RunSQL(
            sql="DROP TABLE IF EXISTS igny8_system_logs CASCADE",
            reverse_sql=migrations.RunSQL.noop,
        ),
        migrations.RunSQL(
            sql="DROP TABLE IF EXISTS igny8_system_status CASCADE",
            reverse_sql=migrations.RunSQL.noop,
        ),
        migrations.AddIndex(
            model_name='aisettings',
            index=models.Index(fields=['integration_type'], name='igny8_ai_se_integra_4f0b21_idx'),
        ),
        migrations.AddIndex(
            model_name='aisettings',
            index=models.Index(fields=['tenant', 'integration_type'], name='igny8_ai_se_tenant__05ae98_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='aisettings',
            unique_together={('tenant', 'integration_type')},
        ),
        migrations.AddIndex(
            model_name='modulesettings',
            index=models.Index(fields=['tenant', 'module_name', 'key'], name='igny8_modul_tenant__21ee25_idx'),
        ),
        migrations.AddIndex(
            model_name='modulesettings',
            index=models.Index(fields=['module_name', 'key'], name='igny8_modul_module__95373a_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='modulesettings',
            unique_together={('tenant', 'module_name', 'key')},
        ),
        migrations.AddIndex(
            model_name='tenantsettings',
            index=models.Index(fields=['tenant', 'key'], name='igny8_tenan_tenant__8ce0b3_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='tenantsettings',
            unique_together={('tenant', 'key')},
        ),
        migrations.AddIndex(
            model_name='usersettings',
            index=models.Index(fields=['user', 'tenant', 'key'], name='igny8_user__user_id_ac09d9_idx'),
        ),
        migrations.AddIndex(
            model_name='usersettings',
            index=models.Index(fields=['tenant', 'key'], name='igny8_user__tenant__01033d_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='usersettings',
            unique_together={('user', 'tenant', 'key')},
        ),
    ]
