-
Notifications
You must be signed in to change notification settings - Fork 70
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
Ensure faithful duplication of columns for backfilling #227
Comments
This was referenced Jan 15, 2024
andrew-farries
added a commit
that referenced
this issue
Jan 15, 2024
#230) When duplicating a column for backfilling to add `NOT NULL` constraint, ensure that any foreign keys on the duplicated column are preserved. This fixes the issue where adding `NOT NULL` to an FK column would drop the FK from the column. This is part of a larger class of issues where duplicated columns are not faithfully preserving all properties of the original, tracked in #227.
andrew-farries
added a commit
that referenced
this issue
Jan 15, 2024
Preserve any foreign key constraints defined on columns when changing a column's type. Uses the `Duplicator` type added in #230 in the 'change type' operation to ensure that FK constraints are preserved when the column is duplicated for backfilling. #230 did the same thing for preserving FK constraints when a column has a `NOT NULL` constraint added. Part of #227
This was referenced Jan 15, 2024
andrew-farries
added a commit
that referenced
this issue
Jan 16, 2024
When duplicating a column for backfilling to change a column's type, ensure that any default on the column is preserved on the duplicated column. This fixes the issue where changing type would lose any `DEFAULT` defined on the column This is part of a larger class of issues where duplicated columns are not faithfully preserving all properties of the original, tracked in #227.
andrew-farries
added a commit
that referenced
this issue
Jan 16, 2024
Add a check to ensure that any `DEFAULT` on a column that is set to `NOT NULL` is preserved by the set `NOT NULL` operation. This already works as a consequence of earlier PRs for #227 but it's worth explicitly testing this behaviour.
andrew-farries
added a commit
that referenced
this issue
Jan 16, 2024
Preserve properties of columns when duplicating them for backfilling to add a`CHECK` constraint. Currently, the column properties that are preserved are: * `DEFAULT`s * foreign key constraints but this list will grow as more work is done on #227.
andrew-farries
added a commit
that referenced
this issue
Jan 16, 2024
Preserve properties of columns when duplicating them for backfilling to add a `UNIQUE` constraint. Currently, the column properties that are preserved are: * `DEFAULT`s * foreign key constraints but this list will grow as more work is done on #227.
andrew-farries
added a commit
that referenced
this issue
Jan 19, 2024
When duplicating a column for backfilling ensure that any `CHECK` constraints on the original column are re-created on the duplicated column. The `CHECK` constraint is initially created as `NOT VALID` then validated after migration completion. This is part of #227 As of this PR, column properties that are preserved when duplicating a column for backfilling are: * `DEFAULT` values * `FOREIGN KEY` constraints * `CHECK` constraints
andrew-farries
added a commit
that referenced
this issue
Jan 22, 2024
When duplicating a column for backfilling ensure that a `NOT NULL` attribute on the original column is re-created on the duplicated column. A `CHECK IS NOT NULL` constraint is initially created as `NOT VALID` then validated and converted to a `NOT NULL` column attribute after migration completion. This is part of #227 As of this PR, column properties that are preserved when duplicating a column for backfilling are: * `DEFAULT` values * `FOREIGN KEY` constraints * `CHECK` constraints * `NOT NULL` attributes
andrew-farries
added a commit
that referenced
this issue
Jan 22, 2024
…247) Add uniqueness information to each index recorded in `pgroll`'s internal schema representation. With the extra information, the entry for indexes in the schema representation now looks like: ```json "indexes": { "products_name_unique": { "name": "products_name_unique", "unique": true, }, "_pgroll_new_products_pkey": { "name": "_pgroll_new_products_pkey", "unique": true, } } ``` Having index uniqueness recorded in the schema representation will help with preserving uniqueness constraints on columns duplicated for backfilling (see #227).
andrew-farries
added a commit
that referenced
this issue
Jan 25, 2024
When duplicating a column for backfilling ensure that any `UNIQUE` constraints on the original column are re-created on the duplicated column. The `UNIQUE` constraint is initially created as an index concurrently and then converted to a constraint on migration completion. This is part of #227 As of this PR, column properties that are preserved when duplicating a column for backfilling are: * `DEFAULT` values * `FOREIGN KEY` constraints * `CHECK` constraints * `UNIQUE` constraints
andrew-farries
added a commit
that referenced
this issue
Jan 26, 2024
Ensure that properties of a column are preserved when duplicating a column for backfilling as part of the drop constraint operation. The properties that are preserved are: * `NOT NULL` * `DEFAULT` * `FOREIGN KEY` constraints * `CHECK` constraints * `UNIQUE` constraints Part of #227
andrew-farries
added a commit
that referenced
this issue
Mar 20, 2024
Ensure that column comments are preserved when a column is duplicated. Part of #227
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Various
pgroll
operations need to duplicate (and backfill) a column on migration start. The general pattern for these operations is:On migration start:
On migration complete:
Duplication of columns currently loses a lot of information about the source column. These means that when such a migration completes, information (such as constraints and defaults) on the original column is lost. Currently only the column's type is preserved.
The operations that duplicate a column are:
NOT NULL
.CHECK
constraint.FOREIGN KEY
constraintUNIQUE
constraintThe information that needs to be preserved when duplicating a column for backfilling is:
DEFAULT
.Support matrix
For each property of a column, p, and each operation type, o, we need to preserve property p when running operation o:
NOT NULL
NOT NULL
CHECK
constraintFK
constraintUNIQUE
constraintDEFAULT
[1] - It isn't currently possible to create unique constraints covering more than one column so it's not possible to test that existing
UNIQUE
constraints on a column are preserved when adding another.The text was updated successfully, but these errors were encountered: