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


class Migration(migrations.Migration):

    dependencies = [
        ("shipment", "0016_shipmentdelivery_contact_phone_and_vehicle_capacity"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="SalesItemChangeRecord",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
                ("operated_at", models.DateTimeField(verbose_name="操作时间")),
                ("before_values", models.JSONField(blank=True, default=dict, verbose_name="修改前的值")),
                ("after_values", models.JSONField(blank=True, default=dict, verbose_name="修改目标值")),
                (
                    "operator",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="sales_item_change_records",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="操作者",
                    ),
                ),
                (
                    "sales_item",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="change_records",
                        to="shipment.salesitem",
                        verbose_name="销售品",
                    ),
                ),
            ],
            options={
                "verbose_name": "销售品修改记录",
                "verbose_name_plural": "销售品修改记录",
                "db_table": "sales_item_change_record",
                "ordering": ["-operated_at", "-id"],
            },
        ),
    ]
