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:
@@ -8,21 +8,15 @@
|
||||
|
||||
## 本地运行配置
|
||||
|
||||
`local` 和 `dev` profile 已开启:
|
||||
`local` 和 `dev` profile 已开启 JDBC 持久化:
|
||||
|
||||
```yaml
|
||||
spring:
|
||||
sql:
|
||||
init:
|
||||
mode: always
|
||||
schema-locations: classpath:bootstrap/bootstrap-ai-agent.sql
|
||||
|
||||
eip4:
|
||||
ai:
|
||||
store: jdbc
|
||||
```
|
||||
|
||||
因此本地启动时会幂等创建 `sys_ai_task`、`sys_ai_draft`、`sys_ai_change_set`、`sys_ai_run`、`sys_ai_audit_log`,并用 JDBC 持久化开发证据。默认 profile 不强制写远端验证库,避免误把开发证据写到共享环境。
|
||||
平台表(`sys_ai_task`、`sys_ai_draft`、`sys_ai_change_set`、`sys_ai_run`、`sys_ai_feature_package`、`sys_ai_revision`、`sys_ai_audit_log`)由 **W1 Flyway 在启动时幂等建表**——单一真相 `platform-app/src/main/resources/db/migration/V3__sys_ai_agent.sql`(A10 W1 收敛后取代原 `spring.sql.init` + 已删的 `bootstrap-ai-agent.sql`)。因此本地启动即用 JDBC 持久化开发证据;默认 profile 不强制写远端验证库,避免误把开发证据写到共享环境。
|
||||
|
||||
建议使用独立 worktree 做 Agent 功能开发,避免占用当前任务目录:
|
||||
|
||||
|
||||
@@ -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` + 回退。
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
-- 归属:platform-ai(P5 Agent 开发底座)。
|
||||
-- 契约:/api/ai/tasks、/api/ai/tasks/{taskId}/drafts、change-sets、runs、audit。
|
||||
--
|
||||
-- 【Flyway 待办(P5)】
|
||||
-- 【Flyway 已落地(A10 W1,2026-06-25)】
|
||||
-- 架构条款(docs/架构设计.md §「平台表管理」):SYS_* 平台表由 Flyway 管理。
|
||||
-- 本工程当前未引入 Flyway。本脚本即「生产建表脚本」,P5 引入 Flyway 时
|
||||
-- 原样改名为 V{n}__create_sys_ai_agent.sql 纳入 src/main/resources/db/migration 即可。
|
||||
-- 本地 / CI 自举副本见 platform-ai/src/main/resources/bootstrap/bootstrap-ai-agent.sql。
|
||||
-- ✅ 已引入 Flyway。这些表【单一真相】= platform-app/src/main/resources/db/migration/V3__sys_ai_agent.sql
|
||||
-- (运行态由 Flyway 启动时幂等 migrate;内容与本脚本一致)。本文件保留为人读的生产建表参考。
|
||||
-- 原 bootstrap-ai-agent.sql 自举副本已删除(收敛入 V3)。
|
||||
--
|
||||
-- 边界:这些表只保存 AI 开发运行态和草稿。发布到 SYS_PAGE_SCHEMA / SYS_ENTITY /
|
||||
-- 服务流等生产元数据必须经过独立人审门禁,不能由 Agent 接口直接落生产。
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
-- 归属:platform-metadata(页面 schema 服务化,P4-4)。
|
||||
-- 契约:GET /api/page/schema/{templateId} 的下发数据源。
|
||||
--
|
||||
-- 【Flyway 待办(P5)】
|
||||
-- 【Flyway 已落地(A10 W1,2026-06-25)】
|
||||
-- 架构条款(docs/架构设计.md §「平台表管理」):SYS_* 平台表由 Flyway 管理。
|
||||
-- 本工程当前未引入 Flyway。本脚本即「生产建表脚本」,P5 引入 Flyway 时
|
||||
-- 原样改名为 V{n}__create_sys_page_schema.sql 纳入 src/main/resources/db/migration 即可
|
||||
-- (内容无需改动,故此处保持 Flyway 友好:单条幂等 DDL,无数据)。
|
||||
-- 本地 / CI 自举副本见 platform-metadata/src/main/resources/bootstrap/bootstrap-page-schema.sql。
|
||||
-- ✅ 已引入 Flyway。本表【单一真相】= platform-app/src/main/resources/db/migration/V1__sys_page_schema.sql
|
||||
-- (运行态由 Flyway 启动时幂等 migrate;内容与本脚本一致)。本文件保留为人读的生产建表参考。
|
||||
-- 原 bootstrap-page-schema.sql 自举副本已删除(收敛入 V1)。
|
||||
--
|
||||
-- 初始数据导入(1489 个转换产物)由 SchemaImportCli 批量入库,不在本 DDL 内。
|
||||
-- ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user