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


class Migration(migrations.Migration):
    dependencies = [
        ('core', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='LegalDocument',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('doc_type', models.CharField(choices=[('privacy', 'Privacy Policy'), ('terms', 'Terms & Conditions')], max_length=20)),
                ('version', models.CharField(max_length=20)),
                ('title', models.CharField(max_length=80)),
                ('effective_date', models.DateField(blank=True, null=True)),
                ('intro', models.TextField(blank=True, default='', max_length=400)),
                ('sections', models.JSONField(default=list)),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('published', 'Published')], default='draft', max_length=20)),
                ('change_note', models.CharField(blank=True, default='', max_length=240)),
                ('published_at', models.DateTimeField(blank=True, null=True)),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='legal_documents', to=settings.AUTH_USER_MODEL)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'core_legaldocument',
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='legaldocument',
            index=models.Index(fields=['doc_type', 'status'], name='core_legald_doc_typ_idx'),
        ),
    ]
