Files
goods/migrations
John Doe a35bcd6647
CI / Go (api) (pull_request) Has been cancelled
CI / Python (ingestion) (pull_request) Has been cancelled
CI / Migrations (postgres) (pull_request) Has been cancelled
M4: ingestion management (incremental, GS1 supplement, dedup/conflict, quality, scheduler)
- OFF incremental fetch via search API + persistent watermark (ingest_state, migration 0004)
- GS1 barcode supplement adapter (offline mapping + GS1-style API) filling only gaps with field-level provenance
- Non-GTIN dedup with canonical selection + merge_log; field-level conflict resolution (source trust > recency)
- Quality scoring (0.4 completeness + 0.3 source trust + 0.2 multi-source + 0.1 freshness) wired into load/merge
- Jobs: update_off, dedup, schedule; docs/ingestion-management.md
- 19 new tests (pure + DB-integration), ruff clean

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-06-08 09:27:42 +00:00
..

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   # 查看当前版本

安装 CLIgo install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.18.1

ltree 标签为英文 slug(不支持空格/中文),中文名存于 category.name_zhgpc_brick_code 为食品子集的代表值,后续用官方 GPC 全量导入替换。