github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/crdb/migrations/zz_migration.0002_add_transactions.go (about)

     1  package migrations
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/jackc/pgx/v5"
     7  )
     8  
     9  const (
    10  	createTransactions = `CREATE TABLE transactions (
    11      key VARCHAR PRIMARY KEY,
    12      timestamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL
    13  );`
    14  )
    15  
    16  func init() {
    17  	if err := CRDBMigrations.Register("add-transactions-table", "initial", noNonAtomicMigration, func(ctx context.Context, tx pgx.Tx) error {
    18  		_, err := tx.Exec(ctx, createTransactions)
    19  		return err
    20  	}); err != nil {
    21  		panic("failed to register migration: " + err.Error())
    22  	}
    23  }