# Generated by Django 5.2.8 on 2025-11-20 23:27

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('igny8_core_auth', '0001_initial'),
        ('planner', '0001_initial'),
        # ('site_building', '0001_initial'),  # REMOVED: SiteBuilder deprecated
    ]

    operations = [
        migrations.CreateModel(
            name='Content',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('html_content', models.TextField(help_text='Final AI-generated HTML content')),
                ('word_count', models.IntegerField(default=0, validators=[django.core.validators.MinValueValidator(0)])),
                ('metadata', models.JSONField(default=dict, help_text='Additional metadata (SEO, structure, etc.)')),
                ('title', models.CharField(blank=True, max_length=255, null=True)),
                ('meta_title', models.CharField(blank=True, max_length=255, null=True)),
                ('meta_description', models.TextField(blank=True, null=True)),
                ('primary_keyword', models.CharField(blank=True, max_length=255, null=True)),
                ('secondary_keywords', models.JSONField(blank=True, default=list, help_text='List of secondary keywords')),
                ('tags', models.JSONField(blank=True, default=list, help_text='List of tags')),
                ('categories', models.JSONField(blank=True, default=list, help_text='List of categories')),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('review', 'Review'), ('publish', 'Publish')], default='draft', help_text='Content workflow status (draft, review, publish)', max_length=50)),
                ('generated_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('source', models.CharField(choices=[('igny8', 'IGNY8 Generated'), ('wordpress', 'WordPress Synced'), ('shopify', 'Shopify Synced'), ('custom', 'Custom API Synced')], db_index=True, default='igny8', help_text='Source of the content', max_length=50)),
                ('sync_status', models.CharField(choices=[('native', 'Native IGNY8 Content'), ('imported', 'Imported from External'), ('synced', 'Synced from External')], db_index=True, default='native', help_text='Sync status of the content', max_length=50)),
                ('external_id', models.CharField(blank=True, help_text='External platform ID', max_length=255, null=True)),
                ('external_url', models.URLField(blank=True, help_text='External platform URL', null=True)),
                ('sync_metadata', models.JSONField(blank=True, default=dict, help_text='Platform-specific sync metadata')),
                ('internal_links', models.JSONField(blank=True, default=list, help_text='Internal links added by linker')),
                ('linker_version', models.IntegerField(default=0, help_text='Version of linker processing')),
                ('optimizer_version', models.IntegerField(default=0, help_text='Version of optimizer processing')),
                ('optimization_scores', models.JSONField(blank=True, default=dict, help_text='Optimization scores (SEO, readability, engagement)')),
                ('entity_type', models.CharField(choices=[('blog_post', 'Blog Post'), ('article', 'Article'), ('product', 'Product'), ('service', 'Service Page'), ('taxonomy', 'Taxonomy Page'), ('page', 'Page')], db_index=True, default='blog_post', help_text='Type of content entity', max_length=50)),
                ('json_blocks', models.JSONField(blank=True, default=list, help_text='Structured content blocks (for products, services, taxonomies)')),
                ('structure_data', models.JSONField(blank=True, default=dict, help_text='Content structure data (metadata, schema, etc.)')),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
                ('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
            ],
            options={
                'verbose_name': 'Content',
                'verbose_name_plural': 'Contents',
                'db_table': 'igny8_content',
                'ordering': ['-generated_at'],
            },
        ),
        migrations.CreateModel(
            name='Tasks',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(db_index=True, max_length=255)),
                ('description', models.TextField(blank=True, null=True)),
                ('keywords', models.CharField(blank=True, max_length=500)),
                ('content_structure', models.CharField(choices=[('cluster_hub', 'Cluster Hub'), ('landing_page', 'Landing Page'), ('pillar_page', 'Pillar Page'), ('supporting_page', 'Supporting Page')], default='blog_post', max_length=50)),
                ('content_type', models.CharField(choices=[('blog_post', 'Blog Post'), ('article', 'Article'), ('guide', 'Guide'), ('tutorial', 'Tutorial')], default='blog_post', max_length=50)),
                ('status', models.CharField(choices=[('queued', 'Queued'), ('completed', 'Completed')], default='queued', max_length=50)),
                ('entity_type', models.CharField(blank=True, choices=[('blog_post', 'Blog Post'), ('article', 'Article'), ('product', 'Product'), ('service', 'Service Page'), ('taxonomy', 'Taxonomy Page'), ('page', 'Page')], db_index=True, default='blog_post', help_text='Type of content entity (inherited from idea/blueprint)', max_length=50, null=True)),
                ('cluster_role', models.CharField(blank=True, choices=[('hub', 'Hub Page'), ('supporting', 'Supporting Page'), ('attribute', 'Attribute Page')], default='hub', help_text='Role within the cluster-driven sitemap', max_length=50, null=True)),
                ('content', models.TextField(blank=True, null=True)),
                ('word_count', models.IntegerField(default=0)),
                ('meta_title', models.CharField(blank=True, max_length=255, null=True)),
                ('meta_description', models.TextField(blank=True, null=True)),
                ('assigned_post_id', models.IntegerField(blank=True, null=True)),
                ('post_url', models.URLField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
                ('cluster', models.ForeignKey(blank=True, limit_choices_to={'sector': models.F('sector')}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tasks', to='planner.clusters')),
                ('idea', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tasks', to='planner.contentideas')),
                ('keyword_objects', models.ManyToManyField(blank=True, help_text='Individual keywords linked to this task', related_name='tasks', to='planner.keywords')),
                ('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
                ('taxonomy', models.ForeignKey(blank=True, help_text='Taxonomy association when derived from blueprint planning', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tasks', to='site_building.siteblueprinttaxonomy')),
            ],
            options={
                'verbose_name': 'Task',
                'verbose_name_plural': 'Tasks',
                'db_table': 'igny8_tasks',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Images',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('image_type', models.CharField(choices=[('featured', 'Featured Image'), ('desktop', 'Desktop Image'), ('mobile', 'Mobile Image'), ('in_article', 'In-Article Image')], default='featured', max_length=50)),
                ('image_url', models.CharField(blank=True, help_text='URL of the generated/stored image', max_length=500, null=True)),
                ('image_path', models.CharField(blank=True, help_text='Local path if stored locally', max_length=500, null=True)),
                ('prompt', models.TextField(blank=True, help_text='Image generation prompt used', null=True)),
                ('status', models.CharField(default='pending', help_text='Status: pending, generated, failed', max_length=50)),
                ('position', models.IntegerField(default=0, help_text='Position for in-article images ordering')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
                ('content', models.ForeignKey(blank=True, help_text='The content this image belongs to (preferred)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='images', to='writer.content')),
                ('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
                ('task', models.ForeignKey(blank=True, help_text='The task this image belongs to (legacy, use content instead)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='images', to='writer.tasks')),
            ],
            options={
                'verbose_name': 'Image',
                'verbose_name_plural': 'Images',
                'db_table': 'igny8_images',
                'ordering': ['content', 'position', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='ContentTaxonomyMap',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('source', models.CharField(choices=[('blueprint', 'Blueprint'), ('manual', 'Manual'), ('import', 'Import')], default='blueprint', max_length=50)),
                ('metadata', models.JSONField(blank=True, default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
                ('content', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='taxonomy_mappings', to='writer.content')),
                ('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
                ('taxonomy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='content_mappings', to='site_building.siteblueprinttaxonomy')),
                ('task', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='taxonomy_mappings', to='writer.tasks')),
            ],
            options={
                'db_table': 'igny8_content_taxonomy_map',
            },
        ),
        migrations.CreateModel(
            name='ContentClusterMap',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role', models.CharField(choices=[('hub', 'Hub Page'), ('supporting', 'Supporting Page'), ('attribute', 'Attribute Page')], default='hub', max_length=50)),
                ('source', models.CharField(choices=[('blueprint', 'Blueprint'), ('manual', 'Manual'), ('import', 'Import')], default='blueprint', max_length=50)),
                ('metadata', models.JSONField(blank=True, default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
                ('cluster', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='content_mappings', to='planner.clusters')),
                ('content', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='cluster_mappings', to='writer.content')),
                ('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
                ('task', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='cluster_mappings', to='writer.tasks')),
            ],
            options={
                'db_table': 'igny8_content_cluster_map',
            },
        ),
        migrations.CreateModel(
            name='ContentAttributeMap',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=120)),
                ('value', models.CharField(blank=True, max_length=255, null=True)),
                ('source', models.CharField(choices=[('blueprint', 'Blueprint'), ('manual', 'Manual'), ('import', 'Import')], default='blueprint', max_length=50)),
                ('metadata', models.JSONField(blank=True, default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
                ('content', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attribute_mappings', to='writer.content')),
                ('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
                ('task', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attribute_mappings', to='writer.tasks')),
            ],
            options={
                'db_table': 'igny8_content_attribute_map',
            },
        ),
        migrations.AddField(
            model_name='content',
            name='task',
            field=models.OneToOneField(blank=True, help_text='The task this content belongs to', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='content_record', to='writer.tasks'),
        ),
        migrations.AddIndex(
            model_name='tasks',
            index=models.Index(fields=['title'], name='igny8_tasks_title_adc50b_idx'),
        ),
        migrations.AddIndex(
            model_name='tasks',
            index=models.Index(fields=['status'], name='igny8_tasks_status_706869_idx'),
        ),
        migrations.AddIndex(
            model_name='tasks',
            index=models.Index(fields=['cluster'], name='igny8_tasks_cluster_ac6cd4_idx'),
        ),
        migrations.AddIndex(
            model_name='tasks',
            index=models.Index(fields=['content_type'], name='igny8_tasks_content_343539_idx'),
        ),
        migrations.AddIndex(
            model_name='tasks',
            index=models.Index(fields=['entity_type'], name='igny8_tasks_entity__1dc185_idx'),
        ),
        migrations.AddIndex(
            model_name='tasks',
            index=models.Index(fields=['cluster_role'], name='igny8_tasks_cluster_c87903_idx'),
        ),
        migrations.AddIndex(
            model_name='tasks',
            index=models.Index(fields=['site', 'sector'], name='igny8_tasks_site_id_9880f4_idx'),
        ),
        migrations.AddIndex(
            model_name='images',
            index=models.Index(fields=['content', 'image_type'], name='igny8_image_content_830ae4_idx'),
        ),
        migrations.AddIndex(
            model_name='images',
            index=models.Index(fields=['task', 'image_type'], name='igny8_image_task_id_c80e87_idx'),
        ),
        migrations.AddIndex(
            model_name='images',
            index=models.Index(fields=['status'], name='igny8_image_status_4a4de2_idx'),
        ),
        migrations.AddIndex(
            model_name='images',
            index=models.Index(fields=['content', 'position'], name='igny8_image_content_4ab256_idx'),
        ),
        migrations.AddIndex(
            model_name='images',
            index=models.Index(fields=['task', 'position'], name='igny8_image_task_id_6340e6_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomymap',
            index=models.Index(fields=['taxonomy'], name='igny8_conte_taxonom_c3da58_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomymap',
            index=models.Index(fields=['content', 'taxonomy'], name='igny8_conte_content_9dc417_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomymap',
            index=models.Index(fields=['task', 'taxonomy'], name='igny8_conte_task_id_e94754_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='contenttaxonomymap',
            unique_together={('content', 'taxonomy')},
        ),
        migrations.AddIndex(
            model_name='contentclustermap',
            index=models.Index(fields=['cluster', 'role'], name='igny8_conte_cluster_c12778_idx'),
        ),
        migrations.AddIndex(
            model_name='contentclustermap',
            index=models.Index(fields=['content', 'role'], name='igny8_conte_content_9fa5cc_idx'),
        ),
        migrations.AddIndex(
            model_name='contentclustermap',
            index=models.Index(fields=['task', 'role'], name='igny8_conte_task_id_821851_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='contentclustermap',
            unique_together={('content', 'cluster', 'role')},
        ),
        migrations.AddIndex(
            model_name='contentattributemap',
            index=models.Index(fields=['name'], name='igny8_conte_name_f79e3e_idx'),
        ),
        migrations.AddIndex(
            model_name='contentattributemap',
            index=models.Index(fields=['content', 'name'], name='igny8_conte_content_f255f2_idx'),
        ),
        migrations.AddIndex(
            model_name='contentattributemap',
            index=models.Index(fields=['task', 'name'], name='igny8_conte_task_id_d60684_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['task'], name='igny8_conte_task_id_712988_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['generated_at'], name='igny8_conte_generat_7128df_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['source'], name='igny8_conte_source_5ef8a1_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['sync_status'], name='igny8_conte_sync_st_02d5bd_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['source', 'sync_status'], name='igny8_conte_source_df78d0_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['entity_type'], name='igny8_conte_entity__f559b3_idx'),
        ),
    ]
