Columns that are duplicated as part of an 'alter column' migration that changes the column type should not attempt to duplicate any DEFAULTs or CHECK constraints that are not compatible with the new column type.
will fail because the length_check constraint can't be applied to the new column type. A similar problem occurs if the column has a string default and the column type is changed to an integer.
As a first pass, it could be acceptable to simply drop defaults and constraints from columns that have their type changed; users can re-set them in the same 'alter column' operation that changes the type if they are intended to be preserved.
Ideally the default/constraints should be dropped if they are not compatible with the new column type and preserved otherwise.
Columns that are duplicated as part of an 'alter column' migration that changes the column type should not attempt to duplicate any
DEFAULT
s orCHECK
constraints that are not compatible with the new column type.Given this pair of migrations:
will fail because the
length_check
constraint can't be applied to the new column type. A similar problem occurs if the column has a string default and the column type is changed to an integer.As a first pass, it could be acceptable to simply drop defaults and constraints from columns that have their type changed; users can re-set them in the same 'alter column' operation that changes the type if they are intended to be preserved.
Ideally the default/constraints should be dropped if they are not compatible with the new column type and preserved otherwise.