-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce caveat support in CockroachDB
- Loading branch information
1 parent
ef2738c
commit 7f6b4d4
Showing
12 changed files
with
385 additions
and
119 deletions.
There are no files selected for viewing
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
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
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
34 changes: 34 additions & 0 deletions
34
internal/datastore/crdb/migrations/zz_migration.0004_add_caveats.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,34 @@ | ||
package migrations | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v4" | ||
) | ||
|
||
const ( | ||
createCaveatTable = `CREATE TABLE caveat ( | ||
name VARCHAR NOT NULL, | ||
definition BYTEA NOT NULL, | ||
timestamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL, | ||
CONSTRAINT pk_caveat_v1 PRIMARY KEY (name) | ||
);` | ||
|
||
addRelationshipCaveatContext = `ALTER TABLE relation_tuple | ||
ADD COLUMN caveat_name VARCHAR, | ||
ADD COLUMN caveat_context JSONB;` | ||
) | ||
|
||
func init() { | ||
if err := CRDBMigrations.Register("add-caveats", "add-metadata-and-counters", noNonatomicMigration, func(ctx context.Context, tx pgx.Tx) error { | ||
if _, err := tx.Exec(ctx, createCaveatTable); err != nil { | ||
return err | ||
} | ||
if _, err := tx.Exec(ctx, addRelationshipCaveatContext); err != nil { | ||
return err | ||
} | ||
return nil | ||
}); err != nil { | ||
panic("failed to register migration: " + err.Error()) | ||
} | ||
} |
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
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
Oops, something went wrong.