auto(d389ca8d6886): session end @ 2026-06-27T12:56:12 (+1f)

This commit is contained in:
ssw committed 2026-06-27 12:56:13 +08:00
1 parent 7416bb760f
commit 760f758b54
1 file changed
+10 -2
+10 -2
View File
@@ -64,6 +64,12 @@ const MAIN_TABLE_PLANS: ReadonlyArray<{ table: string; whereTpl: string }> = [
{ table: 'base_db_link', whereTpl: 'f_full_name = :app_code' },
{ table: 'base_dictionary_data', whereTpl: "f_dictionary_type_id='9c43287481364d348c0ea0d0f64b38be' AND f_full_name = :app_code" },
{ table: 'base_dictionary_data', whereTpl: "f_dictionary_type_id='306427078100678661' AND f_full_name = CONCAT(:app_code,'_b')" },
// v10.6.2+ B-4 闭环: 新建 dict 类型时 enCode 强制 {appCode}.{name} 格式 (点号分隔),
// 因此 base_dictionary_type 用 f_en_code LIKE '{appCode}.%' 即可识别本应用的字典类型.
// base_dictionary_data 通过 f_dictionary_type_id 外键间接定位 (子表依赖主表).
// 顺序: base_dictionary_data 先于 base_dictionary_type (子表 → 主表).
{ table: 'base_dictionary_data', whereTpl: 'f_dictionary_type_id IN (SELECT f_id FROM base_dictionary_type WHERE f_en_code LIKE CONCAT(:app_code, \'.\%\'))' },
{ table: 'base_dictionary_type', whereTpl: 'f_en_code LIKE CONCAT(:app_code, \'.\%\')' },
{ table: 'base_system', whereTpl: 'f_en_code = :app_code' },
]
@@ -116,7 +122,7 @@ interface TableHit {
// =====================================================================
export function buildAppClearCommand(): Command {
const cmd = new Command('clear')
.description('清除 JNPF 应用本地资源 + DB 记录 (RENAME 到 history_bak, 文件备份到 docs/{app}/history-bak/{ts}/). ⚠ 破坏性, 强制 TTY + 双重人工确认.')
.description('清除 JNPF 应用本地资源 + DB 记录 (含本应用 enCode 前缀的字典类型/字典项; RENAME 到 history_bak, 文件备份到 docs/{app}/history-bak/{ts}/). ⚠ 破坏性, 强制 TTY + 双重人工确认.')
.requiredOption('--appCode <code>', '要清除的应用代码 (e.g. tds, tds2)')
.option('--dry-run', '只预览, 不实际删除/备份 (任何环境可用, 无需 TTY)', false)
.option('--skip-db', '跳过数据库清理 (仅清理本地文件 + 构建配置)', false)
@@ -152,6 +158,7 @@ export function buildAppClearCommand(): Command {
'**⚠ 破坏性命令**: 真实执行强制 TTY + 双重人工确认 (appCode + "DELETE"). AI 助手严禁键入确认.',
'**绝不 DROP TABLE / DROP DATABASE**: 业务库用 RENAME TABLE (原子, 秒级), 主库用 Phase 1/2/3 拆事务.',
'**v10.6.1 DDL bug 复刻**: Phase 1 (CREATE+INSERT) + Phase 2 (单事务 DELETE) + Phase 3 (drop 空表) 必须分开, 否则 DDL 隐式 commit 打断事务, rollback 失效.',
'**v10.6.2+ 同步清字典 (默认开启)**: base_dictionary_type 用 `f_en_code LIKE \'{appCode}.%\'` 过滤本应用字典类型, base_dictionary_data 通过 FK 关联删除对应字典项. **只动本应用 enCode 前缀, 不影响其他应用/平台内置字典**.',
'**文件备份**: renameSync 原子到 docs/{app}/history-bak/{ts}/files/, MANIFEST.txt 写明还原 SQL/rsync.',
'**回滚**: 按 docs/{app}/history-bak/{ts}/MANIFEST.txt 中的反向 SQL + rsync 手动还原.',
'**--restart**: 清理成功后询问 Y/N, Y → 自动调 `dacli app create --appCode=X --appName=Y --force-rebuild` 重建.',
@@ -612,7 +619,8 @@ async function querySystemId(conn: Connection, appCode: string): Promise<string
/** 这些表 where 条件只用 appCode (其他表都用 systemId) */
const TABLES_PARAMS_BY_APP_CODE = new Set([
'base_db_link',
'base_dictionary_data', // 两条都
'base_dictionary_data', // 三条 (含 v10.6.2+ 新增的 FK 子表规则)
'base_dictionary_type', // v10.6.2+ 新增: enCode LIKE '{appCode}.%'
'base_system',
])