github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/postgres/migrations/zz_migration.0008_add_ns_config_id.go (about) 1 package migrations 2 3 import ( 4 "context" 5 6 "github.com/jackc/pgx/v5" 7 ) 8 9 const ( 10 dropNSConfigPK = `ALTER TABLE namespace_config DROP CONSTRAINT IF EXISTS pk_namespace_config` 11 createNSConfigID = `ALTER TABLE namespace_config ADD COLUMN id BIGSERIAL PRIMARY KEY` 12 ) 13 14 func init() { 15 if err := DatabaseMigrations.Register( 16 "add-ns-config-id", 17 "add-unique-datastore-id", 18 noNonatomicMigration, 19 func(ctx context.Context, tx pgx.Tx) error { 20 if _, err := tx.Exec(ctx, dropNSConfigPK); err != nil { 21 return err 22 } 23 24 if _, err := tx.Exec(ctx, createNSConfigID); err != nil { 25 return err 26 } 27 28 return nil 29 }); err != nil { 30 panic("failed to register migration: " + err.Error()) 31 } 32 }