# Generated by Django 5.2.8 on 2025-11-21 17:48

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


class Migration(migrations.Migration):

    dependencies = [
        ('igny8_core_auth', '0002_add_wp_api_key_to_site'),
        ('planner', '0002_initial'),
        ('writer', '0001_initial'),
    ]

    operations = [
        migrations.RemoveField(
            model_name='contentattributemap',
            name='account',
        ),
        migrations.RemoveField(
            model_name='contentattributemap',
            name='content',
        ),
        migrations.RemoveField(
            model_name='contentattributemap',
            name='sector',
        ),
        migrations.RemoveField(
            model_name='contentattributemap',
            name='site',
        ),
        migrations.RemoveField(
            model_name='contentattributemap',
            name='task',
        ),
        migrations.AddField(
            model_name='content',
            name='cluster',
            field=models.ForeignKey(blank=True, help_text='Primary semantic cluster', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='contents', to='planner.clusters'),
        ),
        migrations.AddField(
            model_name='content',
            name='cluster_role',
            field=models.CharField(blank=True, choices=[('hub', 'Hub Page'), ('supporting', 'Supporting Content'), ('attribute', 'Attribute Page')], db_index=True, default='supporting', help_text='Role within cluster strategy', max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='content',
            name='content_format',
            field=models.CharField(blank=True, choices=[('article', 'Article'), ('listicle', 'Listicle'), ('guide', 'How-To Guide'), ('comparison', 'Comparison'), ('review', 'Review'), ('roundup', 'Roundup')], db_index=True, help_text='Content format (only for entity_type=post)', max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='content',
            name='external_type',
            field=models.CharField(blank=True, help_text='WordPress post type (post, page, product, service)', max_length=100),
        ),
        migrations.AlterField(
            model_name='content',
            name='entity_type',
            field=models.CharField(choices=[('post', 'Blog Post'), ('page', 'Page'), ('product', 'Product'), ('service', 'Service Page'), ('taxonomy_term', 'Taxonomy Term Page'), ('blog_post', 'Blog Post (Legacy)'), ('article', 'Article (Legacy)'), ('taxonomy', 'Taxonomy Page (Legacy)')], db_index=True, default='post', help_text='Type of content entity', max_length=50),
        ),
        migrations.CreateModel(
            name='ContentAttribute',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('attribute_type', models.CharField(choices=[('product_spec', 'Product Specification'), ('service_modifier', 'Service Modifier'), ('semantic_facet', 'Semantic Facet')], db_index=True, default='product_spec', help_text='Type of attribute', max_length=50)),
                ('name', models.CharField(help_text='Attribute name (e.g., Color, Material)', max_length=120)),
                ('value', models.CharField(blank=True, help_text='Attribute value (e.g., Blue, Cotton)', max_length=255, null=True)),
                ('external_id', models.IntegerField(blank=True, help_text='WP attribute term ID', null=True)),
                ('external_attribute_name', models.CharField(blank=True, help_text='WP attribute slug (e.g., pa_color, pa_size)', max_length=100)),
                ('source', models.CharField(choices=[('blueprint', 'Blueprint'), ('manual', 'Manual'), ('import', 'Import'), ('wordpress', 'WordPress')], default='manual', max_length=50)),
                ('metadata', models.JSONField(blank=True, default=dict, help_text='Additional metadata')),
                ('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, help_text='Optional cluster association for semantic attributes', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='attributes', to='planner.clusters')),
                ('content', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attributes', 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={
                'verbose_name': 'Content Attribute',
                'verbose_name_plural': 'Content Attributes',
                'db_table': 'igny8_content_attributes',
            },
        ),
        migrations.CreateModel(
            name='ContentTaxonomy',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(db_index=True, help_text='Term name', max_length=255)),
                ('slug', models.SlugField(help_text='URL slug', max_length=255)),
                ('taxonomy_type', models.CharField(choices=[('category', 'Category'), ('tag', 'Tag'), ('product_cat', 'Product Category'), ('product_tag', 'Product Tag'), ('product_attr', 'Product Attribute'), ('service_cat', 'Service Category')], db_index=True, help_text='Type of taxonomy', max_length=50)),
                ('description', models.TextField(blank=True, help_text='Term description')),
                ('external_id', models.IntegerField(blank=True, db_index=True, help_text='WordPress term ID', null=True)),
                ('external_taxonomy', models.CharField(blank=True, help_text='WP taxonomy name (category, post_tag, product_cat, pa_color)', max_length=100)),
                ('sync_status', models.CharField(choices=[('native', 'Native IGNY8'), ('imported', 'Imported from External'), ('synced', 'Synced with External')], db_index=True, default='native', help_text='Sync status with external system', max_length=50)),
                ('count', models.IntegerField(default=0, help_text='Post/product count from WordPress')),
                ('metadata', models.JSONField(blank=True, default=dict, help_text='Additional metadata')),
                ('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')),
                ('clusters', models.ManyToManyField(blank=True, help_text='Semantic clusters this term maps to', related_name='taxonomy_terms', to='planner.clusters')),
                ('parent', models.ForeignKey(blank=True, help_text='Parent term for hierarchical taxonomies', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='writer.contenttaxonomy')),
                ('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 Taxonomy',
                'verbose_name_plural': 'Content Taxonomies',
                'db_table': 'igny8_content_taxonomy_terms',
            },
        ),
        migrations.CreateModel(
            name='ContentTaxonomyRelation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=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(on_delete=django.db.models.deletion.CASCADE, related_name='taxonomy_relations', 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_relations', to='writer.contenttaxonomy')),
            ],
            options={
                'db_table': 'igny8_content_taxonomy_relations',
            },
        ),
        migrations.AddField(
            model_name='content',
            name='taxonomies',
            field=models.ManyToManyField(blank=True, help_text='Associated taxonomy terms (categories, tags, attributes)', related_name='contents', through='writer.ContentTaxonomyRelation', to='writer.contenttaxonomy'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['content_format'], name='igny8_conte_content_b538ee_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['cluster_role'], name='igny8_conte_cluster_32e22a_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['cluster'], name='igny8_conte_cluster_e545d1_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['external_type'], name='igny8_conte_externa_a26125_idx'),
        ),
        migrations.AddIndex(
            model_name='content',
            index=models.Index(fields=['site', 'entity_type'], name='igny8_conte_site_id_e559d5_idx'),
        ),
        migrations.DeleteModel(
            name='ContentAttributeMap',
        ),
        migrations.AddIndex(
            model_name='contentattribute',
            index=models.Index(fields=['name'], name='igny8_conte_name_bacaae_idx'),
        ),
        migrations.AddIndex(
            model_name='contentattribute',
            index=models.Index(fields=['attribute_type'], name='igny8_conte_attribu_5d6f12_idx'),
        ),
        migrations.AddIndex(
            model_name='contentattribute',
            index=models.Index(fields=['content', 'name'], name='igny8_conte_content_6c7c68_idx'),
        ),
        migrations.AddIndex(
            model_name='contentattribute',
            index=models.Index(fields=['content', 'attribute_type'], name='igny8_conte_content_91df40_idx'),
        ),
        migrations.AddIndex(
            model_name='contentattribute',
            index=models.Index(fields=['cluster', 'attribute_type'], name='igny8_conte_cluster_1f91b7_idx'),
        ),
        migrations.AddIndex(
            model_name='contentattribute',
            index=models.Index(fields=['external_id'], name='igny8_conte_externa_0bf0e8_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomy',
            index=models.Index(fields=['name'], name='igny8_conte_name_f35eea_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomy',
            index=models.Index(fields=['slug'], name='igny8_conte_slug_65c0a2_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomy',
            index=models.Index(fields=['taxonomy_type'], name='igny8_conte_taxonom_04e1c2_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomy',
            index=models.Index(fields=['sync_status'], name='igny8_conte_sync_st_307b43_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomy',
            index=models.Index(fields=['external_id', 'external_taxonomy'], name='igny8_conte_externa_15861e_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomy',
            index=models.Index(fields=['site', 'taxonomy_type'], name='igny8_conte_site_id_6f84b7_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomy',
            index=models.Index(fields=['site', 'sector'], name='igny8_conte_site_id_9dddc7_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='contenttaxonomy',
            unique_together={('site', 'external_id', 'external_taxonomy'), ('site', 'slug', 'taxonomy_type')},
        ),
        migrations.AddIndex(
            model_name='contenttaxonomyrelation',
            index=models.Index(fields=['content'], name='igny8_conte_content_a897e5_idx'),
        ),
        migrations.AddIndex(
            model_name='contenttaxonomyrelation',
            index=models.Index(fields=['taxonomy'], name='igny8_conte_taxonom_7091e0_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='contenttaxonomyrelation',
            unique_together={('content', 'taxonomy')},
        ),
    ]
