-
Notifications
You must be signed in to change notification settings - Fork 106
[baseline] Add pgroll baseline
command
#832
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
Redefine the `migration_type` column to allow a `baseline` migration type.
The functionality was duplicated.
Make `writeMigrationToFile` return the path of the created file on success.
Run `make generate`.
5ee7dac
to
45420b1
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.
The code and the highlevel functionality looks good to me. I have one minor usability improvement ideas for a later PR:
It would be nice if pgroll
would create the local baseline migration after the baselining was successful. I got an error from baseline
a few times, and the migration file was there in my migrations folder, even though the database was not baselined.
Ensure that the migration file is removed if the baseline creation fails.
Resolved in 71459ab. The migration file is cleaned up if creating the baseline in the target database fails. |
Add a new
pgroll baseline
command topgroll
that allows users to establish a baseline migration from an existing database schema.Usage
Run:
This does two things:
pgroll.migrations
with a new migration type ofbaseline
. The migration JSON is empty and theresulting_schema
field contains the schema at the time the command was run.migrations/01_initial_version.yaml
file for the user to populate (likely with the use ofpg_dump
).Features
pgroll baseline <version> <target directory>
command (currently hidden)baseline
migration in thepgroll.migrations
table that captures the current schema state without applying changes.Implementation Details
Roll.CreateBaseline
method and corresponding testsState.CreateBaseline
method for writingbaseline
migrations topgroll.migrations
The
pgroll baseline
command is currently hidden. Un-hiding the command will happen when thepull
andmigrate
commands are made baseline-aware.This is the first part of #364