Files
eip4-platform/tools/flowable-upgrade/lib/common.sh
zhengwr 3b59e90504 P3-3: Flowable 5.13-SNAPSHOT→6.8.1 升级工具链产品化 + 演练全绿
一键链(tools/flowable-upgrade/):
  ①前置校验→②版本串规范化→③Flowable 5.23→④6.8.1 兼容层→⑤后置校验
  全步骤幂等可重入;参数化 host/port/db/schema;JAVA_HOME 强制传 Maven。

完整重演(eip4flow_rehearsal,客户库只读口径):
  import_5x 63s | 一键链 21s | 后置全绿
  1515 定义 / 9386 执行 / 9324 任务 / 26761 历史 全量就地保留
  schema.version: 5.13-SNAPSHOT → 5.23.0.0 → 6.8.1.0
  engineVer=v5 标记: 1515/1515

迁移手册新增坑6.4: Maven exec:java 在多 JDK 环境不走脚本 JAVA_HOME。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 14:31:29 +08:00

60 lines
2.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# common.sh —— Flowable 升级一键链公共配置/函数库(被各步骤 source)
# 参数化:所有连接信息走环境变量,均有默认值,可被 flowable_upgrade.sh 的 -opt 覆盖。
set -euo pipefail
# ---- 目标库(被升级的库)连接参数 ----
: "${TGT_HOST:=localhost}"
: "${TGT_PORT:=5433}"
: "${TGT_DB:=eip4flow_rehearsal}"
: "${TGT_SCHEMA:=eip3}"
: "${TGT_USER:=$(id -un)}"
: "${TGT_PASS:=}"
# ---- 工具路径 ----
: "${PGBIN:=/opt/homebrew/opt/postgresql@15/bin}"
: "${REPO_ROOT:=/Users/zhengwr/workspace/eip3}"
: "${FLOWABLE5_POC:=${REPO_ROOT}/flowable5-poc}" # 5.23 升级跑器(Activiti 5 系末版)
: "${FLOWABLE6_POC:=${REPO_ROOT}/flowable-poc}" # 6.8.1 兼容层跑器
# JDK17(两个跑器均可在 JDK17 编译/运行;flowable5-poc 字节码 target=8 仍兼容)
: "${JAVA_HOME:=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home}"
# ---- 工件目录(快照/日志/备份)----
TOOL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
: "${WORK_DIR:=${TOOL_DIR}/.work}"
mkdir -p "${WORK_DIR}"
export PGPASSWORD="${TGT_PASS}"
# JDBC URL(两个跑器共用;currentSchema 指向目标 schema)
jdbc_url() {
echo "jdbc:postgresql://${TGT_HOST}:${TGT_PORT}/${TGT_DB}?currentSchema=${TGT_SCHEMA}"
}
# psql 到目标库(带 schema search_path)
tpsql() {
"${PGBIN}/psql" -h "${TGT_HOST}" -p "${TGT_PORT}" -U "${TGT_USER}" -d "${TGT_DB}" \
-v ON_ERROR_STOP=1 "$@"
}
log() { printf '\033[1;36m[%s] %s\033[0m\n' "$(date +%H:%M:%S)" "$*"; }
ok() { printf '\033[1;32m ✓ %s\033[0m\n' "$*"; }
warn() { printf '\033[1;33m ! %s\033[0m\n' "$*"; }
die() { printf '\033[1;31m ✗ %s\033[0m\n' "$*" >&2; exit 1; }
# 计时:begin_timer / end_timer "<step>",追加到 WORK_DIR/timings.tsv
begin_timer() { __T0=$(date +%s); }
end_timer() {
local dt=$(( $(date +%s) - ${__T0:-$(date +%s)} ))
printf '%s\t%ss\n' "$1" "${dt}" >> "${WORK_DIR}/timings.tsv"
ok "$1 耗时 ${dt}s"
}
# 全量运行时表(行数全量拷贝/对账口径)
ACT_FULL="act_ge_property act_re_deployment act_re_model act_re_procdef \
act_ru_event_subscr act_ru_execution act_ru_identitylink act_ru_job act_ru_task act_ru_variable \
act_id_group act_id_info act_id_membership act_id_user \
act_hi_procinst act_hi_taskinst act_hi_actinst"
# 巨型历史表 / bytearray:schema-only(数据按引用过滤或不带),见 §生产外推
ACT_SCHEMA_ONLY="act_ge_bytearray act_hi_varinst act_hi_detail act_hi_comment act_hi_attachment act_hi_identitylink"