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;" + ), + ]