feat(pgsql): add support for concurrent index creation
* Implemented `Concurrent` field in index model * Updated index creation template to support `CREATE INDEX CONCURRENTLY` * Added tests for concurrent index creation in migration writer
This commit is contained in:
@@ -1097,8 +1097,13 @@ func (w *Writer) writeIndexes(schema *models.Schema) error {
|
||||
whereClause = fmt.Sprintf(" WHERE %s", index.Where)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w.writer, "CREATE %sINDEX IF NOT EXISTS %s\n",
|
||||
unique, indexName)
|
||||
concurrently := ""
|
||||
if index.Concurrent {
|
||||
concurrently = "CONCURRENTLY "
|
||||
}
|
||||
|
||||
fmt.Fprintf(w.writer, "CREATE %sINDEX %sIF NOT EXISTS %s\n",
|
||||
unique, concurrently, indexName)
|
||||
fmt.Fprintf(w.writer, " ON %s USING %s (%s)%s;\n\n",
|
||||
w.qualTable(schema.SQLName(), table.SQLName()), indexType, strings.Join(columnExprs, ", "), whereClause)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user