feat(公司tab): 批次 2/3/4 再接 8 页,注册表收到 16 页——用户页回流 company_id 按新边界改写反向钉
「切 tab 数据还一样」的根因一直是分母小于现实:批次 1 只登记 8 页,本轮按控制方 三次点名扩到 16 页(company-scope.ts 是唯一清单,routes.ts 的 companyScoped 逐页对平)。 批次 2(五页 ASIN 中心):去重总数据 / 不符合ASIN / 查询ASIN / 最低价ASIN / 商品类目。 批次 3(两页店铺中心):撞款监控、店铺数据记录。这两页没有归属列可筛,归属口径是 「本公司账号名下的店铺」——后端由 DataReadScope 推公司 → 成员账号 → biz_shop_manage. created_by_id,前端只把 activeId 当 company_id 送下去。空成员集必须交空集合,绝不能 退化成 null(null 在这里=全量,那样第二家会看到全部数据)。 批次 4(用户管理):后端早就认 company_id(只对站点超管生效,公司超管恒锁本公司), 断的是前端——UserListQuery 里连这个字段都没有,三家 tab 看的是同一份全量列表。 三处口径改动,逐条说明: 1)company-user-list.test.ts 的反向钉被改写。2026-10-04 定案把公司维度从用户页整体摘掉, 那条钉的原文是「列表查询/筛选/行渲染不允许出现公司维度」。控制方 2026-10-05 明确要 用户管理区分公司 tab,所以钉的边界收窄成两半:渲染层(行级公司列、「所属公司」标签、 筛选状态、顶栏公司名)仍不得回流;请求层的 company_id 是这次加回来的,尺子换成 「取值口唯一」——页面每处 companyId 都必须等于 companyTab.requestCompanyId,且 normalizeUserPageParams/toUserListQuery 两只白名单构造器体内不许出现公司值。 新增一支行为钉:往归一化里传 companyId 必须被丢掉,这是 users.ts 读原始入参的全部理由 (写成 normalized.companyId 时 TS 照样绿、运行时恒 undefined)。 2)align-dup-console 那条 watch 看守的 token 扩到含 reload。变异自证里「删掉 void loadConsole()」当场全绿:体里的清筛选项守住了,重新取数那半没人守。批次 3/4 三对 token 一起写到 reload 为止(批次 1/2 的老条目不动)。 3)公司管理页补正/反向两把尺子:company-config-entry-super-only 新增「吃公司 tab 的页面 集合恰好等于 COMPANY_SCOPED_PAGES 的 pageFiles」——按代码真值比,不按清单比,所以 清单不改一字而往 CompaniesPage.vue 里塞 store 也会红。谓词带括号,否则 import 行也算消费者。 菜单权限(admin_columns)本轮不动:MenusPage 只消费 /api/admin/permission-menus 这一份全局 菜单字典,切 tab 一样是数据本身全局,不是筛选坏了。真问题在写侧——PermissionMenuService create/update/delete 只有 ensureAdminOperatorIfPresent(isAdmin 即放行),公司管理员改的是 全平台的菜单行。收窄为仅站点超管 vs 给 permission_menu 加归属列,两种改法代价差一个量级, 留给控制方定档。 护栏:G1 发送口 22 个 / 页面分组 17、watch 体看守 10 对、operation-guide 的 tab 文案 15 页 (撞款监控是显式豁免,另有一条自检盯「豁免落空」)。 变异自证 12/12 全杀(前端 10 + 公司管理反向钉 2),分母钉死在 27 例。 门禁:后端全量 3823 例 / 0 失败 / 0 错误 / 7 skipped,BUILD SUCCESS;admin-frontend-vue 1741 例 / 0 红;vue-tsc rc=0。首轮后端 4 红是另一路 task_partial 改动与本轮编译抢跑, 单跑 13 例已绿,本笔不含他们的任何文件。 未上线:jar 与 admin-vue 都没出包,V147 未在生产执行。
This commit is contained in:
+2
-1
@@ -346,7 +346,8 @@ class CompanyScopeMigrationV145Test {
|
||||
Path doc = ROOT.resolve("docs/migration-inventory.md");
|
||||
String text = raw(doc);
|
||||
assertTrue(text.contains(migration().getFileName().toString()), "盘点文档应记录 V145 文件名");
|
||||
assertTrue(text.contains("V146"), "盘点文档应把取号起点推到 V146");
|
||||
// 取号起点不在这里钉:原先写死 contains("V146"),而 V146 真落地后它只因文档里还留着
|
||||
// 那个文件名而巧合为真。派生尺子=MigrationInventoryTest#inventoryDocNumberingStartIsMaxPlusOne。
|
||||
assertTrue(text.contains("1833593804"), "盘点文档应记下 V144 的生产存量校验和");
|
||||
assertTrue(text.contains("1539570901"), "盘点文档应保留 V143 的生产存量校验和");
|
||||
}
|
||||
|
||||
@@ -142,6 +142,35 @@ class MigrationInventoryTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 盘点文档的「起取号」必须是目录当前最大值 + 1 —— 派生式,不写死数字。
|
||||
*
|
||||
* <p>破坏点两条:加了 V148 却没改文档 ⇒ 后来人照文档取号撞上刚落地的 V148(改已应用版本=两台都起不来);
|
||||
* 文档把号位改超前 ⇒ 1..max 留洞,{@link #integerVersionsSequentialFromOne} 会红。
|
||||
* 各迁移自己的审计类原先把「起点推到 V14x」写死在 assertTrue 里,那种断言在 V14x 真落地那天就
|
||||
* 只因文档里还留着同名文件而恒为真(基线自己过期)。尺子挪到这里、只对「本轮目录」求值,
|
||||
* 才不需要每加一版都有人记得回来改一个数字。</p>
|
||||
*/
|
||||
@Test
|
||||
void inventoryDocNumberingStartIsMaxPlusOne() throws IOException {
|
||||
String text = Files.readString(Path.of(System.getProperty("user.dir"), "docs/migration-inventory.md"));
|
||||
String marker = "从 **V";
|
||||
int hits = 0, cursor = -1;
|
||||
while ((cursor = text.indexOf(marker, cursor + 1)) >= 0) hits++;
|
||||
assertEquals(1, hits, "「从 **V<号>** 起取号」应只有一条可解析的取号规则," + hits + " 条=后来人不知道按哪条取号");
|
||||
|
||||
int digitsFrom = text.indexOf(marker) + marker.length();
|
||||
int digitsTo = digitsFrom;
|
||||
while (digitsTo < text.length() && Character.isDigit(text.charAt(digitsTo))) digitsTo++;
|
||||
assertTrue(digitsTo > digitsFrom, "取号规则里 V 之后必须是数字(解析不出=本用例恒绿)");
|
||||
int stated = Integer.parseInt(text.substring(digitsFrom, digitsTo));
|
||||
|
||||
int maxMajor = parseAll(versionFiles()).stream().filter(Migration::isInteger)
|
||||
.mapToInt(Migration::major).max().orElse(0);
|
||||
assertEquals(maxMajor + 1, stated,
|
||||
"取号起点应是目录最大值 V" + maxMajor + " 的下一号,实际文档写 V" + stated);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checksumStableAcrossReads() throws IOException {
|
||||
Map<String, String> first = sha256All(versionFiles());
|
||||
|
||||
+285
@@ -0,0 +1,285 @@
|
||||
package com.nanri.aiimage.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* V147({@code biz_product_category} 加 company_id + 唯一键按公司放宽)的文件审计。
|
||||
* 需求:2026-10-05 控制方点名「商品类目切换 tab 数据显示还一样」;设计见迁移文件头 §1–§6。
|
||||
*
|
||||
* <p>为什么必须单独有一支:V143/V144/V145/V146 每版都有自己的审计类,而 V147 落盘后
|
||||
* 只有消费侧的两支 service/controller 用例——迁移文件本身(加列形状、哨兵回填、换键顺序、
|
||||
* 可重跑守卫、回滚补丁、盘点文档取号起点)在 3788 例里一处都没被钉。也就是说
|
||||
* 「把 ADD COLUMN 改成可空」「把 DROP INDEX 排到 ADD UNIQUE KEY 前面」「把哨兵改成 -1」
|
||||
* 都能全绿进 jar,而这三条里前两条是运行期静默错、第三条是让第 2 家看不见 18 个内置类目。</p>
|
||||
*
|
||||
* <p>本仓 pom 无 H2、无 testcontainers,迁移跑不起来,所以文件审计是唯一能守住的层,
|
||||
* 与 {@link CompanyScopeMigrationV145Test} 同口径:断言打在剥掉注释后的可执行 SQL 上,
|
||||
* {@code stripComments}/{@code normalize} 逐字沿用那一份实现(注释里的 {@code --} 与字符串字面量里的
|
||||
* {@code --} 是两件事,另写一版简化实现会让断言打在残缺 SQL 上)。</p>
|
||||
*/
|
||||
class ProductCategoryMigrationV147Test {
|
||||
|
||||
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 String TABLE = "biz_product_category";
|
||||
private static final String NEW_KEY = "uk_company_category_key";
|
||||
private static final String OLD_KEY = "uk_product_category_key";
|
||||
|
||||
// ---------------------------------------------------------------- 取文件
|
||||
|
||||
private static List<Path> versionFiles() throws IOException {
|
||||
try (Stream<Path> s = Files.list(DB_DIR)) {
|
||||
return s.filter(p -> p.getFileName().toString().matches("^V\\d+(?:_\\d+)?__.*\\.sql$"))
|
||||
.sorted()
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
private static Path migration() throws IOException {
|
||||
List<Path> hits = versionFiles().stream()
|
||||
.filter(p -> p.getFileName().toString().startsWith("V147__"))
|
||||
.toList();
|
||||
assertEquals(1, hits.size(),
|
||||
"V147 必须恰好一个迁移文件,实际 " + hits.size() + " 个(0 个=类目还没落公司口径;2 个=撞号,Flyway 启动即失败)");
|
||||
return hits.get(0);
|
||||
}
|
||||
|
||||
private static String raw(Path file) throws IOException {
|
||||
return Files.readString(file, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private static String statements() throws IOException {
|
||||
return normalize(stripComments(raw(migration())));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------ SQL 预处理
|
||||
// 与 CompanyScopeMigrationV145Test / CompanyMigrationV144Test 逐字同实现,理由见类注释。
|
||||
|
||||
private static String stripComments(String sql) {
|
||||
StringBuilder out = new StringBuilder(sql.length());
|
||||
int i = 0;
|
||||
while (i < sql.length()) {
|
||||
char c = sql.charAt(i);
|
||||
if (c == '\'') {
|
||||
int end = i + 1;
|
||||
while (end < sql.length()) {
|
||||
if (sql.charAt(end) == '\'') {
|
||||
if (end + 1 < sql.length() && sql.charAt(end + 1) == '\'') {
|
||||
end += 2;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
out.append(sql, i, Math.min(end + 1, sql.length()));
|
||||
i = end + 1;
|
||||
continue;
|
||||
}
|
||||
if (c == '-' && i + 1 < sql.length() && sql.charAt(i + 1) == '-') {
|
||||
while (i < sql.length() && sql.charAt(i) != '\n') {
|
||||
i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (c == '/' && i + 1 < sql.length() && sql.charAt(i + 1) == '*') {
|
||||
int end = sql.indexOf("*/", i + 2);
|
||||
i = end < 0 ? sql.length() : end + 2;
|
||||
continue;
|
||||
}
|
||||
out.append(c);
|
||||
i++;
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
private static String normalize(String sql) {
|
||||
return sql.replaceAll("\\s+", " ").trim();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ 用例
|
||||
|
||||
/** 破坏点:取到已应用的 146(原地改=两台都起不来),或把这一版编成 V148(V147 就被跳开,类目列永远不加)。 */
|
||||
@Test
|
||||
void migrationIsVersionedOneFourSeven() throws IOException {
|
||||
Path file = migration();
|
||||
Matcher m = Pattern.compile("^V(\\d+)(?:_\\d+)?__").matcher(file.getFileName().toString());
|
||||
assertTrue(m.find(), "文件名应能抽出整数版本:" + file.getFileName());
|
||||
assertEquals(147, Integer.parseInt(m.group(1)), "本迁移必须是 V147(V146 之后的下一号)");
|
||||
assertTrue(file.getFileName().toString().matches("^V147__[A-Za-z0-9_.-]+\\.sql$"),
|
||||
"命名应 V147__<snake 描述>.sql:" + file.getFileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点:把列加成可空 ⇒ 混合版本窗口里旧 jar 写进来的类目行 company_id 为 NULL,
|
||||
* 而 {@code readCompanyId} 返回 null 的分支是「不裁剪」,这些行会同时出现在每一家的树上;
|
||||
* 把 {@code MODIFY COLUMN} 写进来 ⇒ 重建表并按"当时的列默认值"物化历史行(§6 明令禁止)。
|
||||
* DEFAULT 1 必须**在场**:它是同批旧 jar 唯一能插进这张表的通道,摘它的是下一版而不是这一版。
|
||||
*/
|
||||
@Test
|
||||
void addsANotNullCompanyColumnWithInstantAndNeverModify() throws IOException {
|
||||
String sql = statements();
|
||||
assertTrue(sql.contains("ALTER TABLE `" + TABLE + "` ADD COLUMN `company_id` bigint NOT NULL DEFAULT 1"),
|
||||
TABLE + " 应一次到位加成 NOT NULL DEFAULT 1(DEFAULT 只为同批旧 jar 存在,摘除是下一版)");
|
||||
assertTrue(sql.contains("ALGORITHM = INSTANT"),
|
||||
"加列必须钉 INSTANT:前提不成立时 MySQL 直接报 1846,而不是悄悄退化成 COPY(§4)");
|
||||
assertFalse(sql.contains("MODIFY COLUMN"), "禁 MODIFY COLUMN——它会重建表并按当时的默认值物化历史行(§6)");
|
||||
assertFalse(sql.contains("ALTER TABLE `" + TABLE + "` DROP COLUMN"),
|
||||
"本版本不删列:归属信息一旦删掉就无法再分清是第几家公司建的(§2)");
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点 ①:删掉那条 UPDATE ⇒ 18 行内置节点留在公司 1,第 2 家的类目树只剩自己自建的 0 行,
|
||||
* 「切 tab 这一页空白」就是这么来的。破坏点 ②:哨兵值写成 1 或 -1 ⇒ 要么和真实公司 1 混在一起
|
||||
* (第 1 家的自建类目被当成平台内置、别家也能改),要么被 {@code requireCompanyId} 的 <=0 判定挡在门外。
|
||||
* 破坏点 ③:这张表除这一条 UPDATE 外不该有任何别的 DML——没有账号列,任何"按人回填"都是编数据。
|
||||
*/
|
||||
@Test
|
||||
void builtinRowsGoToSentinelZeroAndThatIsTheOnlyDml() throws IOException {
|
||||
String sql = statements();
|
||||
Pattern dml = Pattern.compile("\\b(UPDATE|INSERT|DELETE|REPLACE)\\b", Pattern.CASE_INSENSITIVE);
|
||||
Matcher d = dml.matcher(sql);
|
||||
int hits = 0;
|
||||
while (d.find()) {
|
||||
hits++;
|
||||
}
|
||||
assertEquals(1, hits, TABLE + " 的可执行段应当只有那一条回填 UPDATE,实际命中 " + hits + " 条 DML 关键字");
|
||||
assertTrue(sql.contains("SET `company_id` = 0"), "内置节点应挂哨兵公司 0");
|
||||
assertTrue(sql.contains("WHERE `is_builtin` = 1"),
|
||||
"驱动条件必须是 is_builtin 而不是 category_key 白名单:V50 的种子后来被删过(种子 24 行、今天 18 行)");
|
||||
assertTrue(sql.contains("AND `company_id` = 1"),
|
||||
"回填必须自带 company_id = 1 限定 ⇒ DDL 段失败后 repair 重跑时这条是 no-op(§可重跑性)");
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点:把 DROP 旧键排到 ADD 新键之前 ⇒ 中间那一刻这张表没有任何唯一键在守并发,
|
||||
* 两个账号同时建同名类目就会落两行;把新键的第二列换掉或把 company_id 挪到第二位 ⇒
|
||||
* {@code WHERE company_id IN (0, ?)} 走不到这个键,而 §4 明写「不加单独的列索引」,
|
||||
* 于是这一页的每次列表查询都退化成扫描。
|
||||
*/
|
||||
@Test
|
||||
void swapsTheUniqueKeyCompanyFirstAndAddsBeforeDropping() throws IOException {
|
||||
String sql = statements();
|
||||
int add = sql.indexOf("ADD UNIQUE KEY `" + NEW_KEY + "` (`company_id`, `category_key`)");
|
||||
int drop = sql.indexOf("DROP INDEX `" + OLD_KEY + "`");
|
||||
assertTrue(add >= 0, "新唯一键应是 (company_id, category_key) 这个顺序,实际串:" + sql.substring(0, Math.min(sql.length(), 400)));
|
||||
assertTrue(drop >= 0, "旧的全平台唯一键 " + OLD_KEY + " 必须被删掉,否则第 2 家在同一个父级下重名建类会撞 1062");
|
||||
assertTrue(add < drop, "换键顺序必须先 ADD 后 DROP:中间任一步失败都至少还有一个唯一键在守并发");
|
||||
assertEquals(2, count(sql, "ALGORITHM = INPLACE, LOCK = NONE"),
|
||||
"两条索引操作各钉一次 INPLACE + LOCK = NONE(§4:这张表 412 行,但仍不许默默锁表)");
|
||||
assertFalse(sql.contains("ADD INDEX") || sql.contains("ADD KEY"),
|
||||
"不该再单开列索引:新唯一键的最左前缀就是 company_id,再开一个就是 V139 那轮清掉的冗余形状");
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点:把两条 DDL 的存在性守卫删掉 ⇒ DDL 不进事务,中途失败后 repair 重跑会撞
|
||||
* 1060(重复列)/1061(重复键)而彻底起不来,只能人工进库删。
|
||||
* 计数取 3 而不是「大于 0」:本文件的可执行段恰好查三次 information_schema
|
||||
* (一次列、两次索引),少一次就是一处守卫没了。
|
||||
*/
|
||||
@Test
|
||||
void bothDdlStatementsAreGuardedByExistenceChecks() throws IOException {
|
||||
String sql = statements();
|
||||
assertEquals(3, count(sql, "information_schema"),
|
||||
"可执行段应查 3 次 information_schema(列存在 + 新键存在 + 旧键存在),实际次数见消息");
|
||||
assertTrue(sql.contains("COLUMN_NAME = 'company_id'"), "加列的守卫要按列名查");
|
||||
assertTrue(sql.contains("INDEX_NAME = '" + NEW_KEY + "'"), "加新键的守卫要按新键名查");
|
||||
assertTrue(sql.contains("INDEX_NAME = '" + OLD_KEY + "'"), "删旧键的守卫要按旧键名查");
|
||||
assertTrue(count(sql, "PREPARE stmt FROM @sql") == 3 && count(sql, "EXECUTE stmt") == 3,
|
||||
"三段条件 DDL 都必须走 PREPARE/EXECUTE(MySQL 不能在 IF 里直接写 DDL)");
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点:回滚脚本没跟着写 ⇒ 出问题只能手工现编 SQL,而"漏删 flyway_schema_history 的 147 行"
|
||||
* 这一手会让重装带 V147 的 jar 时 Flyway 判定已应用直接跳过——列和键都不重建,
|
||||
* 而 Java 侧实体照常读写 company_id,运行期报 Unknown column。
|
||||
*
|
||||
* <p>与 V145 那份同形:{@code DROP COLUMN} 必须留在注释里由人工解开(这张表没有账号列,
|
||||
* 删了就再也分不出哪一家),而"回滚不得版本化"由 {@link CompanyScopeMigrationV145Test
|
||||
* #rollbackStaysOutOfFlywayScanAndCoversTheHistoryRow} 那支按全目录扫,本类不重复实现,
|
||||
* 只在下面那支按文件名把本迁移钉进盘点文档(号位起点由 {@link MigrationInventoryTest
|
||||
* #inventoryDocNumberingStartIsMaxPlusOne} 派生式盯着)。</p>
|
||||
*/
|
||||
@Test
|
||||
void rollbackIsAHumanPatchOutsideTheFlywayScanPath() throws IOException {
|
||||
Path doc = ROOT.resolve("docs/rollback-V147-product-category-company.sql");
|
||||
assertTrue(Files.isRegularFile(doc), "V147 的人工回滚补丁必须存在:" + doc);
|
||||
String whole = raw(doc);
|
||||
assertTrue(whole.contains("flyway_schema_history"), "回滚必须写明删 version='147' 的历史行");
|
||||
String executable = normalize(stripComments(whole));
|
||||
assertTrue(executable.contains("ADD UNIQUE KEY `" + OLD_KEY + "` (`category_key`)"),
|
||||
"回滚要把全平台唯一键加回来(新键是旧键的严格放宽,回填那一刻必然不撞)");
|
||||
assertTrue(executable.contains("DROP INDEX `" + NEW_KEY + "`"), "回滚要摘掉按公司的新唯一键");
|
||||
assertTrue(executable.indexOf("ADD UNIQUE KEY") < executable.indexOf("DROP INDEX"),
|
||||
"回滚也必须先加旧键后删新键,理由与迁移同一半:中间时刻不许没有唯一键");
|
||||
assertFalse(executable.contains("DROP COLUMN"),
|
||||
"DROP COLUMN 是丢归属信息的动作,必须留在注释里由人工解开");
|
||||
assertFalse(executable.contains("MODIFY COLUMN"), "同上:任何时候不要写 MODIFY COLUMN");
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点:V147 的 DEFAULT 1 没进启动期哨兵清单 ⇒ "下一次记得摘"这件事没人喊,
|
||||
* 而巡检按 {@code COMPANY_DEFAULT_STILL_PRESENT} 这条 ASCII 签名 grep docker logs。
|
||||
*/
|
||||
@Test
|
||||
void startupSentinelWatchesTheProductCategoryColumn() throws IOException {
|
||||
Path guard = ROOT.resolve("src/main/java/com/nanri/aiimage/modules/company/service/CompanyDefaultGuard.java");
|
||||
assertTrue(Files.isRegularFile(guard), "启动期 DEFAULT 哨兵应存在:" + guard);
|
||||
String text = raw(guard);
|
||||
assertTrue(text.contains("COMPANY_DEFAULT_STILL_PRESENT"), "哨兵标记串必须保持 ASCII 原样(巡检按它 grep)");
|
||||
assertTrue(text.contains("'" + TABLE + "'"),
|
||||
"探针 SQL 的 IN 列表要含 " + TABLE + "(不在 IN 里就查不到这一列,哨兵等于没探)");
|
||||
assertTrue(text.contains("\"" + TABLE + "\""),
|
||||
"WATCHED_TABLES 清单要含 " + TABLE + "(查到了却不在清单里,就没人去喊那条签名)");
|
||||
}
|
||||
|
||||
/**
|
||||
* 破坏点:盘点文档没跟着改 ⇒ 下一个人按"取号起点"取号就撞号,或者按"最新版本"漏掉本文件。
|
||||
* 这里把 V145/V146/V147 三个文件名同时钉住:只钉最新一条会重演
|
||||
* 「推进第 11 行时把 V145 挤掉」那一次回归(本轮真实发生过)。
|
||||
* 号位起点不写在这里——写死 "V148" 到 V148 落地那天就自己过期,改由
|
||||
* {@link MigrationInventoryTest#inventoryDocNumberingStartIsMaxPlusOne} 按「本轮目录最大值 + 1」求值。
|
||||
*/
|
||||
@Test
|
||||
void inventoryDocTracksV147AndTheEarlierFilenamesTogether() throws IOException {
|
||||
Path doc = ROOT.resolve("docs/migration-inventory.md");
|
||||
String text = raw(doc);
|
||||
for (String keep : List.of("V145__brand_dedupe_company_scope.sql",
|
||||
"V146__users_expires_at_admin_expiry.sql",
|
||||
migration().getFileName().toString())) {
|
||||
assertTrue(text.contains(keep), "盘点文档应逐字保留文件名:" + keep);
|
||||
}
|
||||
assertTrue(text.contains("1833593804"), "盘点文档应记下 V144 的生产存量校验和");
|
||||
}
|
||||
|
||||
/** 自检:本用例集扫的是真文件,且 normalize 后仍能命中关键串(0 命中的断言是恒绿的)。 */
|
||||
@Test
|
||||
void scannedSignaturesAreActuallyPresent() throws IOException {
|
||||
String sql = statements();
|
||||
assertTrue(sql.length() > 800, "剥注释后的 SQL 太短,说明预处理把内容吃掉了:" + sql.length());
|
||||
assertTrue(count(sql, "ALTER TABLE") >= 3 && count(sql, "information_schema") > 0,
|
||||
"关键签名 0 命中=预处理或文件路径坏了,本类的断言全部不可信");
|
||||
}
|
||||
|
||||
private static int count(String haystack, String needle) {
|
||||
int n = 0, i = haystack.indexOf(needle);
|
||||
while (i >= 0) {
|
||||
n++;
|
||||
i = haystack.indexOf(needle, i + needle.length());
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user