Files
dsh_shenxian/scripts/switch-A-migrate.sh
T

21 lines
1008 B
Bash
Raw Normal View History

#!/usr/bin/env bash
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
# A 步:把 47 的生产库 SQLite → 本机控制面 PG(停机窗口内做,避免迁移期间库变动)
set -uo pipefail
PGURL="postgres://dshs:[email protected]:15432/dshs"
DB="$DSHS_DATA_ROOT"/dshs.db
cd "$DSH_INSTALL_DIR"-cluster || exit 1
echo "=== 1) 停 dshs(窗口开始) ==="
systemctl stop dshs
sleep 2
echo " dshs=$(systemctl is-active dshs) 实例 scope 残留: $(systemctl list-units --type=scope --all 2>/dev/null | grep -c 'dsh-' || echo 0)"
echo " 库文件: $(ls -l $DB $DB-wal 2>/dev/null | awk '{print $5}' | tr '\n' '/')"
echo "=== 2) dry-run(只报行数) ==="
node scripts/migrate-sqlite-to-pg.mjs --sqlite "$DB" --pg "$PGURL" --dry-run 2>&1 | tail -18
echo "=== 3) 真迁 ==="
node scripts/migrate-sqlite-to-pg.mjs --sqlite "$DB" --pg "$PGURL" 2>&1 | tail -18
echo " rc=$?"
echo " ⏸ 窗口保持关闭 —— 部署 worker 与 drop-in 后再一起开(见后续步骤)"