916bdd9c7c
- 新增 category.archive_kind 与 kind_field 字段模板表(迁移 0010) - 种子 electronics 字段模板 + 3C 品类树(手机/笔记本/平板等) - 后端按档案模式动态计算完整度/合格:食品沿用 food_detail, 其它模式走 product.attributes + kind_field - 新增 GET /api/kind-fields?kind= 接口 - 后台编辑页按品类模式动态渲染规格参数表单 - 公开详情页/接口输出带标签的规格表 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Database migrations (golang-migrate)
SQL migrations for the OpenGoods database, applied with
golang-migrate.
Naming: NNNN_description.up.sql / NNNN_description.down.sql.
Files
| Version | Up | 内容 |
|---|---|---|
| 0001 | 0001_init |
扩展(pgcrypto/pg_trgm/ltree) + 全部核心表 + 索引 + tsvector 触发器 |
| 0002 | 0002_seed_units |
单位字典(与 ingestion/opengoods/units.py 一致)+ 常用营养参数定义 |
| 0003 | 0003_seed_categories |
食品品类骨架(GS1 GPC 映射 + 自建中文树)+ 品类参数模板 |
运行
先起本地依赖:docker compose up -d postgres
export DBURL="postgres://opengoods:opengoods@localhost:5432/opengoods?sslmode=disable"
migrate -path migrations -database "$DBURL" up # 升级到最新
migrate -path migrations -database "$DBURL" down -all # 全部回滚
migrate -path migrations -database "$DBURL" version # 查看当前版本
安装 CLI:go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.18.1
ltree 标签为英文 slug(不支持空格/中文),中文名存于
category.name_zh。gpc_brick_code为食品子集的代表值,后续用官方 GPC 全量导入替换。