# Generated by Django 5.2.8 on 2025-11-24 11:50

import django.db.models.deletion
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='InfluencerProfile',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('instagram_handle', models.CharField(db_index=True, help_text='Instagram username/handle', max_length=100, unique=True)),
                ('access_token', models.TextField(blank=True, help_text='Encrypted Instagram access token (long-lived)', null=True)),
                ('instagram_business_id', models.CharField(blank=True, help_text='Instagram Business Account ID', max_length=100, null=True)),
                ('verification_status', models.BooleanField(default=False, help_text='Whether the influencer has completed Instagram verification')),
                ('followers_count', models.IntegerField(default=0, help_text='Total number of followers')),
                ('media_count', models.IntegerField(default=0, help_text='Total number of media posts')),
                ('ave_impressions', models.FloatField(default=0.0, help_text='Average impressions across all posts')),
                ('ave_reach', models.FloatField(default=0.0, help_text='Average reach across all posts')),
                ('ave_engagement', models.FloatField(default=0.0, help_text='Average engagement (likes + comments + shares) across all posts')),
                ('ave_saves', models.FloatField(default=0.0, help_text='Average saves across all posts')),
                ('ave_video_views', models.FloatField(blank=True, default=0.0, help_text='Average video views (only for video posts)', null=True)),
                ('engagement_rate_percent', models.FloatField(default=0.0, help_text='Engagement rate: (Total Engagements / Total Followers) * 100')),
                ('follower_growth', models.IntegerField(default=0, help_text='Follower growth over the last 30 days (absolute number)')),
                ('follower_growth_rate_percent', models.FloatField(default=0.0, help_text='Follower growth rate: (Growth / Previous Followers) * 100')),
                ('profile_views', models.IntegerField(default=0, help_text='Total profile views over the last 30 days')),
                ('female_audience_percentage', models.FloatField(default=0.0, help_text='Percentage of audience that is female')),
                ('male_audience_percentage', models.FloatField(default=0.0, help_text='Percentage of audience that is male')),
                ('audience_summary_string', models.TextField(blank=True, help_text='Human-readable audience summary (top cities and countries)', null=True)),
                ('ai_generated_niche', models.CharField(blank=True, db_index=True, help_text="AI-predicted niche (e.g., 'fashion', 'fitness', 'food')", max_length=100, null=True)),
                ('last_data_fetch', models.DateTimeField(blank=True, help_text='Timestamp of last successful data fetch from Instagram API', null=True)),
                ('data_processing_status', models.CharField(choices=[('PENDING', 'Pending'), ('PROCESSING', 'Processing'), ('COMPLETED', 'Completed'), ('FAILED', 'Failed')], default='PENDING', help_text='Status of background data processing task', max_length=20)),
                ('error_message', models.TextField(blank=True, help_text='Error message if data processing failed', null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('user', models.OneToOneField(help_text='Associated user account', on_delete=django.db.models.deletion.CASCADE, related_name='influencer_profile', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Influencer Profile',
                'verbose_name_plural': 'Influencer Profiles',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='MediaPost',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('media_id', models.CharField(db_index=True, help_text='Instagram media ID', max_length=100, unique=True)),
                ('media_type', models.CharField(choices=[('IMAGE', 'Image'), ('VIDEO', 'Video'), ('CAROUSEL_ALBUM', 'Carousel')], default='IMAGE', help_text='Type of media post', max_length=20)),
                ('caption', models.TextField(blank=True, help_text='Post caption text (used for AI niche prediction)', null=True)),
                ('timestamp', models.DateTimeField(blank=True, help_text='When the post was published on Instagram', null=True)),
                ('impressions', models.IntegerField(default=0, help_text='Number of times the post was viewed')),
                ('reach', models.IntegerField(default=0, help_text='Number of unique accounts that saw the post')),
                ('engagement', models.IntegerField(default=0, help_text='Total engagement (likes + comments + shares)')),
                ('saved', models.IntegerField(default=0, help_text='Number of times the post was saved')),
                ('video_views', models.IntegerField(blank=True, help_text='Number of video views (only applicable for video posts)', null=True)),
                ('fetched_at', models.DateTimeField(auto_now_add=True, help_text='When this data was fetched from Instagram API')),
                ('influencer', models.ForeignKey(help_text='Associated influencer profile', on_delete=django.db.models.deletion.CASCADE, related_name='media_posts', to='influencers.influencerprofile')),
            ],
            options={
                'verbose_name': 'Media Post',
                'verbose_name_plural': 'Media Posts',
                'ordering': ['-timestamp'],
                'indexes': [models.Index(fields=['influencer', '-timestamp'], name='influencers_influen_fc88cb_idx')],
            },
        ),
    ]
