# Generated by Django 6.0.1 on 2026-05-11 20:32

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='SocialAccount',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('platform_type', models.CharField(choices=[('LI', 'LinkedIn'), ('GO', 'Google'), ('META', 'Meta (Facebook/Instagram)'), ('TT', 'TikTok'), ('X', 'X/Twitter'), ('YT', 'YouTube')], max_length=4)),
                ('platform_id', models.CharField(help_text='Platform-specific account ID', max_length=255)),
                ('name', models.CharField(help_text='Account name or display name', max_length=255)),
                ('access_token', models.TextField(blank=True, null=True)),
                ('refresh_token', models.TextField(blank=True, null=True)),
                ('credentials_json', models.JSONField(blank=True, default=dict)),
                ('expires_at', models.DateTimeField(blank=True, null=True)),
                ('is_permanent', models.BooleanField(default=False)),
                ('is_active', models.BooleanField(default=True)),
                ('last_synced_at', models.DateTimeField(blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='social_accounts', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
                'unique_together': {('platform_type', 'platform_id')},
            },
        ),
        migrations.CreateModel(
            name='SocialContent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('platform_type', models.CharField(max_length=4)),
                ('source_platform', models.CharField(blank=True, help_text='Actual source platform for Meta (FB/IG)', max_length=4, null=True)),
                ('content_id', models.CharField(help_text='Platform-specific content ID', max_length=255, unique=True)),
                ('title', models.CharField(blank=True, help_text='For videos/titles', max_length=255)),
                ('text', models.TextField(blank=True, help_text='For posts/tweets')),
                ('last_comment_sync_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('is_syncing', models.BooleanField(default=False, help_text='Is full sync in progress?')),
                ('content_data', models.JSONField(default=dict)),
                ('created_at', models.DateTimeField(help_text='Actual content creation time')),
                ('added_at', models.DateTimeField(auto_now_add=True)),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contents', to='social.socialaccount')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SocialComment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('platform_type', models.CharField(max_length=4)),
                ('source_platform', models.CharField(blank=True, help_text='Actual source platform for Meta (FB/IG)', max_length=4, null=True)),
                ('comment_id', models.CharField(help_text='Platform-specific comment ID', max_length=255, unique=True)),
                ('author_name', models.CharField(max_length=255)),
                ('author_id', models.CharField(blank=True, max_length=255, null=True)),
                ('text', models.TextField()),
                ('comment_data', models.JSONField(default=dict)),
                ('like_count', models.IntegerField(default=0, help_text='Number of likes')),
                ('reply_count', models.IntegerField(default=0, help_text='Number of replies')),
                ('rating', models.IntegerField(blank=True, db_index=True, help_text='Star rating (1-5) for review platforms like Google Reviews', null=True)),
                ('media_url', models.URLField(blank=True, help_text='URL to associated media (images/videos)', max_length=500, null=True)),
                ('ai_analysis', models.JSONField(blank=True, default=dict, help_text='Complete AI analysis in bilingual format (en/ar) with sentiment, summaries, keywords, topics, entities, and emotions')),
                ('created_at', models.DateTimeField(db_index=True)),
                ('added_at', models.DateTimeField(auto_now_add=True)),
                ('synced_via_webhook', models.BooleanField(default=False)),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='social.socialaccount')),
                ('content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='social.socialcontent')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SocialReply',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('platform_type', models.CharField(max_length=4)),
                ('source_platform', models.CharField(blank=True, help_text='Actual source platform for Meta (FB/IG)', max_length=4, null=True)),
                ('reply_id', models.CharField(help_text='Platform-specific reply ID', max_length=255, unique=True)),
                ('author_name', models.CharField(max_length=255)),
                ('author_id', models.CharField(blank=True, max_length=255, null=True)),
                ('text', models.TextField()),
                ('reply_data', models.JSONField(default=dict)),
                ('created_at', models.DateTimeField(db_index=True)),
                ('added_at', models.DateTimeField(auto_now_add=True)),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='replies', to='social.socialaccount')),
                ('comment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='replies', to='social.socialcomment')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='socialcontent',
            index=models.Index(fields=['account', '-created_at'], name='social_soci_account_fa3cd8_idx'),
        ),
        migrations.AddIndex(
            model_name='socialcontent',
            index=models.Index(fields=['platform_type', '-created_at'], name='social_soci_platfor_939cb6_idx'),
        ),
        migrations.AddIndex(
            model_name='socialcomment',
            index=models.Index(fields=['account', '-created_at'], name='social_soci_account_e203a7_idx'),
        ),
        migrations.AddIndex(
            model_name='socialcomment',
            index=models.Index(fields=['content', '-created_at'], name='social_soci_content_4dc803_idx'),
        ),
        migrations.AddIndex(
            model_name='socialcomment',
            index=models.Index(fields=['platform_type', '-created_at'], name='social_soci_platfor_a04b00_idx'),
        ),
        migrations.AddIndex(
            model_name='socialreply',
            index=models.Index(fields=['comment', '-created_at'], name='social_soci_comment_1816f0_idx'),
        ),
        migrations.AddIndex(
            model_name='socialreply',
            index=models.Index(fields=['account', '-created_at'], name='social_soci_account_adbe60_idx'),
        ),
        migrations.AddIndex(
            model_name='socialreply',
            index=models.Index(fields=['platform_type', '-created_at'], name='social_soci_platfor_b71fb5_idx'),
        ),
    ]
