8000 Dont require database access to `pgroll latest --local` by andrew-farries · Pull Request #760 · xataio/pgroll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Dont require database access to pgroll latest --local #760

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 2 commits into from
Mar 28, 2025

Conversation

andrew-farries
Copy link
Collaborator

Ensure that the latest command does not require database access when the --local flag is provided.

In this case the command should act only locally, with the migrations on disk and not require a connection to the database.

The reason it used to require a DB connection was to support the --with-schema flag which took the schema name from an instantiated Roll instance. Change this so that the schema name is instead taken from the command line --schema flag (or the PGROLL_SCHEMA env var) directly instead.

Fixes #726

@github-actions github-actions bot temporarily deployed to Docs Preview March 27, 2025 12:35 Inactive
@andrew-farries andrew-farries marked this pull request as ready for review March 27, 2025 12:38
@andrew-farries andrew-farries requested review from kvch and Copilot March 27, 2025 12:38
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request decouples database access from the local "latest" command by converting LatestVersionLocal into a standalone function that operates only on local migration files.

  • Removed the receiver from LatestVersionLocal and updated its usage in tests.
  • Updated the latest command implementation to use separate helper functions for local and remote version retrieval.
  • Adjusted error messages in the command for clearer context.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/roll/latest_test.go Updated tests to use the new standalone LatestVersionLocal
pkg/roll/latest.go Converted LatestVersionLocal from a method to a function
cmd/latest.go Refactored command logic to handle local and remote modes
Comments suppressed due to low confidence (1)

cmd/latest.go:60

  • Consider wrapping the error returned by os.Stat with additional context (e.g., "failed to stat directory") to improve clarity compared to the previous version.
return "", err

@andrew-farries andrew-farries force-pushed the stop-require-db-access-for-latest-cmd branch from 27badf0 to 670a27d Compare March 27, 2025 13:40
@github-actions github-actions bot temporarily deployed to Docs Preview March 27, 2025 13:40 Inactive
@andrew-farries
Copy link
Collaborator Author

rebased to resolve a merge conflict

Copy link
Contributor
@kvch kvch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smallest nit of my life

`LatestVersionLocal` is a function that doesn't need to be a method of the
`Roll` type. It can be a package-level function instead.
Ensure that the `latest` command does not require database access when
the `--local` flag is provided. In this case the command should act
locally, with the migrations on disk and not require a connection to
the database.
@andrew-farries andrew-farries force-pushed the stop-require-db-access-for-latest-cmd branch from 670a27d to 4f7373a Compare March 28, 2025 06:55
@github-actions github-actions bot temporarily deployed to Docs Preview March 28, 2025 06:56 Inactive
@andrew-farries andrew-farries merged commit 221f1bd into main Mar 28, 2025
30 checks passed
@andrew-farries andrew-farries deleted the stop-require-db-access-for-latest-cmd branch March 28, 2025 07:02
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.

pgroll latest --local needs db access?
2 participants
0