github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/postgres/migrations/zz_migration.0004_add_transaction_timestamp_index.go (about)

     1  package migrations
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/jackc/pgx/v5"
     7  )
     8  
     9  const createIndexOnTupleTransactionTimestamp = `
    10  	CREATE INDEX ix_relation_tuple_transaction_by_timestamp on relation_tuple_transaction(timestamp);
    11  `
    12  
    13  func init() {
    14  	if err := DatabaseMigrations.Register("add-transaction-timestamp-index", "add-unique-living-ns", noNonatomicMigration, func(ctx context.Context, tx pgx.Tx) error {
    15  		_, err := tx.Exec(ctx, createIndexOnTupleTransactionTimestamp)
    16  		return err
    17  	}); err != nil {
    18  		panic("failed to register migration: " + err.Error())
    19  	}
    20  }