Skip to content

Support creating multiple indexes concurrently in a single migration postgresql  #284

@julieqiu

Description

@julieqiu

Describe the Bug
I'd like to add multiple indexes to my postgresql schema in a single migration file.

Steps to Reproduce

  1. My migrations look like '...'
CREATE INDEX CONCURRENTLY idx_my_table_col1 ON my_table(col1);
CREATE INDEX CONCURRENTLY idx_my_table_col2 ON my_table(col2);
  1. I ran migrate with the following options '....'
migrate -source file:migrations -database "postgres://localhost:5432/my-database?sslmode=disable" up
  1. See error
 (details: pq: CREATE INDEX CONCURRENTLY cannot run inside a transaction block)

Expected Behavior
I expected the migration to succeed and add both indexes. This migration does succeed if I only try to create one index at a time and have two sequential migration files with the following contents:

CREATE INDEX CONCURRENTLY idx_my_table_col1 ON my_table(col1);
```
```
CREATE INDEX CONCURRENTLY idx_my_table_col2 ON my_table(col2);
```

**Migrate Version**
v4.6.2

**Loaded Source Drivers**
Source drivers: github, github-ee, gitlab, go-bindata, godoc-vfs, gcs, file, s3

**Loaded Database Drivers**
Database drivers: cockroachdb, crdb-postgres, postgres, redshift, postgresql, spanner, sqlserver, cassandra, clickhouse, cockroach, mongodb, mysql, stub


**Go Version**
go version go1.13 darwin/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions