peterldowns / pgmigrate

a modern Postgres migrations CLI and library
MIT License
70 stars 3 forks source link

fix: allow SET search_path in migrations #7

Closed peterldowns closed 1 month ago

peterldowns commented 1 month ago

An issue was reported in https://github.com/peterldowns/pgmigrate/issues/4 that when a migration executed SET search_path TO ..., pgmigrate would subsequently break by failing to query against the table it uses to track which migrations have been applied:

"ERROR: relation \"pgmigrate_migrations\" does not exist (SQLSTATE 42P01)"

This PR fixes this problem by making the following changes to solve the problem:

To confirm the fix, I added unit tests for:

My overall recommendation is that if you're modifying connection-specific settings inside of a migration, you:

With this PR, pgmigrate's correctness will no longer be affected by the use of SET search_path TO ... in a migration.