Test #1
@@ -708,7 +708,41 @@ MySQL DDL 可能已隐式提交,不能假定整个文件自动回滚。按以
|
||||
| 代码读取新列,但结构与迁移都漏改 | 即使两条迁移路径相同,受影响的真实数据库读写验证仍失败,候选不得通过。 |
|
||||
| 迁移文件存在但漏改字段或必要种子 | 与应用预期结构或种子断言不符时阻断,不能仅凭存在迁移文件或历史校验成功放行。 |
|
||||
|
||||
## 17. 官方参考
|
||||
## 17. 当前 Jenkins 数据库检查边界
|
||||
|
||||
当前 Jenkins 的数据库门禁只做结构一致性检查,不做业务验收和迁移执行:
|
||||
|
||||
- 检查国内、海外初始化 SQL 约定的表和字段是否存在。
|
||||
- 只读查询 MySQL `information_schema`。
|
||||
- 缺表或缺字段时流水线失败,阻止继续构建/部署。
|
||||
- 不执行初始化 SQL、版本迁移 SQL、DML、造数、清理或回填。
|
||||
- 不检查业务表中是否有数据,也不检查数据内容和业务流程。
|
||||
|
||||
Jenkins 需要为每个环境配置一个文件型 Credentials:
|
||||
|
||||
```text
|
||||
SCHEMA_CHECK_READ_ONLY=true
|
||||
SCHEMA_CHECK_HOST=...
|
||||
SCHEMA_CHECK_PORT=3306
|
||||
SCHEMA_CHECK_USERNAME=...
|
||||
SCHEMA_CHECK_PASSWORD=...
|
||||
```
|
||||
|
||||
Credentials 名称约定:
|
||||
|
||||
- `firstleg-development-schema-readonly`
|
||||
- `firstleg-test-schema-readonly`
|
||||
- `firstleg-production-schema-readonly`
|
||||
|
||||
账号只授予目标实例的 `information_schema` 读取权限和连接所需权限,不授予建表、改表、删除、插入、更新或执行迁移权限。生产环境未配置对应 Credentials 前,结构门禁会失败,不会静默跳过。
|
||||
|
||||
脚本入口:
|
||||
|
||||
```text
|
||||
node scripts/database-schema-contract.mjs --region BOTH
|
||||
```
|
||||
|
||||
## 18. 官方参考
|
||||
|
||||
- [Flyway Versioned migrations](https://documentation.red-gate.com/fd/versioned-migrations-273973333.html)
|
||||
- [Flyway Repeatable migrations](https://documentation.red-gate.com/fd/repeatable-migrations-273973335.html)
|
||||
|
||||
Reference in New Issue
Block a user