Files
crawler-plugin/backend-java/docs/plans/12-plan-flyway-and-inspection.md
T
huangzd1997 b404fd2572 docs(仓库): 规划文档改为入库,落盘品牌库/去重库每公司一套二期方案
`.gitignore` 原先把 docs/plans/ 与 backend-java/docs/plans/ 记成「本地不入库」,
代价有两头:干净 worktree 出包时这些文件根本不存在(门禁要读它们的用例先假红),
跨会话的实施计划也没有留存通道。改为入库,本批把 34 个 md 落进仓库。
2026-10-04 13:51:16 +08:00

138 lines
4.2 KiB
Markdown
Raw 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.
# 12-plan — Flyway 迁移规范与只读巡检
> 对应 `docs/specs/12-flyway-and-inspection.md`。只追加不改历史;巡检默认关闭。
> 技术栈:Java 21 + Flyway + SQL。
## 任务 192:迁移规范模板
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
### 功能点要求
`docs/` 产出迁移规范模板:变更目的/影响表和数据量/锁表风险/验证 SQL/回滚步骤/上线窗口六项必填;新迁移文件头注释引用模板。
### 测试用例(≥8)
1. test_template_exists — 模板存在
2. test_six_fields — 六字段齐全
3. test_template_has_example — 示例
4. test_rollback_steps — 回滚步骤
5. test_validation_sql — 验证 SQL 示例
6. test_window_field — 上线窗口
7. test_doc_committed
8. test_template_usable — 可复制使用
## 任务 193:历史迁移盘点
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
### 功能点要求
盘点 db/ 下 V87+ 迁移:编号连续性、无修改历史(git 不动)、生产已执行版本核对;产出盘点报表。
### 测试用例(≥8)
1. test_version_sequential — 编号连续
2. test_no_legacy_modified — 历史未改
3. test_latest_version_noted — 最新版本记录
4. test_duplicate_version — 无重复编号
5. test_migration_single_purpose — 单迁移单目的(抽查)
6. test_report_committed
7. test_checksum_stable — 校验和稳定
8. test_repeatable
## 任务 194:orphan Job 巡检 SQL
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
### 功能点要求
巡检 SQL:task_file_job 无对应 task/result;SQL 只读;输出孤儿清单。
### 测试用例(≥8)
1. test_sql_syntax_valid — 语法有效
2. test_sql_read_only — 只读(SELECT)
3. test_orphan_detected — 检出
4. test_valid_excluded — 正常排除
5. test_join_condition — 关联条件
6. test_no_side_effect — 无副作用
7. test_empty_result_ok — 空结果
8. test_documented — 文档
## 任务 195:orphan payload 巡检 SQL
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
同 194 模式(payload 无对应任务)。
### 测试用例(≥8)
同 194(payload 表)。
## 任务 196:任务存在结果缺失巡检 SQL
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
同 194 模式(SUCCESS 任务无结果)。
### 测试用例(≥8)
同 194。
## 任务 197:结果存在文件缺失巡检 SQL
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
同 194 模式(resultFileUrl 对应对象不存在——SQL 先出清单,对象检查在 09/158 配合)。
### 测试用例(≥8)
同 194。
## 任务 198:已完成任务活跃 Job 巡检 SQL
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
同 194 模式(终态任务仍有活跃 job)。
### 测试用例(≥8)
同 194。
## 任务 199:超保留期引用巡检 SQL
**所属模块**:12 Flyway **依赖**:无 **预估**:8-15 分钟
同 194 模式(临时文件超保留期仍有引用)。
### 测试用例(≥8)
同 194。
## 任务 200:巡检报表任务落地
**所属模块**:12 Flyway **依赖**:194-199 **预估**:8-15 分钟
### 功能点要求
巡检定时任务:执行 6 张报表 SQL;默认 disabled;启用后输出报表日志;失败不阻断。
### 测试用例(≥8)
1. test_disabled_default
2. test_enabled_runs_all — 6 报表全跑
3. test_report_output
4. test_failure_grace
5. test_schedule_config
6. test_no_delete
7. test_dual_instance
8. test_enabled_stable
## 任务 201:迁移演练
**所属模块**:12 Flyway **依赖**:192 **预估**:8-15 分钟
### 功能点要求
副本库演练:flyway migrate 干净执行;验证 SQL 通过;锁表风险评估(索引类迁移在表大小场景);回滚步骤验证。
### 测试用例(≥8)
1. test_migrate_clean — 干净迁移
2. test_validate_sql_pass — 验证 SQL
3. test_rollback_script — 回滚
4. test_lock_window_estimated — 锁窗口
5. test_checksum_ok
6. test_idempotent_rerun
7. test_no_legacy_touch — 不动历史
8. test_documented
### 收尾验证(本模块)
`mvn test` 相关类 + 巡检 SQL 在副本库执行通过。