# Generated by Django 5.2.1 on 2025-06-02 19:38

import django.contrib.postgres.indexes
import django.db.models.deletion
import parler.fields
import parler.models
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('user', '0014_alter_useraddress_options_and_more'),
    ]

    operations = [
        migrations.CreateModel(
            name='SubscriptionTopic',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('slug', models.SlugField(help_text="Unique identifier for the topic (e.g., 'weekly-newsletter')", unique=True, verbose_name='Slug')),
                ('category', models.CharField(choices=[('marketing', 'Marketing Campaigns'), ('product', 'Product Updates'), ('account', 'Account Updates'), ('system', 'System Notifications'), ('newsletter', 'Newsletter'), ('promotional', 'Promotional'), ('other', 'Other')], default='other', help_text='Category of the subscription topic', max_length=20, verbose_name='Category')),
                ('is_active', models.BooleanField(default=True, help_text='Whether this topic is currently available for subscription', verbose_name='Active')),
                ('is_default', models.BooleanField(default=False, help_text='Whether new users are automatically subscribed to this topic', verbose_name='Default Subscription')),
                ('requires_confirmation', models.BooleanField(default=False, help_text='Whether subscription to this topic requires email confirmation', verbose_name='Requires Confirmation')),
            ],
            options={
                'verbose_name': 'Subscription Topic',
                'verbose_name_plural': 'Subscription Topics',
                'ordering': ['-created_at'],
                'indexes': [django.contrib.postgres.indexes.BTreeIndex(fields=['created_at'], name='subscriptiontopic_created_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['updated_at'], name='subscriptiontopic_updated_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['slug'], name='sub_topic_slug_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['is_active'], name='sub_topic_active_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['category'], name='sub_topic_category_ix')],
            },
            bases=(parler.models.TranslatableModelMixin, models.Model),
        ),
        migrations.CreateModel(
            name='SubscriptionTopicTranslation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('language_code', models.CharField(db_index=True, max_length=15, verbose_name='Language')),
                ('name', models.CharField(help_text='Human-readable name for the topic', max_length=100, verbose_name='Name')),
                ('description', models.TextField(blank=True, help_text='Detailed description of what this subscription includes', verbose_name='Description')),
                ('master', parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='user.subscriptiontopic')),
            ],
            options={
                'verbose_name': 'Subscription Topic Translation',
                'db_table': 'user_subscriptiontopic_translation',
                'db_tablespace': '',
                'managed': True,
                'default_permissions': (),
                'unique_together': {('language_code', 'master')},
            },
            bases=(parler.models.TranslatedFieldsModelMixin, models.Model),
        ),
        migrations.CreateModel(
            name='UserSubscription',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('status', models.CharField(choices=[('active', 'Active'), ('pending', 'Pending Confirmation'), ('unsubscribed', 'Unsubscribed'), ('bounced', 'Bounced')], default='active', max_length=20, verbose_name='Status')),
                ('subscribed_at', models.DateTimeField(auto_now_add=True, verbose_name='Subscribed At')),
                ('unsubscribed_at', models.DateTimeField(blank=True, null=True, verbose_name='Unsubscribed At')),
                ('confirmation_token', models.CharField(blank=True, help_text='Token for email confirmation if required', max_length=64, verbose_name='Confirmation Token')),
                ('metadata', models.JSONField(blank=True, default=dict, help_text='Additional subscription preferences or data', verbose_name='Metadata')),
                ('topic', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscribers', to='user.subscriptiontopic', verbose_name='Topic')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to=settings.AUTH_USER_MODEL, verbose_name='User')),
            ],
            options={
                'verbose_name': 'User Subscription',
                'verbose_name_plural': 'User Subscriptions',
                'ordering': ['-created_at'],
                'indexes': [django.contrib.postgres.indexes.BTreeIndex(fields=['created_at'], name='usersubscription_created_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['updated_at'], name='usersubscription_updated_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['user', 'status'], name='user_sub_user_status_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['topic', 'status'], name='user_sub_topic_status_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['status'], name='user_sub_status_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['confirmation_token'], name='user_sub_token_ix')],
                'unique_together': {('user', 'topic')},
            },
        ),
    ]
