You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR makes column duplication idempotent. Previously, if the same
column was altered in multiple operations in the same migration was not
working. The modified column could not be duplicated in the second
operation because the `ALTER TABLE` statement has failed. I added `IF
NOT EXISTS` to make the column creation idempotent. Now the column is
duplicated once, and other changes are added on top of it like setting
not null constraints, changing default values, etc.
The only edge case this PR does not address is when the column type is
changed in a later operation. This limitation can be worked around by
changing the type first in an `alter_column` operation and then adding
other changes to the migration. I do opted for this trade-off because it
would increase the complexity of the duplicator but not much of an
upside.
This is working:
```yaml
operations:
- alter_column:
name: mycol
type: text
- alter_column:
name: mycol
comment: nocomment
```
This is not supported:
```yaml
operations:
- alter_column:
name: mycol
comment: nocomment
- alter_column:
name: mycol
type: text
```
0 commit comments