-
Notifications
You must be signed in to change notification settings - Fork 105
Add documentation for the pgroll latest url
command
#928
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
Conversation
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
a97e606
to
6b5c628
Compare
6b5c628
to
fd24f13
Compare
fd24f13
to
a68d8c1
Compare
a68d8c1
to
1c10463
Compare
One file per subcommand.
1c10463
to
cd9dace
Compare
divyenduz
approved these changes
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
kvch
approved these changes
Jun 24, 2025
andrew-farries
added a commit
that referenced
this pull request
Jun 30, 2025
Add a `pgroll latest url` command to the CLI. The command returns a Postgres connection string with the `search_path` option set to the latest version schema name. This can be used to set the connection string for an application to work with the latest schema version. By default, with no arguments, `pgroll latest url` will use the connection string set via the global `--postgres-url` (or `PGROLL_PG_URL` env var). If an argument is given to `pgroll latest url`, the command will use that as the base connection string instead. The resulting connection string sets the `search_path` by setting the `options` parameter in the URL query string: ``` options=-c search_path='public_01_some_migration' ``` As described in the Postgres [libpq documentation](https://www.postgresql.org/docs/current/libpq-connect.html). ## Examples With no connection string argument, use the connection string used by `pgroll` itself: ```bash $ export PGROLL_PG_URL=postgres://postgres:postgres@localhost:5432?sslmode=disable $ pgroll latest url postgres://postgres:postgres@localhost:5432?options=-c%20search_path%3Dpublic_05_some_migration&sslmode=disable ``` Take the connection string as a command line argument: ```bash $ pgroll latest url postgres://me:mypass@example.com:5432 postgres://me:mypass@example.com:5432?options=-c%20search_path%3Dpublic_05_some_migration ``` Like `pgroll latest migration` and `pgroll latest schema`, `pgroll latest url` takes a `--local/-l` flag to take the latest version schema name from a directory of migration files rather than the target database. This allows for a connection string to be constructed offline, without having to lookup the latest version schema name in the target database. ```bash $ pgroll latest url --local migrations/ postgres://me:mypass@localhost:5432 postgres://me:mypass@localhost:5432?options=-c%20search_path%3Dpublic_05_some_migration ``` The resulting connection string can be used directly as an argument to tools like `psql` that accept a connection string on the command line: ```bash psql $(pgroll . latest url) ``` Documentation for the new command is added in #928 Closes #900
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.
Add documentation for the
pgroll latest url
command added in #927.pgroll latest
command into one page per subcomandpgroll latest url
command.Part of #900