Files
dsh_shenxian/scripts/switch-A2-verify-users.sh
T
admin 5ec99ce227
build / build-and-scan (push) Canceled after 0s
chore: 文档库全量重新入库(2026-10-20)
2026-10-20 15:05:55 +08:00

23 lines
1.4 KiB
Bash
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
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
# 校验:SQLite 与 PG 两侧的 users 明细 + 与磁盘目录对照(判断 2 vs 7 是孤儿目录还是迁移漏行)
set -uo pipefail
cd "$DSH_INSTALL_DIR"-cluster || exit 1
echo "=== SQLite 侧(只读打开,含 WAL) ==="
node -e '
const D = require("better-sqlite3");
const db = new D(""$DSH_DB_FILE"", { readonly: true });
const users = db.prepare("select id, username, role, uid from users order by rowid").all();
console.log(" users 行数:", users.length);
for (const u of users) console.log(` ${u.username} role=${u.role} uid=${u.uid} id=${u.id}`);
console.log(" credential_vault:", db.prepare("select count(*) c from credential_vault").get().c);
console.log(" business_plugins:", db.prepare("select count(*) c from business_plugins").get().c);
'
echo "=== PG 侧 ==="
PGPASSWORD=dshs_cluster_2026 /usr/bin/psql -h 127.0.0.1 -p "$DSHS_PG_PORT" -U dshs -d dshs -tAc \
"select username||' role='||role||' uid='||coalesce(uid::text,'NULL')||' id='||id from users order by rowid" 2>&1 | sed 's/^/ /'
echo " PG users 总数: $(PGPASSWORD=dshs_cluster_2026 /usr/bin/psql -h 127.0.0.1 -p "$DSHS_PG_PORT" -U dshs -d dshs -tAc 'select count(*) from users')"
echo "=== 磁盘目录 vs DB ==="
echo " 目录($(ls "$DSH_USERS_DIR" | wc -l) 个):"
ls "$DSH_USERS_DIR" | sed 's/^/ /'