Prevent Sync failure with non-regular indexes on Postgres

When dropping indexes in Postgres if the index is non-regular we
should not attempt to regularise the index name as it is already correct.

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
Andrew Thornton 2022-09-02 20:44:29 +01:00
parent c3bce55620
commit af675201d3
No known key found for this signature in database
GPG Key ID: 3CDE74631F13A748
1 changed files with 3 additions and 4 deletions

View File

@ -1030,11 +1030,10 @@ func (db *postgres) DropIndexSQL(tableName string, index *schemas.Index) string
tableParts := strings.Split(strings.Replace(tableName, `"`, "", -1), ".")
tableName = tableParts[len(tableParts)-1]
if !strings.HasPrefix(idxName, "UQE_") &&
!strings.HasPrefix(idxName, "IDX_") {
if index.Type == schemas.UniqueType {
if index.IsRegular {
if index.Type == schemas.UniqueType && !strings.HasPrefix(idxName, "UQE_") {
idxName = fmt.Sprintf("UQE_%v_%v", tableName, index.Name)
} else {
} else if index.Type == schemas.IndexType && !strings.HasPrefix(idxName, "IDX_") {
idxName = fmt.Sprintf("IDX_%v_%v", tableName, index.Name)
}
}