-
Notifications
You must be signed in to change notification settings - Fork 516
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
[/v4] - Add CLI and cleanup #497
Merged
Merged
Conversation
This file contains 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
Cleaned up the CLI a bit, A database migration tool that simplifies the process of versioning, applying, and rolling back
schema changes in a controlled and organized way.
USAGE
goose [flags] <command>
COMMANDS
create Create a new .go or .sql migration file
down Migrate database down to the previous version
down-to Migrate database down to, but not including, a specific version
env Print environment variables
fix Apply sequential numbering to existing timestamped migrations
redo Roll back the last appied migration and re-apply it
status List applied and pending migrations
up Migrate database to the most recent version
up-by-one Migrate database up by one version
up-to Migrate database up to, and including, a specific version
version Print the current version of the database
SUPPORTED DATABASES
postgres mysql sqlite3
redshift tidb mssql
clickhouse vertica
FLAGS
--allow-missing Allow missing (out-of-order) migrations
--dbstring Database connection string
--dir Directory with migration files (default: "./migrations")
--exclude Exclude migrations by filename, comma separated
--help Display help
--json Format output as JSON
--lock-mode Set a lock mode [none, advisory-session] (default: "none")
--no-versioning Do not store version info in the database, just run the migrations
--table Table name to store version info (default: "goose_db_version")
--v Turn on verbose mode
--version Display the version of goose currently installed
ENVIRONMENT VARIABLES
GOOSE_DBSTRING Database connection string, lower priority than --dbstring
GOOSE_DIR Directory with migration files, lower priority than --dir
EXAMPLES
goose --dbstring="postgres://user:password@localhost:5432/dbname?sslmode=disable" status
goose --dbstring="mysql://user:password@/dbname?parseTime=true" status
GOOSE_DIR=./examples/sql-migrations GOOSE_DBSTRING="sqlite:./test.db" goose status
GOOSE_DBSTRING="clickhouse://user:password@localhost:9000/clickdb" goose status
LEARN MORE
Use 'goose <command> --help' for more information about a command.
Read the manual at https://pressly.github.io/goose/
|
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.
This PR adds the CLI component back to the
goose
command. We're using the https://github.com/peterbourgon/ff (and ffcli) to compose the CLI.There are also a few improvements, refactors and cleanups to the library itself because now we're starting to use it as if the consumer would.
There are a few breaking changes here, and will need to revisit those before merging:
down-to 0
or.DownTo(ctx, 0)
, and no point having 2 ways to do the same thingGOOSE_DRIVER
evn variable, we can instead derive the intended dialect from theGOOSE_DBSTRING
or--dbstring
. E.g.,With the help of https://github.com/xo/dburl we can parse the database connection string. This should greatly simplify CLI usage.
GOOSE_MIGRATION_DIR
to justGOOSE_DIR
MigrationResult
likely needs to surface error(s) per migrationThis one is especially important because when running
goose up
we may apply N migrations but fail for any number of reasons, this should be available when printing out or outputting JSON. Remember, we don't print within the goose package anymore, so this needs to be surfaced back to the user.