-
Notifications
You must be signed in to change notification settings - Fork 75
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
New command: bootstrap
#414
Conversation
Co-authored-by: Andrew Farries <[email protected]>
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.
Looks good 👍 Just a couple of small things.
|
||
for _, fileName := range migrationFiles { | ||
if err := runMigrationFromFile(cmd.Context(), m, fileName, true); err != nil { | ||
return fmt.Errorf("running migration file '%s': %w", fileName, err) |
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.
return fmt.Errorf("running migration file '%s': %w", fileName, err) | |
return fmt.Errorf("running migration file %q: %w", fileName, err) |
file, err := os.Open(fileName) | ||
if err != nil { | ||
return fmt.Errorf("opening migration file: %w", err) | ||
} |
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.
Now that this is a function I think that file.Close()
can be deferred here rather than called later.
Add a `pgroll migrate` subcommand. ## Documentation `pgroll migrate` applies all outstanding migrations from a source directory to the target database. Assuming that migrations up to and including migration `40_create_enum_type` from the [example migrations directory](https://github.com/xataio/pgroll/tree/main/examples) have been applied, running: ``` $ pgroll migrate examples/ ``` will apply migrations from `41_add_enum_column` onwards to the target database. If the `--complete` flag is passed to `pgroll migrate` the final migration to be applied will be completed. Otherwise the final migration will be left active (started but not completed). ## Notes: * If no migrations have yet been applied to the target database, `migrate` applies all of the migrations in the source directory. * This PR removes the `pgroll bootstrap` command (#414) as it is equivalent to running `pgroll migrate <directory> --complete` against a fresh database. Part of #446
This PR adds a new command called
bootstrap
. It runs all the migrations in the specified folder. Migration files are JSON files, ordered alphabetically.Help:
Closes #269