wip(freight): migration 0017 + model/column-list groundwork for add-freight-templates

This commit is contained in:
Chengdong Zhang
2026-09-23 17:39:45 +08:00
parent a83e857bdf
commit 5b426486ac
105 changed files with 6193 additions and 1566 deletions
@@ -1,3 +1,5 @@
> **Progress 2026-09-23:** migration `0017_freight_templates.sql` written (incl. `skus.weight_grams` for by-weight and `shipments.shipping_company_code`); models extended (`Order.shipping_fee_minor`, `OrderItem` freight snapshots, `Sku.weight_grams`, `FreightPricingMethod`); order/sku SQL column lists updated; `cargo test -p vmall-api` green. Not started: shared contract (1.2), freight module (1.3), calculation + checkout wiring (2.x), frontends (3.x/4.x), verification (5.x).
## 1. Migration and shared contract
- [ ] 1.1 Add migration `0017_freight_templates.sql`: `freight_templates` (shop FK, name, default flag with a partial unique index per shop, always-free toggle, `by_piece`/`by_weight` pricing method, first/additional unit fees as i64 minor units, integer first/additional unit sizes in pieces or grams, optional free-shipping threshold in i64 minor units), `freight_region_rules` (template FK, region code set, overriding fees and unit sizes), `shipping_companies` (code, `{en, zh}` JSONB name), `orders.shipping_fee_minor`, `order_items` pricing-method and template-id snapshot columns, and `shipments.shipping_company_code`, with shop/template indexes and cascading deletes.