清设计痕迹(卖源码): 删 84 项跟踪文档/spec/plan/prompt+5 支纯文档用例+4 支没人接进闸门的审计工具,9 支混合用例只摘读 docs 的那几段
V143–V152 的迁移契约用例逐支过:87 例 0 红(mvn -o test 实跑)。混合类里钉"迁移文件本体"的断言全部保留, 只删/只切按路径读 docs 的方法;两支 scannedSignaturesAreActuallyPresent 是防恒绿的自检, 它自检的对象(回滚补丁)已随文档出仓,那几行留在类里就变成给空断言背书,所以一并摘掉。 删除面 241 个唯一副本的归档在 D:\archive\design-scrub-2026-10-11\,逐个 sha256 回读。
This commit is contained in:
@@ -28,7 +28,6 @@ class CompanyMigrationV143Test {
|
||||
private static final Path ROOT = Path.of(System.getProperty("user.dir"));
|
||||
private static final Path DB_DIR = ROOT.resolve("src/main/resources/db");
|
||||
private static final Pattern VERSION_FILE = Pattern.compile("^V(\\d+)(?:_(\\d+))?__.*\\.sql$");
|
||||
private static final String ROLLBACK_RELATIVE = "docs/rollback-V143-company.sql";
|
||||
|
||||
// ---------------------------------------------------------------- 取文件
|
||||
|
||||
@@ -374,23 +373,6 @@ class CompanyMigrationV143Test {
|
||||
*/
|
||||
@Test
|
||||
void rollbackLivesOutsideFlywayScanPath() throws IOException {
|
||||
Path rollback = ROOT.resolve(ROLLBACK_RELATIVE);
|
||||
assertTrue(Files.isRegularFile(rollback),
|
||||
"回滚脚本应存在于 " + ROLLBACK_RELATIVE + "(Flyway 扫描路径之外),否则事故时无从回退");
|
||||
|
||||
String rb = normalize(stripComments(Files.readString(rollback, StandardCharsets.UTF_8)));
|
||||
assertMatches(rb, "ALTER TABLE `users`\\s+DROP INDEX `idx_users_company_id`", "回滚应删掉索引");
|
||||
assertMatches(rb, "DROP COLUMN `company_id`", "回滚应删掉 users.company_id");
|
||||
assertMatches(rb, "DROP TABLE (IF EXISTS )?`company`", "回滚应删掉 company 表");
|
||||
assertTrue(rb.contains("flyway_schema_history") && rb.contains("143"),
|
||||
"回滚必须清掉 flyway_schema_history 里 V143 的记录,否则重装 jar 时 Flyway 认为已应用而跳过");
|
||||
assertTrue(rb.contains("admin_companies"), "回滚应删掉后台「公司管理」菜单行");
|
||||
|
||||
assertTrue(rawMigration().contains(ROLLBACK_RELATIVE),
|
||||
"V143 头注释的「回滚步骤」必须点名该脚本,否则值班的人找不到它");
|
||||
assertFalse(rawMigration().contains("db/V144"),
|
||||
"回滚不得写成版本化迁移 V144:Flyway 会在下次启动时自动执行它,静默撤销 V143");
|
||||
|
||||
for (Path f : versionFiles()) {
|
||||
String name = f.getFileName().toString().toLowerCase();
|
||||
assertFalse(name.contains("rollback"), "Flyway 扫描路径内不得出现回滚迁移: " + f.getFileName());
|
||||
@@ -402,35 +384,4 @@ class CompanyMigrationV143Test {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点:docs/migration-inventory.md 的数字没跟着改。
|
||||
* 下一个人按文档里的"取号起点"取号就会撞号(Flyway 启动失败),或以为 V143 还没被占用。
|
||||
*/
|
||||
@Test
|
||||
void inventoryDocTracksTheNewMigration() throws IOException {
|
||||
Path doc = ROOT.resolve("docs/migration-inventory.md");
|
||||
assertTrue(Files.isRegularFile(doc), "盘点文档应存在");
|
||||
String text = Files.readString(doc, StandardCharsets.UTF_8);
|
||||
|
||||
List<Path> files = versionFiles();
|
||||
int maxOnDisk = files.stream().mapToInt(CompanyMigrationV143Test::versionOf).max().orElse(0);
|
||||
|
||||
assertTrue(text.contains(migration().getFileName().toString()),
|
||||
"盘点文档应记录最新迁移文件名 " + migration().getFileName());
|
||||
|
||||
Matcher count = Pattern.compile("版本化迁移文件数:\\*\\*(\\d+)\\*\\*").matcher(text);
|
||||
assertTrue(count.find(), "盘点文档应给出版本化迁移文件数");
|
||||
assertEquals(files.size(), Integer.parseInt(count.group(1)),
|
||||
"文档记录的迁移文件数与磁盘不符");
|
||||
|
||||
Matcher range = Pattern.compile("整数版本范围:\\*\\*V1\\.\\.V(\\d+)\\*\\*").matcher(text);
|
||||
assertTrue(range.find(), "盘点文档应给出整数版本范围");
|
||||
assertEquals(maxOnDisk, Integer.parseInt(range.group(1)),
|
||||
"文档记录的整数版本上界与磁盘不符");
|
||||
|
||||
Matcher next = Pattern.compile("从 \\*\\*V(\\d+)\\*\\* 起取号").matcher(text);
|
||||
assertTrue(next.find(), "盘点文档应给出取号起点");
|
||||
assertEquals(maxOnDisk + 1, Integer.parseInt(next.group(1)),
|
||||
"取号起点必须 = 磁盘最大版本 + 1,否则会撞号或留洞");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user