-
Notifications
You must be signed in to change notification settings - Fork 106
Improve error messages when pgroll init
has not been run
#745
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
Conversation
4875f20
to
9ee630f
Compare
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.
Pull Request Overview
This PR improves the error messaging for commands that require pgroll initialization by verifying whether pgroll is initialized before performing operations.
- Introduces a new error variable (errPGRollNotInitialized) with a clear error message in cmd/errors.go.
- Adds initialization checks using IsInitialized in multiple CLI command implementations.
- Implements a new test in pkg/state/state_test.go to verify the behavior of IsInitialized.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
cmd/errors.go | Adds a new error variable with a clear error message. |
pkg/state/state.go | Introduces/duplicates the IsInitialized method for checking. |
pkg/state/state_test.go | Adds test to verify initialization behavior. |
cmd/status.go | Adds initialization check before showing status. |
cmd/start.go | Adds initialization check before starting migrations. |
cmd/complete.go | Adds initialization check before completing migrations. |
cmd/rollback.go | Adds initialization check before rolling back migrations. |
cmd/migrate.go | Adds initialization check before migrating. |
cmd/analyze.go | Adds initialization check before analyzing schema. |
cmd/pull.go | Adds initialization check before pulling schema history. |
cmd/latest.go | Adds initialization check before fetching the latest migration. |
Return true iff `pgroll` has been initialized in the database.
Ensure that the `State.IsInitialized` method returns `true` after the state has been initialized and `false` before it has been initialized.
9ee630f
to
fc09a60
Compare
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.
Pull Request Overview
This PR improves the CLI error messages for commands that require a prior initialization via pgroll init
. The changes add a new error variable for uninitialized state, enhance multiple command flows to check initialization before proceeding, and include a test to verify the behavior of the initialization check.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
cmd/errors.go | Introduces a new error variable for uninitialized state with an error message. |
pkg/state/state_test.go | Adds a test validating that IsInitialized returns the expected values before and after Init. |
pkg/state/state.go | Adds the IsInitialized method to check whether the state has been initialized. |
cmd/complete.go | Implements an initialization check before completing a migration. |
cmd/start.go | Implements an initialization check before starting a migration. |
cmd/status.go | Implements an initialization check before returning the status. |
cmd/rollback.go | Implements an initialization check before rolling back a migration. |
cmd/analyze.go | Implements an initialization check before analyzing the schema. |
cmd/migrate.go | Implements an initialization check before running migrations. |
cmd/pull.go | Implements an initialization check before pulling the migration history. |
cmd/latest.go | Implements an initialization check before obtaining the latest version. |
Improve the error messages displayed by the CLI when attempting to run commands that require
pgroll init
to have been run.Old example of
pgroll start
beforepgroll init
:New error message:
The same change is applied to all other commands that need to run against an initialized database.
Closes #723