-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add relationship index storing caveat to migrations
- Loading branch information
1 parent
fc0d606
commit 821f59b
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
internal/datastore/crdb/migrations/zz_migration.0007_add_relation_index_storing_caveat.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package migrations | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
) | ||
|
||
const ( | ||
addRelationshipIndexStoringCaveatQuery = ` | ||
CREATE INDEX idx_relationship_caveat_storing ON relation_tuple (namespace, relation, object_id, userset_relation) STORING (caveat_name, caveat_context); | ||
` | ||
) | ||
|
||
func init() { | ||
err := CRDBMigrations.Register("add-relationship-index-storing-caveat", "add-relationship-counters-table", addRelationshipIndexStoringCaveat, noAtomicMigration) | ||
if err != nil { | ||
panic("failed to register migration: " + err.Error()) | ||
} | ||
} | ||
|
||
func addRelationshipIndexStoringCaveat(ctx context.Context, conn *pgx.Conn) error { | ||
if _, err := conn.Exec(ctx, addRelationshipIndexStoringCaveatQuery); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |