chore(A10 W1): 收敛重复 bootstrap,db/migration 成平台表 DDL 单一真相

W1 引入 db/migration/V1-V3 后,平台表 DDL 在迁移与各模块 bootstrap-*.sql 重复
(评审揪出的"易漂移")。本次收敛,db/migration 成唯一真相:

- 删 3 份重复 bootstrap:bootstrap-page-schema(=V1)/bootstrap-datastatus(=V2)/
  bootstrap-ai-agent(=V3)。三者无运行态 classpath 消费者(已全仓核实)。
- AiAgentDdlTest(platform-ai,原读 bootstrap-ai-agent.sql)删除,等价覆盖迁入
  platform-app 新增 PlatformMigrationDdlGuardTest:① 守 V3 声明全部 AI 平台表/索引;
  ② 守 SchemaImportCli.CREATE_DDL ≡ V1(独立 CLI 兜底 DDL 防漂移)。
- SchemaImportCli.CREATE_DDL 由包私有改 public 供上述 guard 比对;两处过时注释改指 V1。
- ci.sh 平台表预灌改指 db/migration/V1(注:app 启动 Flyway 已幂等建表,此预灌仅冗余兜底)。
- docs 对齐:AI_AGENT_AUTO_DEVELOPMENT(spring.sql.init→Flyway)、docs/sql/SYS_PAGE_SCHEMA
  /SYS_AI_AGENT 头注释(待办→已落地)、A10 design 残留收敛标完成、deploy/README 残留项标完成。

边界:platform-parity 的 bootstrap-{sys,privilege,auth,xservice,multidim,flow}.sql 是
eip3 schema 对拍测试 fixture,非平台表副本,原样保留。

验证:全 reactor mvn clean install 绿;PlatformMigrationDdlGuardTest 2/2;独立 code-reviewer
评审 GO(零 CRITICAL/HIGH/MEDIUM,含 guard substring 逻辑对真实 V1 仿真核实)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-25 15:16:35 +08:00
parent b7fbae4cae
commit fa3c92b698
12 changed files with 94 additions and 228 deletions

View File

@@ -63,7 +63,9 @@ EIP4 当前只有 **dev 形态**(手工 `run-dev.sh` 起两个 fat jar + 前
## 3.1 W1 Flyway 详细执行规格(ready-to-run,2026-06-25 勘探后细化)
> **状态(2026-06-25 更新)**:✅ **已实现 + 对本地真实 PG 验证通过**(见上「实施进度」+ `FlywayMigrationLocalIT`)。下方为落地时遵循的规格,现已按此落地;残留全收敛(删 bootstrap/repoint ci.sh)为 follow-up。
> **状态(2026-06-25 更新)**:✅ **已实现 + 对本地真实 PG 验证通过 + 整栈 docker compose 真起 + 残留全收敛**。
> - 真验:`FlywayMigrationLocalIT`(库级两场景)+ 整栈 `docker compose up` 内置空 PG:platform-app 在 prod profile 启动时 Flyway 自建 eip3 schema 落 9 张 sys_* 表、readiness UP、nginx 单源反代生效(见 `deploy/README.md` 验证状态)。
> - 残留收敛(已完成):删 3 份与 db/migration 重复的 bootstrap(page-schema/datastatus/ai-agent);`ci.sh` 改指 `db/migration/V1`;`AiAgentDdlTest` 迁入 platform-app 改守 V3;新增 `SchemaImportCli.CREATE_DDL`↔V1 防漂移 guard(`PlatformMigrationDdlGuardTest`)。db/migration 现为平台表 DDL 唯一真相(SchemaImportCli 内联 DDL 为独立 CLI 兜底,经 guard 钉死不漂移)。
> **已做前置(2026-06-25)**:`bootstrap-ai-agent.sql` 两份去重——删 platform-app 副本,单一真相归 `platform-ai/src/main/resources/bootstrap/bootstrap-ai-agent.sql`(platform-app 经依赖传递消费;原同 classpath 路径双副本=解析歧义,已消除)。
**为何需 PG 才能安全做**:迁移 SQL 是 PG 专有(`::jsonb`/`::xml`/`ON CONFLICT`),H2 跑不了;本机 Docker daemon 未起→testcontainers 也用不了。盲发自动 migrate 进客户库启动路径=高爆炸半径,必须先在 dev PG 验过 `flyway migrate` + 回退。