Skip to content

Remove redundant pgroll.internal parameter #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025

Conversation

andrew-farries
Copy link
Collaborator

The pgroll.internal custom parameter never worked, because it was set outside of a transaction using SET LOCAL, so it had no effect other than spitting out a warning to the Postgres logs.

The pgroll.internal parameter was meant to be used to ensure that DDL done by pgroll operations was not captured as an inferred migration. However, the raw_migration function also uses the is_active_migration_period function for this same purpose, so the pgroll.internal parameter was redundant even if it had worked.

The `pgroll.internal` custom param never worked, because it was
set outside of a transaction using `SET LOCAL`, so it had no effect
other than spitting out a warning to the Postgres logs.

The `pgroll.internal` parameter was meant to be used to ensure that
DDL done by `pgroll` operations was not captured as an `inferred`
migration. However, the `raw_migration` function also uses the
`is_active_migration_period` function for this same purpose, so the
`pgroll.internal` parameter was redundant even if it had worked.
@github-actions github-actions bot temporarily deployed to Docs Preview May 12, 2025 07:37 Inactive
@andrew-farries andrew-farries marked this pull request as ready for review May 12, 2025 07:40
@andrew-farries andrew-farries requested a review from kvch May 12, 2025 07:42
@andrew-farries andrew-farries merged commit 2982cf7 into main May 12, 2025
30 checks passed
@andrew-farries andrew-farries deleted the remove-redundant-set-local branch May 12, 2025 09:39
andrew-farries added a commit that referenced this pull request Jun 12, 2025
Set a session-level setting `pgroll.internal` to `TRUE` on connections
used by `pgroll` (`pgroll` uses two connections, one to execute
migrations and one for its internal state).

Use the `pgroll.internal` setting to prevent schema changes made by
`pgroll` itself being captured by the raw_migration() event trigger
function.

DDL changes made in schema `s` are already ignored by `raw_migration()`
if there is an active migration period in progress for schema `s`. The
change in this commit ensures that *all* DDL changes in *all* schema at
*all* times made by `pgroll` are ignored by `raw_migration()`, including
version schema creation and the creation of views within those schema.

This reverts PR #823 which removed a `pgroll.internal` setting that was
set using `SET LOCAL` outside a transaction block. That PR assumeed that
setting `pgroll.internal` with `SET LOCAL` outside a transaction had no
effect, but it did have an effect (the setting was set to an empty
string, which was sufficient given how it was used in`raw_migration()`).
This PR uses the same setting but sets it with `SET` (instead of `SET
LOCAL`) to make it more obvious what is happening.
andrew-farries added a commit that referenced this pull request Jun 12, 2025
Set a session-level setting `pgroll.internal` to `TRUE` on connections
used by `pgroll` (`pgroll` uses two connections, one to execute
migrations and one for its internal state).

Use the `pgroll.internal` setting to prevent schema changes made by
`pgroll` itself being captured by the raw_migration() event trigger
function.

DDL changes made in schema `s` are already ignored by `raw_migration()`
if there is an active migration period in progress for schema `s`. The
change in this commit ensures that *all* DDL changes in *all* schema at
*all* times made by `pgroll` are ignored by `raw_migration()`, including
version schema creation and the creation of views within those schema.

This reverts PR #823 which removed a `pgroll.internal` setting that was
set using `SET LOCAL` outside a transaction block. That PR assumeed that
setting `pgroll.internal` with `SET LOCAL` outside a transaction had no
effect, but it did have an effect (the setting was set to an empty
string, which was sufficient given how it was used in`raw_migration()`).
This PR uses the same setting but sets it with `SET` (instead of `SET
LOCAL`) to make it more obvious what is happening.
andrew-farries added a commit that referenced this pull request Jun 13, 2025
Set a session-level setting `pgroll.internal` to `TRUE` on connections
used by `pgroll` (`pgroll` uses two connections, one to execute
migrations and one for its internal state).

Use the `pgroll.internal` setting to prevent schema changes made by
`pgroll` itself being captured by the `raw_migration()` event trigger
function.

DDL changes made in schema `s` are already ignored by `raw_migration()`
if there is an active migration period in progress for schema `s`. The
change in this commit ensures that *all* DDL changes in *all* schema at
*all* times made by `pgroll` are ignored by `raw_migration()`, including
version schema creation and the creation of views within those schema.

This reverts PR #823 which removed
a `pgroll.internal` setting that was set using `SET LOCAL` outside a
transaction block. That PR assumed that setting `pgroll.internal` with
`SET LOCAL` outside a transaction had no effect, but it did have an
effect (the setting was set to an empty string, which was sufficient
given how it was used in`raw_migration()`). This PR uses the same
setting but sets it with `SET` (instead of `SET LOCAL`) to make it more
obvious what is happening.

Add a test to verify that version schema creation does not create
inferred migrations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants