fix(build): uapi 表必须先建,rag 的 uapi_seed.sql 才有表可插

原 8b 步骤只生成 rag DDL,pipeline 库无 upapp/uapi/uapiio 表 → 种子导入静默失败(0 行)。
改为循环生成 uapi+rag 两模块 DDL,按 uapi建表→rag建表→配置种子 顺序导入。
This commit is contained in:
yumoqing 2026-08-25 15:32:58 +08:00
parent f1af8c882f
commit bcd8f54a9d

View File

@ -114,17 +114,22 @@ done
# pipeline_task has no separate module
mkdir -p wwwroot/pipeline_task
# 8b. rag 模块:建 rag_* 表 + 导入 uapi 外部服务配置种子
# 8b. uapi + rag 模块建表 + 导入外部服务配置种子
# uapi 表(upapp/uapi/uapiio...)必须先建rag 的 uapi_seed.sql 才有表可插
# rag 表统一 rag_ 前缀,与产线业务表隔离;数据独立于 ragserver同代码不同宿主各自的数据
if [ -d "pkgs/rag/models" ] && ls pkgs/rag/models/*.json >/dev/null 2>&1; then
cd "$cdir/pkgs/rag/models"
"$cdir/py3/bin/json2ddl" mysql . > /tmp/pipeline_rag_ddl.sql || {
echo "ERROR: rag json2ddl failed" >&2; cd "$cdir"; exit 1; }
if [ ! -s /tmp/pipeline_rag_ddl.sql ]; then
echo "ERROR: rag DDL empty — check models/*.json (need summary+fields)" >&2
cd "$cdir"; exit 1
for m in uapi rag; do
if [ -d "pkgs/$m/models" ] && ls pkgs/$m/models/*.json >/dev/null 2>&1; then
cd "$cdir/pkgs/$m/models"
"$cdir/py3/bin/json2ddl" mysql . > "/tmp/pipeline_${m}_ddl.sql" || {
echo "ERROR: $m json2ddl failed" >&2; cd "$cdir"; exit 1; }
if [ ! -s "/tmp/pipeline_${m}_ddl.sql" ]; then
echo "ERROR: $m DDL empty — check models/*.json (need summary+fields)" >&2
cd "$cdir"; exit 1
fi
cd "$cdir"
fi
cd "$cdir"
done
if [ -f /tmp/pipeline_uapi_ddl.sql ] || [ -f /tmp/pipeline_rag_ddl.sql ]; then
"$cdir/py3/bin/python" - <<'PYEOF'
import sys, os, subprocess
sys.path.insert(0, os.getcwd())
@ -133,7 +138,9 @@ from appPublic.aes import aes_decode_b64
cfg = getConfig('.', {'workdir': '.'})
kw = cfg.databases['pipeline'].kwargs
pwd = aes_decode_b64(cfg.password_key, kw.password)
for sqlfile in ['/tmp/pipeline_rag_ddl.sql', 'pkgs/rag/init/uapi_seed.sql']:
# 顺序关键uapi 建表 → rag 建表 → rag 的 uapi 配置种子
for sqlfile in ['/tmp/pipeline_uapi_ddl.sql', '/tmp/pipeline_rag_ddl.sql',
'pkgs/rag/init/uapi_seed.sql']:
if not os.path.exists(sqlfile):
print(' SKIP (missing): %s' % sqlfile)
continue
@ -143,10 +150,10 @@ for sqlfile in ['/tmp/pipeline_rag_ddl.sql', 'pkgs/rag/init/uapi_seed.sql']:
stdin=f, capture_output=True)
tag = os.path.basename(sqlfile)
if r.returncode == 0:
print(' rag: %s applied' % tag)
print(' rag/uapi: %s applied' % tag)
else:
err = r.stderr.decode('utf-8', 'replace').strip().split(chr(10))[0]
print(' WARN rag %s: %s' % (tag, err[:160]))
print(' WARN %s: %s' % (tag, err[:160]))
PYEOF
fi