# Generated by Django 3.2.25 on 2026-10-13 14:48

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='BlogCategory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True)),
                ('slug', models.SlugField(max_length=120, unique=True)),
                ('description', models.CharField(blank=True, max_length=250)),
            ],
            options={
                'verbose_name_plural': 'Blog categories',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='BlogPost',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('slug', models.SlugField(max_length=220, unique=True)),
                ('excerpt', models.TextField(help_text='Short summary displayed on article cards.', max_length=350)),
                ('content', models.TextField(help_text='Article body. Rich-text editing can be added separately.')),
                ('cover_image', models.ImageField(blank=True, null=True, upload_to='blog/covers/')),
                ('cover_image_alt', models.CharField(blank=True, max_length=200)),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('published', 'Published')], db_index=True, default='draft', max_length=10)),
                ('is_featured', models.BooleanField(default=False)),
                ('meta_title', models.CharField(blank=True, max_length=70)),
                ('meta_description', models.CharField(blank=True, max_length=160)),
                ('published_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('author', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.PROTECT, related_name='blog_posts', to=settings.AUTH_USER_MODEL)),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='posts', to='blog.blogcategory')),
            ],
            options={
                'ordering': ['-published_at', '-created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='blogpost',
            index=models.Index(fields=['status', 'published_at'], name='blog_status_pub_idx'),
        ),
        migrations.AddIndex(
            model_name='blogpost',
            index=models.Index(fields=['category', 'status'], name='blog_cat_status_idx'),
        ),
    ]
