Skip to content

Make pgroll pull pull only migrations that don't exist in target directory #811

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

Merged
merged 2 commits into from
May 1, 2025

Conversation

andrew-farries
Copy link
Collaborator

Make the pgroll pull command pull only those migrations from the target database that are missing in the local directory.

This ensures that existing migrations in the local directory are not overwritten or modified when pulling from the target database, for example with formatting or order-of-field changes.

@github-actions github-actions bot temporarily deployed to Docs Preview April 30, 2025 09:22 Inactive
@andrew-farries andrew-farries marked this pull request as ready for review April 30, 2025 09:29
@andrew-farries andrew-farries requested a review from kvch April 30, 2025 09:29
@andrew-farries andrew-farries force-pushed the pull-only-new-migrations branch from 1b987a2 to fe22159 Compare May 1, 2025 07:41
@github-actions github-actions bot temporarily deployed to Docs Preview May 1, 2025 07:41 Inactive
Base automatically changed from pull-as-yaml to main May 1, 2025 07:53
`MissingMigrations` returns the slice of migrations that have been
applied to the target database but are missing from the local migrations
directory `dir`. If the local order of migrations does not match the
order of migrations in the schema history, an `ErrMismatchedMigration`
error is returned.
Make the `pgroll pull` command pull only those migrations from the
target database that are missing in the local directory.

This ensures that existing migrations in the local directory are not
overwritten or modified when pulling from the target database, for
example with formatting or order-of-field changes.
@andrew-farries andrew-farries force-pushed the pull-only-new-migrations branch from fe22159 to 067f019 Compare May 1, 2025 07:56
@github-actions github-actions bot temporarily deployed to Docs Preview May 1, 2025 07:56 Inactive
@andrew-farries andrew-farries merged commit dc239eb into main May 1, 2025
30 checks passed
@andrew-farries andrew-farries deleted the pull-only-new-migrations branch May 1, 2025 08:14
andrew-farries added a commit that referenced this pull request May 8, 2025
Ensure that when no migrations have been applied to the target database,
the `MissingMigrations` function returns an empty slice.

Also, update an error message in the pull command to be more accurate.

This should have been part of #811
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.

2 participants