# 文章草稿功能 - 数据库迁移
# Generated manually for article draft auto-save feature

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 = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('blog', '0003_add_article_version'),
    ]

    operations = [
        migrations.CreateModel(
            name='ArticleDraft',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(blank=True, default='', max_length=200, verbose_name='title')),
                ('body', models.TextField(blank=True, default='', verbose_name='body')),
                ('category_id', models.IntegerField(blank=True, null=True, verbose_name='category id')),
                ('tags_data', models.JSONField(blank=True, default=list, verbose_name='tags data')),
                ('status', models.CharField(default='d', max_length=1, verbose_name='status')),
                ('comment_status', models.CharField(default='o', max_length=1, verbose_name='comment status')),
                ('type', models.CharField(default='a', max_length=1, verbose_name='type')),
                ('creation_time', models.DateTimeField(db_index=True, default=django.utils.timezone.now, verbose_name='creation time')),
                ('last_update_time', models.DateTimeField(auto_now=True, db_index=True, verbose_name='last update time')),
                ('session_id', models.CharField(blank=True, default='', max_length=64, verbose_name='session id')),
                ('is_published', models.BooleanField(default=False, verbose_name='is published')),
                ('article', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='drafts', to='blog.Article', verbose_name='article')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='article_drafts', to=settings.AUTH_USER_MODEL, verbose_name='author')),
            ],
            options={
                'verbose_name': 'article draft',
                'verbose_name_plural': 'article drafts',
                'ordering': ['-last_update_time'],
            },
        ),
        migrations.AddIndex(
            model_name='articledraft',
            index=models.Index(fields=['author', '-last_update_time'], name='draft_author_time_idx'),
        ),
        migrations.AddIndex(
            model_name='articledraft',
            index=models.Index(fields=['article', '-last_update_time'], name='draft_article_time_idx'),
        ),
        migrations.AddIndex(
            model_name='articledraft',
            index=models.Index(fields=['is_published', '-last_update_time'], name='draft_published_time_idx'),
        ),
    ]
