From 6c664d912bc05085ad87b2715637b9348963e5ee Mon Sep 17 00:00:00 2001 From: Therainclouds <245141853@qq.com> Date: Thu, 12 Feb 2026 22:34:13 +0800 Subject: [PATCH] new --- backend/db.sqlite3 | 0 .../shop/migrations/0029_fix_legacy_fields.py | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+) delete mode 100644 backend/db.sqlite3 create mode 100644 backend/shop/migrations/0029_fix_legacy_fields.py diff --git a/backend/db.sqlite3 b/backend/db.sqlite3 deleted file mode 100644 index e69de29..0000000 diff --git a/backend/shop/migrations/0029_fix_legacy_fields.py b/backend/shop/migrations/0029_fix_legacy_fields.py new file mode 100644 index 0000000..85c1d23 --- /dev/null +++ b/backend/shop/migrations/0029_fix_legacy_fields.py @@ -0,0 +1,23 @@ +# Generated by Django 6.0.1 on 2026-02-12 14:33 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0028_fix_goodsid_schema'), + ] + + operations = [ + # 1. 将 product_name 字段改为可为空 + migrations.RunSQL( + sql="ALTER TABLE shop_order ALTER COLUMN product_name DROP NOT NULL;", + reverse_sql="ALTER TABLE shop_order ALTER COLUMN product_name SET NOT NULL;" + ), + # 2. 将 unit_price 字段改为可为空 + migrations.RunSQL( + sql="ALTER TABLE shop_order ALTER COLUMN unit_price DROP NOT NULL;", + reverse_sql="ALTER TABLE shop_order ALTER COLUMN unit_price SET NOT NULL;" + ), + ]