From 13e7709145958bb4baaaf4765ee68ebc7179e46b Mon Sep 17 00:00:00 2001 From: Ivan Ryabov Date: Mon, 13 Jan 2025 10:11:31 +1100 Subject: [PATCH] PG index options handle CONCURRENT option separately --- migrator.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/migrator.go b/migrator.go index 2293a7c..a3416fc 100644 --- a/migrator.go +++ b/migrator.go @@ -130,7 +130,8 @@ func (m Migrator) CreateIndex(value interface{}, name string) error { } createIndexSQL += "INDEX " - if strings.TrimSpace(strings.ToUpper(idx.Option)) == "CONCURRENTLY" { + hasConcurrentOption := strings.TrimSpace(strings.ToUpper(idx.Option)) == "CONCURRENTLY" + if hasConcurrentOption { createIndexSQL += "CONCURRENTLY " } @@ -142,7 +143,7 @@ func (m Migrator) CreateIndex(value interface{}, name string) error { createIndexSQL += " ?" } - if idx.Option != "" { + if idx.Option != "" && !hasConcurrentOption { createIndexSQL += " " + idx.Option }