# 文章版本管理功能 - 数据库迁移
# Generated manually for article version management 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', '0002_add_performance_indexes'),
    ]

    operations = [
        migrations.CreateModel(
            name='ArticleVersion',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('version_number', models.PositiveIntegerField(default=1, verbose_name='version number')),
                ('title', models.CharField(max_length=200, verbose_name='title')),
                ('body', models.TextField(verbose_name='body')),
                ('pub_time', models.DateTimeField(verbose_name='publish time')),
                ('status', models.CharField(max_length=1, verbose_name='status')),
                ('comment_status', models.CharField(max_length=1, verbose_name='comment status')),
                ('type', models.CharField(max_length=1, verbose_name='type')),
                ('category_id', models.IntegerField(verbose_name='category id')),
                ('category_name', models.CharField(max_length=30, verbose_name='category name')),
                ('creation_time', models.DateTimeField(db_index=True, default=django.utils.timezone.now, verbose_name='creation time')),
                ('change_summary', models.CharField(blank=True, default='', max_length=200, verbose_name='change summary')),
                ('is_auto_save', models.BooleanField(default=True, verbose_name='is auto save')),
                ('article', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='blog.Article', verbose_name='article')),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='article_versions_created', to=settings.AUTH_USER_MODEL, verbose_name='created by')),
            ],
            options={
                'verbose_name': 'article version',
                'verbose_name_plural': 'article versions',
                'ordering': ['-version_number'],
            },
        ),
        migrations.AddIndex(
            model_name='articleversion',
            index=models.Index(fields=['article', '-version_number'], name='version_article_num_idx'),
        ),
        migrations.AddIndex(
            model_name='articleversion',
            index=models.Index(fields=['creation_time'], name='version_creation_time_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='articleversion',
            unique_together={('article', 'version_number')},
        ),
    ]
