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
However the migration run keeps failing with error that says CREATE INDEX CONCURRENTLY cannot be run under transaction, despite the golang goose migration using GoMigrationNoTx.
Here is the code (using Postgres docs example) & error for reference:
import (
"database/sql""log""github.com/pressly/goose/v3"
)
const (
upSQL1=`CREATE INDEX measurement_usls_idx ON ONLY measurement (unitsales);`upSQL2=`CREATE INDEX CONCURRENTLY measurement_usls_200602_idx ON measurement_y2006m02 (unitsales);ALTER INDEX measurement_usls_idx ATTACH PARTITION measurement_usls_200602_idx;`downSQL=`DROP INDEX measurement_usls_idx`
)
funcinit() {
goose.AddMigrationNoTx(up, down)
}
funcup(db*sql.DB) error {
if_, err:=db.Exec(upSQL1); err!=nil {
returnerr
}
if_, err:=db.Exec(upSQL2); err!=nil {
returnerr
}
returnnil
}
funcdown(db*sql.DB) error {
if_, err:=db.Exec(downSQL); err!=nil {
returnerr
}
returnnil
}
Error: 2024/07/19 16:19:07 goose up: ERROR go migration no tx: "20240719161645_add_index_concurrently_example.go": failed to run go migration: ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block (SQLSTATE 25001)
Hello 👋
I'm trying to run goose migrations to create index on a partitioned postgres table. I'm basically following the Postgres docs example for adding index to an existing partitioned table: https://www.postgresql.org/docs/current/ddl-partitioning.html#DDL-PARTITIONING-DECLARATIVE-MAINTENANCE
However the migration run keeps failing with error that says
CREATE INDEX CONCURRENTLY
cannot be run under transaction, despite the golang goose migration usingGoMigrationNoTx
.Here is the code (using Postgres docs example) & error for reference:
Error:
2024/07/19 16:19:07 goose up: ERROR go migration no tx: "20240719161645_add_index_concurrently_example.go": failed to run go migration: ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block (SQLSTATE 25001)
I'm using
pressly/goose/[email protected]
.Any insights here would be appreciated, thanks!
The text was updated successfully, but these errors were encountered: