# Generated by Django 4.2 on 2026-02-12 02:53

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


class Migration(migrations.Migration):

    dependencies = [
        ("users", "0002_smscode_user_birthday_user_deletion_requested_at_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="PointsRecord",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("amount", models.IntegerField(verbose_name="变动数量")),
                (
                    "type",
                    models.CharField(
                        choices=[
                            ("unlock_shelf", "解锁书架"),
                            ("reward", "奖励"),
                            ("admin_adjust", "管理员调整"),
                        ],
                        max_length=30,
                        verbose_name="类型",
                    ),
                ),
                (
                    "description",
                    models.CharField(
                        blank=True, default="", max_length=200, verbose_name="描述"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="创建时间"),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="points_records",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="用户",
                    ),
                ),
            ],
            options={
                "verbose_name": "积分流水",
                "verbose_name_plural": "积分流水",
                "db_table": "points_record",
                "ordering": ["-created_at"],
            },
        ),
        migrations.AddIndex(
            model_name="pointsrecord",
            index=models.Index(
                fields=["user", "-created_at"], name="points_reco_user_id_b675f0_idx"
            ),
        ),
    ]
