Files
adminandClaude Opus 4.8 70b540f668 feat(b2): 账号层三表入 schema —— base_user / base_role / base_role_relation
影响:/api/health 的 baseTables 从 0 变 3(tables 仍 30);data/ 清空重建。
冒烟断言数 75 → 76(多的那条是 baseTables 对账),其余契约零变化。

改动:
- schema/migrate.sql:末段追加账号层三表(真源 = 上游 j7
  boot/db/j7/V1.0.0__jnpf_base_schema.sql,base_user 在 :17384):
  列类型/列序/96 条 COMMENT ON/3 个索引逐字搬运;
  主键 PRIMARY KEY (f_id, f_tenant_id) 内联(上游在 dump 后置 ALTER 里加,
  pglite 只吃 migrate.sql ⇒ 必须自带)
- tests/schema_init.rs:public 表数 30 → 33,并逐名断言 base_* 三表在位
- src/platform/db.rs:迁移产物单测改成 30 tdc_* + 3 base_* 逐名断言
- scripts/reset-data.sh:提示语改成「30 张 tdc_* + 3 张 base_*」
- docs/known-limitations.md:新增 L2(上游 base_user 的 f_maxkey_user_id
  没建 —— 本仓不实现 MaxKey SSO)
- CLAUDE.md / .workbuddy/memory/2026-10-26.md 同步

设计:tdc_* 侧零 DDL 改动(B0 已逐列对账一致);base_* 只建上游真正用到、
且本仓要用的三张,其余 120 张 base_* 与 base_module/base_authorize 一律不建。

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-10-26 22:58:53 +08:00

43 lines
1.3 KiB
Bash
Executable File
Raw Permalink 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
# 清空本地运行期数据(data/tdc.pg + 旧的 node-identity.json)。
#
# 🔴 macOS:个人文件删除必须落到访达回收站(可恢复)⇒ 用 mv 到 ~/.Trash,不用 rm。
#
# 用法:./scripts/reset-data.sh [数据目录]
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DATA_DIR="${1:-${ROOT}/data}"
if [ ! -d "${DATA_DIR}" ]; then
echo "[reset-data] 数据目录不存在,无需重置:${DATA_DIR}"
exit 0
fi
STAMP="$(date +%Y%m%d-%H%M%S)"
TRASH="${HOME}/.Trash"
mkdir -p "${TRASH}"
moved=0
for item in "tdc.pg" "node-identity.json"; do
src="${DATA_DIR}/${item}"
if [ -e "${src}" ]; then
# 目标名带秒级时间戳 + PID,且不撞已有目标(撞了会让 mv 把源移进已有目录,形成一层嵌套)
dest="${TRASH}/tdc-rs-${item}.${STAMP}.$$"
n=1
while [ -e "${dest}" ]; do
dest="${TRASH}/tdc-rs-${item}.${STAMP}.$$.${n}"
n=$((n + 1))
done
mv "${src}" "${dest}"
echo "[reset-data] 已移入访达回收站:${dest}"
moved=1
fi
done
if [ "${moved}" -eq 0 ]; then
echo "[reset-data] 无需重置:${DATA_DIR} 里没有 tdc.pg / node-identity.json"
else
echo "[reset-data] 下次启动会按 schema/migrate.sql 重新建表(30 张 tdc_* + 3 张 base_*)"
fi