Support altering primary key columns that are not included in FK constraints #930
+190
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the past
pgroll
could not preserve primary key constraint on altered columns. Instead the primary key constraint was down-graded to a unique, not null constraint. Now the PK constraint is not removed during completing the migration.Futhermore, if the table had rows,
pgroll
could not backfill rows.pgroll
"updates" the primary keys of the backfilled table to trigger backfilling existing columns. Previously, finding the identity columns returned the duplicated column__pgroll_new_id
instead of the correctid
. In this case we need the current PK, so we can copy the correct values to the new column.I opened follow-up issue to support altering mutiple columns of the same composite key in the same migration: #930
Support for alter PK columns that are part of FK constraints is in a follow-up PR: #935
Closes #888