# Generated by Django 6.0.4 on 2026-06-06 02:55

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('tools', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Campaign',
            fields=[
                ('id', models.UUIDField(default=apps.disseminations.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=180)),
                ('objective', models.CharField(blank=True, max_length=255)),
                ('description', models.TextField(blank=True)),
                ('color', models.CharField(default='#6b7280', max_length=7)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('end_date', models.DateField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dissemination_campaigns', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'dissemination_campaigns',
                'ordering': ['-start_date', 'name'],
            },
        ),
        migrations.CreateModel(
            name='Channel',
            fields=[
                ('id', models.UUIDField(default=apps.disseminations.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=120)),
                ('platform', models.CharField(choices=[('twitter', 'Twitter / X'), ('instagram', 'Instagram'), ('facebook', 'Facebook'), ('linkedin', 'LinkedIn'), ('tiktok', 'TikTok'), ('youtube', 'YouTube'), ('threads', 'Threads'), ('other', 'Other')], max_length=20)),
                ('handle', models.CharField(blank=True, help_text='@handle or page slug', max_length=120)),
                ('profile_url', models.URLField(blank=True)),
                ('avatar_url', models.URLField(blank=True)),
                ('active', models.BooleanField(default=True)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dissemination_channels', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'dissemination_channels',
                'ordering': ['platform', 'name'],
            },
        ),
        migrations.CreateModel(
            name='MediaAsset',
            fields=[
                ('id', models.UUIDField(default=apps.disseminations.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(blank=True, max_length=180)),
                ('kind', models.CharField(choices=[('image', 'Image'), ('video', 'Video'), ('document', 'Document'), ('other', 'Other')], default='image', max_length=20)),
                ('file', models.FileField(upload_to='disseminations/media/')),
                ('width', models.PositiveIntegerField(blank=True, null=True)),
                ('height', models.PositiveIntegerField(blank=True, null=True)),
                ('size_bytes', models.PositiveBigIntegerField(default=0)),
                ('tags', models.JSONField(blank=True, default=list)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('uploaded_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dissemination_media', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'dissemination_media_assets',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Post',
            fields=[
                ('id', models.UUIDField(default=apps.disseminations.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(blank=True, max_length=200)),
                ('body', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('scheduled', 'Scheduled'), ('publishing', 'Publishing'), ('published', 'Published'), ('failed', 'Failed'), ('archived', 'Archived')], db_index=True, default='draft', max_length=20)),
                ('scheduled_at', models.DateTimeField(blank=True, db_index=True, null=True)),
                ('published_at', models.DateTimeField(blank=True, db_index=True, null=True)),
                ('timezone_name', models.CharField(default='UTC', max_length=64)),
                ('tags', models.JSONField(blank=True, default=list)),
                ('link_url', models.URLField(blank=True)),
                ('metrics', models.JSONField(blank=True, default=dict, help_text='reach/likes/comments/shares per channel')),
                ('error_message', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dissemination_posts', to=settings.AUTH_USER_MODEL)),
                ('campaign', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='posts', to='disseminations.campaign')),
                ('channels', models.ManyToManyField(blank=True, related_name='posts', to='disseminations.channel')),
                ('media', models.ManyToManyField(blank=True, related_name='posts', to='disseminations.mediaasset')),
                ('tracking_url', models.ForeignKey(blank=True, help_text='Short link generated for link_url; used for click tracking.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dissemination_posts', to='tools.url')),
            ],
            options={
                'db_table': 'dissemination_posts',
                'ordering': ['-scheduled_at', '-created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='channel',
            index=models.Index(fields=['platform', 'active'], name='disseminati_platfor_80d1b2_idx'),
        ),
        migrations.AddIndex(
            model_name='post',
            index=models.Index(fields=['status', 'scheduled_at'], name='disseminati_status_7ec0a3_idx'),
        ),
        migrations.AddIndex(
            model_name='post',
            index=models.Index(fields=['campaign', 'status'], name='disseminati_campaig_9086d6_idx'),
        ),
    ]
