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

Fix previous version detection in the presence of inferred DDL migrations #197

Merged
merged 4 commits into from
Nov 3, 2023

Conversation

andrew-farries
Copy link
Collaborator

Update the definition of the previous_version function to use a recursive CTE to find the first non-'inferred' parent of the current version.

This requires adding a new column to the pgroll.migrations table to record whether a migration is a pgroll migration or an inferred DDL change made outside of pgroll.

Together, this means that the previous version schema is removed correctly when there have been inferred DDL changes between the current and previous pgroll migration.

Fixes #196

Add a column to record the kind of migration: 'pgroll' or 'inferred'.
Ensure that the previous version schema is removed when completing a
migration. Separate the two cases:

* The previous migration was a `pgroll` migration.
* The previous migration was an inferred DDL migration.
Use a recursive CTE to find the first non-'inferred' parent of the current
version.
@andrew-farries andrew-farries merged commit c029d5e into main Nov 3, 2023
22 checks passed
@andrew-farries andrew-farries deleted the fix-ddl-migration-previous-version branch November 3, 2023 07:08
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.

Inferred DDL migrations break previous version detection
2 participants