Skip to content
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 latest command #469

Merged
merged 4 commits into from
Nov 25, 2024
Merged

Add a pgroll latest command #469

merged 4 commits into from
Nov 25, 2024

Conversation

andrew-farries
Copy link
Collaborator

@andrew-farries andrew-farries commented Nov 19, 2024

Add a pgroll latest command to show the latest version in either the target database or a local directory of migration files.

Documentation

pgroll latest prints the latest schema version in either the target database or a local directory of migration files.

By default, pgroll latest prints the latest version in the target database. Use the --local flag to print the latest version in a local directory of migration files instead.

In both cases, the --with-schema flag can be used to prefix the latest version with the schema name.

Database

Assuming that the example migrations have been applied to the public schema in the target database, running:

$ pgroll latest 

will print the latest version in the target database:

45_add_table_check_constraint

The exact output will vary as the examples/ directory is updated.

Local

Assuming that the example migrations are on disk in a directory called examples, running:

$ pgroll latest --local examples/

will print the latest migration in the directory:

45_add_table_check_constraint

The exact output will vary as the examples/ directory is updated.


Part of #446

@andrew-farries andrew-farries marked this pull request as ready for review November 19, 2024 08:50
docs/README.md Outdated Show resolved Hide resolved
@andrew-farries andrew-farries force-pushed the pgroll-latest-command branch 2 times, most recently from ca52794 to 1f7f2bc Compare November 22, 2024 12:49
@andrew-farries
Copy link
Collaborator Author

I've updated the command so that it can now retrieve the latest schema version from either the target database or a local migrations directory. The PR description and documentation has been updated with the new behaviour.

I think this addresses the confusion about what the command is operating on that @kvch raised in #469 (comment).

Retrieve the latest migration version from the local filesystem and the
remote schema respectively.
Retrieve the latest schema version from either the target database or a
local directory.
@andrew-farries andrew-farries merged commit eaaabf9 into main Nov 25, 2024
27 checks passed
@andrew-farries andrew-farries deleted the pgroll-latest-command branch November 25, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants