196 lines
8.8 KiB
Markdown
196 lines
8.8 KiB
Markdown
# RailwaySystem 数据库 V2 双门禁验证报告 (Gate A / Gate B)
|
|||
|
|
|
||
|
|
本文档记录 RailwaySystem 数据库 V2 **测试迁移准入阶段**在真实环境下的双门禁(Gate A 与 Gate B)实测验证结果。
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 一、验证环境与连接上下文
|
||
|
|
|
||
|
|
| 配置项 | 实际环境参数 | 状态 |
|
||
|
|
| :--- | :--- | :--- |
|
||
|
|
| **数据库版本** | KingbaseES V009R003C018 | 正常连通 |
|
||
|
|
| **数据库实例** | `training` | 确认 |
|
||
|
|
| **当前 Schema** | `public` | 确认 |
|
||
|
|
| **会话 search_path** | `public, sys_catalog` | 确认 |
|
||
|
|
| **数据库模式** | `database_mode = mysql` | 确认 |
|
||
|
|
| **JDBC 驱动** | `com.kingbase8:kingbase8:8.6.0` (via preferQueryMode=simple) | 官方原生驱动 |
|
||
|
|
| **连接安全性** | 脱敏隧道接入,无外部明文暴露 | 合规 |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 二、Gate A: 事务回滚能力探测验证
|
||
|
|
|
||
|
|
### 2.1 执行目标与原则
|
||
|
|
- **验证脚本**: `RuoYi-Vue/sql/train/v2/000_tx_capability_probe.sql`
|
||
|
|
- **执行目标**: 探测当前 KingbaseES 实例在 `database_mode = mysql` 下是否支持 DDL + `BEGIN / ROLLBACK` 事务原子性回滚能力。
|
||
|
|
- **约束**: 仅在临时对象 `public.__railway_v2_tx_probe` 上执行,绝不触碰任何业务表。
|
||
|
|
|
||
|
|
### 2.2 验证结果矩阵
|
||
|
|
|
||
|
|
| 探测步骤 | 预期行为 | 实际执行结果 | 判定 |
|
||
|
|
| :--- | :--- | :--- | :--- |
|
||
|
|
| **1. 显式开启事务** | `BEGIN;` | 事务启动成功 | **PASS** |
|
||
|
|
| **2. 探针表建表** | `CREATE TABLE public.__railway_v2_tx_probe (id INTEGER);` | 表创建成功 | **PASS** |
|
||
|
|
| **3. 探针表改表** | `ALTER TABLE public.__railway_v2_tx_probe ADD COLUMN test_col INTEGER;` | 字段追加成功 | **PASS** |
|
||
|
|
| **4. 显式回滚事务** | `ROLLBACK;` | 事务回滚成功 | **PASS** |
|
||
|
|
| **5. 匿名块断言** | `DO $$ ... $$;` 检查表是否存在并发出提示 | 收到 `[Probe-PASS]` 通知 | **PASS** |
|
||
|
|
| **6. 最终只读断言** | `SELECT count(*) FROM information_schema.tables WHERE ...` 为 0 | `count = 0` | **PASS** |
|
||
|
|
|
||
|
|
### 2.3 Gate A 关键原始日志
|
||
|
|
```text
|
||
|
|
==================================================
|
||
|
|
>>> 正在启动 Gate A: 000_tx_capability_probe.sql
|
||
|
|
>>> 目标文件: RuoYi-Vue/sql/train/v2/000_tx_capability_probe.sql
|
||
|
|
==================================================
|
||
|
|
Database: training, Schema: public
|
||
|
|
Database Mode: mysql
|
||
|
|
Version: KingbaseES V009R003C018
|
||
|
|
>>> 开始执行 000_tx_capability_probe.sql 内容 (preferQueryMode=simple)...
|
||
|
|
Statement [1] update count: 0
|
||
|
|
>>> [STMT NOTICE/WARNING] >>> [Probe-PASS] 数据库 DDL 事务原子性验证通过:Kingbase 实例支持 DDL 事务回滚,符合 V2 迁移安全前提。
|
||
|
|
Statement [2] update count: 0
|
||
|
|
Statement [3] update count: 0
|
||
|
|
Statement [4] update count: 0
|
||
|
|
Statement [5] update count: 0
|
||
|
|
>>> 000_tx_capability_probe.sql 脚本执行完成,无异常抛出。
|
||
|
|
>>> 验证探针表残留情况 (SELECT count(*) FROM information_schema.tables)...
|
||
|
|
>>> public.__railway_v2_tx_probe count = 0
|
||
|
|
==================================================
|
||
|
|
>>> [GATE A FINAL EVALUATION]: PASS
|
||
|
|
==================================================
|
||
|
|
```
|
||
|
|
|
||
|
|
### 2.4 Gate A 结论
|
||
|
|
**Gate A = PASS**。当前 KingbaseES 实例完全支持本次 V2 迁移所依赖的 DDL 事务原子性回滚能力,探针表完全回滚且零残留。
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 三、Gate B: Phase 0.5 基线强校验验证
|
||
|
|
|
||
|
|
### 3.1 执行目标与原则
|
||
|
|
- **验证脚本**: `RuoYi-Vue/sql/train/v2/000_preflight.sql`
|
||
|
|
- **执行目标**: 纯只读核验当前真实数据库精确处于 Phase 0.5 基线状态,杜绝环境漂移或非纯净基线。
|
||
|
|
|
||
|
|
### 3.2 验证结果矩阵
|
||
|
|
|
||
|
|
| 核验分类 | 核验项 | 期望值 | 实测值 | 判定 |
|
||
|
|
| :--- | :--- | :--- | :--- | :--- |
|
||
|
|
| **Schema 确认** | 会话 Schema | `public` | `public` | **PASS** |
|
||
|
|
| **业务表集合** | 14 张 Phase 0.5 历史表集合全等 | 仅这 14 张 `train_*` | 14 张精确存在 | **PASS** |
|
||
|
|
| **表差异探测** | `MISSING_TABLE` | 0 | 0 | **PASS** |
|
||
|
|
| **表差异探测** | `UNEXPECTED_TABLE` | 0 | 0 | **PASS** |
|
||
|
|
| **数据行数基线** | `train_teacher` | 1 行 | 1 行 | **PASS** |
|
||
|
|
| **数据行数基线** | 其余 13 张旧业务表 | 全部 0 行 | 全部 0 行 | **PASS** |
|
||
|
|
| **V2 新增表** | 8 张 V2 新表存在性 | 全部不存在 (0) | 全部不存在 (0) | **PASS** |
|
||
|
|
| **主键约束** | 14 个旧表 PK 定义 | 14/14 匹配 | 14/14 匹配 | **PASS** |
|
||
|
|
| **自增列** | 6 个旧表 Identity 主键 | 6/6 匹配 | 6/6 匹配 | **PASS** |
|
||
|
|
| **唯一约束** | 7 组旧表 UNIQUE 约束 | 7/7 匹配 | 7/7 匹配 | **PASS** |
|
||
|
|
| **外键约束** | 24 组旧表 FK 约束 (名称/源列/引用表/引用列) | 24/24 匹配 | 24/24 匹配 | **PASS** |
|
||
|
|
| **触发器** | 9 个 update_time 触发器 | 9/9 匹配 | 9/9 匹配 | **PASS** |
|
||
|
|
| **旧字段特征** | 旧列特征检查 (`c_id`, `t_id`, `lesson_start_time` 等) | 符合旧模型 | 符合旧模型 | **PASS** |
|
||
|
|
| **系统底座表** | `sys_*` 基础表数据完整性 | 1/106/15/44/500 | 1/106/15/44/500 | **PASS** |
|
||
|
|
|
||
|
|
### 3.3 14 张 Phase 0.5 业务表行数实测明细
|
||
|
|
- `train_teacher`: 1 行
|
||
|
|
- `train_student`: 0 行
|
||
|
|
- `train_course`: 0 行
|
||
|
|
- `train_class_plan`: 0 行
|
||
|
|
- `train_dormitory_info`: 0 行
|
||
|
|
- `train_dorm_auth`: 0 行
|
||
|
|
- `train_classroom_info`: 0 行
|
||
|
|
- `train_training_site`: 0 行
|
||
|
|
- `train_class_report`: 0 行
|
||
|
|
- `train_electronic_board`: 0 行
|
||
|
|
- `train_student_checkin`: 0 行
|
||
|
|
- `train_score_info`: 0 行
|
||
|
|
- `train_study_duration`: 0 行
|
||
|
|
- `train_student_portrait`: 0 行
|
||
|
|
|
||
|
|
### 3.4 8 张 V2 新增表独立只读探测
|
||
|
|
- `train_resource`: 不存在 (count = 0)
|
||
|
|
- `train_course_resource`: 不存在 (count = 0)
|
||
|
|
- `train_plan_course`: 不存在 (count = 0)
|
||
|
|
- `train_enrollment`: 不存在 (count = 0)
|
||
|
|
- `train_lesson`: 不存在 (count = 0)
|
||
|
|
- `train_accommodation`: 不存在 (count = 0)
|
||
|
|
- `train_score_item`: 不存在 (count = 0)
|
||
|
|
- `train_student_score`: 不存在 (count = 0)
|
||
|
|
|
||
|
|
### 3.5 Gate B 关键原始日志
|
||
|
|
```text
|
||
|
|
==================================================
|
||
|
|
>>> 正在启动 Gate B: 000_preflight.sql
|
||
|
|
>>> 目标文件: RuoYi-Vue/sql/train/v2/000_preflight.sql
|
||
|
|
==================================================
|
||
|
|
Database: training, Schema: public
|
||
|
|
Database Mode: mysql
|
||
|
|
Version: KingbaseES V009R003C018
|
||
|
|
|
||
|
|
>>> 开始执行 000_preflight.sql 脚本 (只读强校验)...
|
||
|
|
[PREFLIGHT LOG] ==============================================================================
|
||
|
|
[PREFLIGHT LOG] >>> [Preflight-PASS] Phase 0.5 精确骨架校验全部通过!
|
||
|
|
[PREFLIGHT LOG] >>> 核验项: 14旧表 + 14 PK + 24 FK + 7 UNIQUE + 6 Identity + 9 Triggers + 行数基线
|
||
|
|
[PREFLIGHT LOG] >>> 判定结果: 当前数据库处于纯净 Phase 0.5 历史基线状态,允许执行 V2 迁移。
|
||
|
|
[PREFLIGHT LOG] ==============================================================================
|
||
|
|
>>> 000_preflight.sql 脚本执行成功,全部内部断言 PASS!
|
||
|
|
|
||
|
|
==================================================
|
||
|
|
>>> 开始收集 Phase 0.5 详细只读核验明细数据...
|
||
|
|
==================================================
|
||
|
|
Probe Table '__railway_v2_tx_probe' Count: 0
|
||
|
|
|
||
|
|
Actual train_* tables count: 14
|
||
|
|
Actual train_* tables list: [train_class_plan, train_class_report, train_classroom_info, train_course, train_dorm_auth, train_dormitory_info, train_electronic_board, train_score_info, train_student, train_student_checkin, train_student_portrait, train_study_duration, train_teacher, train_training_site]
|
||
|
|
|
||
|
|
Row count per train_* table:
|
||
|
|
- train_class_plan: 0 行
|
||
|
|
- train_class_report: 0 行
|
||
|
|
- train_classroom_info: 0 行
|
||
|
|
- train_course: 0 行
|
||
|
|
- train_dorm_auth: 0 行
|
||
|
|
- train_dormitory_info: 0 行
|
||
|
|
- train_electronic_board: 0 行
|
||
|
|
- train_score_info: 0 行
|
||
|
|
- train_student: 0 行
|
||
|
|
- train_student_checkin: 0 行
|
||
|
|
- train_student_portrait: 0 行
|
||
|
|
- train_study_duration: 0 行
|
||
|
|
- train_teacher: 1 行
|
||
|
|
- train_training_site: 0 行
|
||
|
|
|
||
|
|
Checking V2 new tables existence:
|
||
|
|
- train_resource: NOT EXISTS (PASS)
|
||
|
|
- train_course_resource: NOT EXISTS (PASS)
|
||
|
|
- train_plan_course: NOT EXISTS (PASS)
|
||
|
|
- train_enrollment: NOT EXISTS (PASS)
|
||
|
|
- train_lesson: NOT EXISTS (PASS)
|
||
|
|
- train_accommodation: NOT EXISTS (PASS)
|
||
|
|
- train_score_item: NOT EXISTS (PASS)
|
||
|
|
- train_student_score: NOT EXISTS (PASS)
|
||
|
|
|
||
|
|
Primary Keys count: 14 (expected: 14)
|
||
|
|
Foreign Keys count: 24 (expected: 24)
|
||
|
|
Unique constraints count: 7 (expected: 7)
|
||
|
|
Identity columns count: 6 (expected: 6)
|
||
|
|
Triggers count: 9 (expected: 9)
|
||
|
|
|
||
|
|
==================================================
|
||
|
|
>>> [GATE B FINAL EVALUATION]: PASS
|
||
|
|
==================================================
|
||
|
|
```
|
||
|
|
|
||
|
|
### 3.6 Gate B 结论
|
||
|
|
**Gate B = PASS**。当前数据库精确处于 Phase 0.5 迁移起点状态,无任何缺失、漂移或意外对象。
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 四、双门禁总体结论与状态说明
|
||
|
|
|
||
|
|
1. **准入资格判定**:
|
||
|
|
- `Gate A: PASS`
|
||
|
|
- `Gate B: PASS`
|
||
|
|
- **结论**: 数据库 V2 迁移正式获得 **Stage 1 (001_backup_current_schema.sql)** 执行准入资格。
|
||
|
|
|
||
|
|
2. **迁移脚本执行边界声明**:
|
||
|
|
- 截至 Gate A/B 完成与报告生成时,**001~010 正式数据库迁移脚本均未执行**。
|
||
|
|
- 数据库依然保持纯净 Phase 0.5 状态。
|