postgres: fail when the search path no longer resolves to the migrations table - #4397
Closed
AbhinavMir wants to merge 1 commit into
Closed
postgres: fail when the search path no longer resolves to the migrations table#4397AbhinavMir wants to merge 1 commit into
AbhinavMir wants to merge 1 commit into
Conversation
…ons table The Postgres migrator refers to the migrations table by an unqualified name. Postgres resolves that name through `search_path`, which contains `"$user"` by default. Postgres ignores a search path entry that names no existing schema. A migration that creates a schema with the name of the database role therefore makes that schema shadow `public` in all later sessions. The migrator then creates a second, empty migrations table and applies every migration again. `ensure_migrations_table()` now reads the effective search path with `current_schemas(false)`. It then finds the schemas that hold the table. The table can exist in the search path, but not in the schema that an unqualified name resolves to. In that condition, migration stops with the new `MigrateError::AmbiguousMigrationsTable`. The check does not run for a table name that the user set, because that user controls how the name resolves.
Author
|
Hi, sorry for opening this PR! Looking back at some other issues, it seems like the team might not be open to AI-assisted PRs, and I respect it! I used Claude Opus 4.8 to build this PR. Closing it now! Reference: #199 (comment) |
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.
#3523