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
Fix adding extra unique constraint to columns that are already unique (#579)
Previously, `pgroll` failed to add unique constraint to columns that
were already included in another unique constraint in some cases. The
bug is triggered when the name of the column that is not yet unique
comes earlier than the already unique column.
The error message we get:
```
Failed to complete migration: unable to execute complete operation: failed to create unique constraint from index "_pgroll_dup_fruits_name_key": pq: index "fruits_name_key" does not exist
```
The issue is during renaming phase. `pgroll` checked if the unique index
is duplicated (thus, has to be renamed). Then `pgroll` checked if the
column (being renamed) is included in the index. If it was part of the
index, `pgroll` renamed the index to the final name. If that unique
index happened to be a unique constraint `pgroll` transformed the index
into a unique constraint. Good, yay.
However, if the unique index is duplicated, but the column (that was
being renamed) was not part of the index definition, `pgroll` did not
rename the index. If this unique index is a constraint, `pgroll` still
tried to transform the index with the original name into a constraint.
So we got the error message above.
Now this problem is fixed.
Related to #227
0 commit comments