github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/postgres/migrations/zz_migration.0013_drop_id_constraints.go (about) 1 package migrations 2 3 import ( 4 "context" 5 6 "github.com/jackc/pgx/v5" 7 ) 8 9 var dropIDConstraints = []string{ 10 `ALTER TABLE relation_tuple 11 DROP CONSTRAINT uq_relation_tuple_namespace, 12 DROP CONSTRAINT uq_relation_tuple_living, 13 ALTER COLUMN created_transaction DROP NOT NULL, 14 ALTER COLUMN deleted_transaction DROP NOT NULL`, 15 `ALTER TABLE namespace_config 16 DROP CONSTRAINT uq_namespace_living, 17 ALTER COLUMN created_transaction DROP NOT NULL, 18 ALTER COLUMN deleted_transaction DROP NOT NULL`, 19 `ALTER TABLE caveat 20 DROP CONSTRAINT uq_caveat_v1, 21 ALTER COLUMN created_transaction DROP NOT NULL, 22 ALTER COLUMN deleted_transaction DROP NOT NULL`, 23 } 24 25 func init() { 26 if err := DatabaseMigrations.Register("drop-id-constraints", "add-xid-constraints", 27 noNonatomicMigration, 28 func(ctx context.Context, tx pgx.Tx) error { 29 for _, stmt := range dropIDConstraints { 30 if _, err := tx.Exec(ctx, stmt); err != nil { 31 return err 32 } 33 } 34 35 return nil 36 }); err != nil { 37 panic("failed to register migration: " + err.Error()) 38 } 39 }