-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add a pgroll pull
subcommand
#463
Conversation
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.
nice! should we add something to the docs?
6a1a8b0
to
e9979ed
Compare
7e67ccb
to
bc01a35
Compare
If we're happy that I've added documentation in the most recent commit on the branch. |
Define: * A new `Migration` type to represent a single migration in the migration history of a schema. * A `SchemaHistory` method on the `State` type to return all migrations applied to a schema in ascending timestamp order. * A `WriteToFile` method on the `Migration` type to write the migration to a file in the target directory, optionally prepending the filename with the migration timestamp.
Pull the migration history of a schema from the target database and write it to disk.
bc01a35
to
8c455f2
Compare
Awesome! I wonder if we should (not in this PR) update our examples folder to use these prefixes, while taking the numbers out of the migration names |
Taking migration numbers out of the migration names is a good idea I think 👍 |
Add a new
pgroll pull
command that pulls the complete migration history for a schema from themigrations
table in the target database and dumps the migrations to disk.Example
Given the migration history in
pgroll.migrations
after applying allexample/
migrations in this repo:Run:
This will pull all migrations from the
pgroll.migrations
table into themigrations/
directory:The optional
--with-prefixes
flag prefixes each migration name with its position in the schema history:This produces the following files:
The
--with-prefixes
flag ensures that files are sorted lexicographically by their time of application.