github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/postgres/migrations/zz_migration.0006_add_gc_index.go (about) 1 package migrations 2 3 import ( 4 "context" 5 6 "github.com/jackc/pgx/v5" 7 ) 8 9 const ( 10 createDeletedTransactionIndex = `CREATE INDEX CONCURRENTLY ix_relation_tuple_by_deleted_transaction ON relation_tuple (deleted_transaction)` 11 ) 12 13 func init() { 14 if err := DatabaseMigrations.Register("add-gc-index", "change-transaction-timestamp-default", 15 func(ctx context.Context, conn *pgx.Conn) error { 16 // CREATE INDEX CONCURRENTLY cannot run inside a transaction block (SQLSTATE 25001) 17 _, err := conn.Exec(ctx, createDeletedTransactionIndex) 18 return err 19 }, noTxMigration, 20 ); err != nil { 21 panic("failed to register migration: " + err.Error()) 22 } 23 }