Commit 55444ced by luoqi

fix(deploy): migrate status 校验改先落变量再 grep — pipefail+grep -q SIGPIPE 误报

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
parent c8c6943a
......@@ -45,9 +45,12 @@ done
log "验证 2/3:数据库迁移无 pending(migrate 容器 exit 0 且 deploy 干净)"
mexit=$(docker inspect "${proj}-pac-migrate-1" --format '{{.State.ExitCode}}')
[[ "$mexit" == "0" ]] || die "migrate 容器 exit=$mexit(看 docker logs ${proj}-pac-migrate-1)"
# 注:prisma 的"新版本提示框"打印位置不固定(异步),不能 tail 截断 —— 全量输出里 grep
docker exec "${proj}-pac-service-1" sh -c 'npx prisma migrate status 2>&1' \
| grep -qiE 'database schema is up to date' || die "迁移有 pending / 状态异常"
# 注 1:prisma 的"新版本提示框"位置不固定(异步)→ 不能 tail 截断,全量输出里找;
# 注 2:pipefail 下 `cmd | grep -q` 会因 grep 提前退出给 cmd 发 SIGPIPE → 管道 141 误判失败
# → 先落变量再 grep。
status_out=$(docker exec "${proj}-pac-service-1" sh -c 'npx prisma migrate status 2>&1' || true)
grep -qiE 'database schema is up to date' <<<"$status_out" \
|| die "迁移有 pending / 状态异常: $(tail -2 <<<"$status_out")"
echo " migrate OK"
log "验证 3/3:health + web"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment