Skip to content

Add a global --use-version-schema flag to the pgroll CLI #919

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 6 commits into from
Jun 18, 2025

Conversation

andrew-farries
Copy link
Collaborator

Add a global --use-version-schema option to the pgroll CLI to enable/disable the creation and maintenance of version schema by pgroll operations.

Usage

Apply a migrations/ directory without creating any version schema:

$ pgroll migrate migrations/ --complete --use-version-schema=false

Start a migration without creating a version schema:

$ pgroll start migrations/01_some_migration.yaml --use-version-schema=false

The option can also be set by specifying:

PGROLL_USE_VERSION_SCHEMA=false

as an environment variable.


Fixes #872

@github-actions github-actions bot temporarily deployed to Docs Preview June 17, 2025 15:53 Inactive
@andrew-farries andrew-farries marked this pull request as ready for review June 18, 2025 06:47
@andrew-farries andrew-farries requested a review from kvch June 18, 2025 06:48
@andrew-farries andrew-farries force-pushed the latest-version-remote-with-no-version-schema branch from cece35e to e553c34 Compare June 18, 2025 07:41
@andrew-farries andrew-farries force-pushed the add-use-version-schema-flag branch from 38f57d7 to 671792b Compare June 18, 2025 07:41
@github-actions github-actions bot temporarily deployed to Docs Preview June 18, 2025 07:41 Inactive
@andrew-farries andrew-farries force-pushed the latest-version-remote-with-no-version-schema branch from e553c34 to 8e58110 Compare June 18, 2025 10:49
@andrew-farries andrew-farries force-pushed the add-use-version-schema-flag branch from 671792b to ae269bd Compare June 18, 2025 10:49
@github-actions github-actions bot temporarily deployed to Docs Preview June 18, 2025 10:49 Inactive
Base automatically changed from latest-version-remote-with-no-version-schema to main June 18, 2025 10:54
Check that the method correctly reports whether the roll instance was
configured to use the version schema or not.
The flag controls whether the `start`, `migrate`, `complete` and
`rollback` commands should attempt to interact with version schema.
Should make sense for both local and remote usage.
Change the message printed by `pgroll start/migrate` when the
`--use-version-schema` flag is set to `false` to avoid confusion.
@andrew-farries andrew-farries force-pushed the add-use-version-schema-flag branch from ae269bd to f0e43df Compare June 18, 2025 10:54
@github-actions github-actions bot temporarily deployed to Docs Preview June 18, 2025 10:55 Inactive
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/xataio/pgroll/cmd 0.00% (ø)
github.com/xataio/pgroll/cmd/flags 0.00% (ø)
github.com/xataio/pgroll/pkg/roll 79.94% (+0.06%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/xataio/pgroll/cmd/flags/flags.go 0.00% (ø) 8 (+1) 0 8 (+1)
github.com/xataio/pgroll/cmd/latest_migration.go 0.00% (ø) 30 0 30
github.com/xataio/pgroll/cmd/latest_schema.go 0.00% (ø) 30 0 30
github.com/xataio/pgroll/cmd/root.go 0.00% (ø) 59 (+3) 0 59 (+3)
github.com/xataio/pgroll/cmd/start.go 0.00% (ø) 50 (+3) 0 50 (+3)
github.com/xataio/pgroll/pkg/roll/roll.go 76.60% (+0.51%) 47 (+1) 36 (+1) 11 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/xataio/pgroll/pkg/roll/execute_test.go

@andrew-farries andrew-farries merged commit 1fb32c8 into main Jun 18, 2025
30 checks passed
@andrew-farries andrew-farries deleted the add-use-version-schema-flag branch June 18, 2025 11:05
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.

Provide an option to not create version schema
2 participants