test(environment): 1058 migration three-state verification on real postgres

- fresh database, legacy upgrade (rows get one-shot access key, online=false),
  repeat startup idempotence
- 1058 revised before any database applied it: drop dead token column,
  provision access_key via temporary default so non-empty legacy tables upgrade
- immutable-migration rule skips PR-local migrations until merged; after merge
  the lock applies again
This commit is contained in:
2026-10-09 08:45:54 +08:00
parent a34ba07d5b
commit 7df8762db3
3 changed files with 104 additions and 1 deletions
@@ -34,6 +34,11 @@ func TestMigrationFilesAreImmutableAfterIntroduction(t *testing.T) {
t.Skipf("no introducing commit found for %s", repoFile)
}
firstCommit := strings.SplitN(introduced, "\n", 2)[0]
// 引入 commit 尚未进入主线的迁移(同 PR 内迭代)允许修正内容;
// 合入主线后此跳过失效,规则恢复锁死。
if gitOutput(t, "merge-base", "--is-ancestor", firstCommit, "origin/main") == "" {
t.Skipf("%s introduced in %s which is not merged into origin/main; PR-local migrations may still be revised", repoFile, firstCommit)
}
original := gitOutput(t, "show", firstCommit+":"+repoFile)
current, err := os.ReadFile(file)
if err != nil {