Repository navigation
test(postgres): CLI の --extension-mode verify が runMigrations まで届くことを、拡張が足りない DB で縛る - #2100
Merged
Merged
Conversation
…、拡張が足りない DB で縛る bin/migrate.ts に変異を当てたところ、解釈した extensionMode を runMigrations に渡さない形が、bin/migrate.ts を子プロセスで起動する試験4ファイル(25件)のどこでも赤にならなかった。--extension-mode を CLI 経由で試す試験が無く、verify の振る舞いは runMigrations を直接呼ぶ extension-mode.postgres.test.ts だけが見ていた。この変異では、verify を指定しても既定の create で流れ、足りない拡張を黙って作ってしまう。 約束はすでに書かれている。packages/postgres/README.md の CLI の節は『verify は何も発行せず pg_extension を読み、足りない拡張があれば拡張名と実行すべき SQL を示して失敗する(CREATE EXTENSION 権限を持たないロール向け)』と書いている。測定2と同じ『vector だけ無い』DB に対して CLI を起動し、終了コード1・stderr の SQL・vector も表も作らないことを見る。
takecchi
marked this pull request as ready for review
October 11, 2026 15:46
takecchi
enabled auto-merge (squash)
October 11, 2026 15:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
変異の記録の地図(#1963)で
packages/postgres/src/bin/migrate.tsは直接の記録が薄かった(PR #113 の変異8、#1116 の B10)。そこで変異を9形当てた。そのうち2形が生き残り、1形は約束が書かれていた。この PR はその1形を塞ぐ。生き残っていた変異
bin/migrate.tsで、解釈したextensionModeをrunMigrationsに渡さない(--extension-mode verifyを指定しても既定のcreateで流れる)。bin/migrate.tsを子プロセスで起動する試験4ファイル(migrate-cli-process・migrate-cli-schema・analyze-memories・analyze-memories-scope、25件)がすべて緑のままだった。--extension-modeを CLI 経由で試す試験が無く、verify の振る舞いはrunMigrationsを直接呼ぶextension-mode.postgres.test.tsだけが見ていた。(同じ回で生き残ったもう1形〔
finallyのpool.end()を消すと、終了がプールの idle 待ちで遅れるだけで、終了コードも出力も変わらない〕は、約束が書かれていないので、塞がずに別の Issue にまとめる。)約束はすでに書かれている
packages/postgres/README.mdの CLI の節は、--extension-mode <create|verify>について「verifyは何も発行せずpg_extensionを読み、足りない拡張があれば拡張名と実行すべき SQL を示して失敗する(CREATE EXTENSION権限を持たないロール向け)」と書いている(ADR 0093)。足したもの
extension-mode.postgres.test.ts(直列の群)に「測定2b」を足した。測定2と同じ「vector だけが無い」使い捨ての DB に対して CLI を--extension-mode verifyで起動し、次の3つを見る。CREATE EXTENSION IF NOT EXISTS vector;が出る。observationsの表も作られない。CLI の起動は
migrate-cli-schema.postgres.test.tsと同じ形(tsxでsrc/bin/migrate.tsを叩く。envはPATHと渡したものだけ)にした。変異で確かめたこと
手元の Postgres 17 + pgvector(5432 以外のポート)で確かめた。
extension-mode.postgres.test.ts7件すべて緑。extensionModeを渡さない: 足した「測定2b」だけが赤(終了コードが 0 のまま、vector が作られた)。