# Generated by Django 4.2 on 2026-02-09 06:31

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="StoryShelf",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="书架名称")),
                (
                    "is_locked",
                    models.BooleanField(default=False, verbose_name="是否加锁"),
                ),
                (
                    "unlock_cost",
                    models.IntegerField(default=0, verbose_name="解锁积分"),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="创建时间"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="更新时间"),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="story_shelves",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="用户",
                    ),
                ),
            ],
            options={
                "verbose_name": "故事书架",
                "verbose_name_plural": "故事书架",
                "db_table": "story_shelf",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="Story",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=200, verbose_name="标题")),
                (
                    "content",
                    models.TextField(blank=True, default="", verbose_name="内容"),
                ),
                (
                    "cover_url",
                    models.URLField(
                        blank=True, default="", max_length=500, verbose_name="封面URL"
                    ),
                ),
                (
                    "has_video",
                    models.BooleanField(default=False, verbose_name="是否有视频"),
                ),
                (
                    "video_url",
                    models.URLField(
                        blank=True, default="", max_length=500, verbose_name="视频URL"
                    ),
                ),
                (
                    "generation_mode",
                    models.CharField(
                        choices=[("ai", "AI生成"), ("manual", "手动创建")],
                        default="ai",
                        max_length=20,
                        verbose_name="生成方式",
                    ),
                ),
                (
                    "prompt",
                    models.TextField(blank=True, default="", verbose_name="生成提示词"),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="创建时间"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="更新时间"),
                ),
                (
                    "shelf",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="stories",
                        to="stories.storyshelf",
                        verbose_name="所属书架",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="stories",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="用户",
                    ),
                ),
            ],
            options={
                "verbose_name": "故事",
                "verbose_name_plural": "故事",
                "db_table": "story",
                "ordering": ["-created_at"],
            },
        ),
        migrations.AddIndex(
            model_name="story",
            index=models.Index(
                fields=["user", "shelf"], name="story_user_id_7abea4_idx"
            ),
        ),
    ]
