-
feat(sync): PR3 — 统一 sync 模式,deprecate cold-import 独立路径 · f7a6d41f
把 cold-import / incremental 两个独立模式合并为单一 sync 入口。 importDirectory 关键改动: - 只要 manifest 配了 sql_source.incremental.per_query,**永远** 读 + 写 cursor - options.incremental === false → 走 --full 路径(忽略上次 cursor,但仍写新 cursor_after) - options.incremental 默认 true → 正常 sync(读 + 写 cursor) - resource 统一写 'incremental_bundle'(不再区分 cold_import / incremental) - readLastIncrementalCursor 接受 SUCCESS + PARTIAL 历史行(partial 已推进 cursor) 修关键 bug: PR1 之前,--full 模式(incremental=false)不写 cursor → 下次 sync 从旧 cursor 拉 → **漏掉 --full 期间 DW 新写入的数据** PR3 统一写 cursor_after=run_start,保证后续 sync 永远从最新 baseline 接力 新 CLI 入口: - pnpm sync → 推荐主入口(=sync-incremental,首跑全量 / 日常增量自动) - pnpm sync:prod → docker prod 版 - pnpm sync:once → 别名(强调"手动触发一次") - pnpm cold-import → legacy 保留(不读 cursor,等价 pnpm sync --full) - pnpm sync-incremental → legacy alias 保留 sync-incremental.cli.ts 增强: - 加 --full / --cohort-batch=N / --no-cohort 参数 - 文件头改 "PAC v1 唯一推荐 sync 命令" + 用法 + 退出码注释 - 启动日志带 cohortBatch / full / dryRun 配置全量 部署节奏(server 实战): 首次:pnpm sync:prod -- --dir=./data/jvs-dw → 自动分批(5000 patient/批) → cursor_after = 启动时刻 ISO → 持续跑直到所有 patient 处理完成 → 此后 cron 02:30 增量自动接力 灾后:DELETE FROM patient_transactions...; pnpm sync:prod -- --dir=./data/jvs-dw (cursor 自然为空 = 等价全量) 强制:pnpm sync -- --full(罕见,cursor 损坏修复场景) 向后兼容: - 所有老脚本(cold-import / sync-incremental)继续工作 - SyncIncrementalSchedulerService 不动(默认 incremental:true) - 历史 sync_logs 行(resource='cold_import_bundle')不受影响, 自然被 cursor_after IS NULL 过滤掉luoqi committed
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| cli | Loading commit data... | |
| common | Loading commit data... | |
| config | Loading commit data... | |
| modules | Loading commit data... | |
| openapi | Loading commit data... | |
| prisma | Loading commit data... | |
| queues | Loading commit data... | |
| redis | Loading commit data... | |
| app.module.ts | Loading commit data... | |
| health.controller.ts | Loading commit data... | |
| main.ts | Loading commit data... |