Skip to content

Commit

Permalink
Merge pull request #2143 from authzed/add-pg-watch-api-index
Browse files Browse the repository at this point in the history
adds postgres index to support efficient querying via Watch API
  • Loading branch information
vroldanbet authored Nov 26, 2024
2 parents 7ff8fb1 + 8ed00e6 commit 96b3ec5
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package migrations

import (
"context"
"fmt"

"github.com/jackc/pgx/v5"
)

const addWatchAPIIndexToRelationTupleTable = `CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_watch_index ON relation_tuple (created_xid);`

func init() {
if err := DatabaseMigrations.Register("add-watch-api-index-to-relation-tuple-table", "add-metadata-to-transaction-table",
func(ctx context.Context, conn *pgx.Conn) error {
if _, err := conn.Exec(ctx, addWatchAPIIndexToRelationTupleTable); err != nil {
return fmt.Errorf("failed to add watch API index to relation tuple table: %w", err)
}
return nil
},
noTxMigration); err != nil {
panic("failed to register migration: " + err.Error())
}
}

0 comments on commit 96b3ec5

Please sign in to comment.