Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add access_grant database table (#19321)
rebelice758e9537d500
diff --git a/backend/migrator/migration/3.15/0010##create_access_grant_table.sql b/backend/migrator/migration/3.15/0010##create_access_grant_table.sqlnew file mode 100644index 0000000000..a5f1cca04e--- /dev/null+++ b/backend/migrator/migration/3.15/0010##create_access_grant_table.sql@@ -0,0 +1,13 @@+CREATE TABLE access_grant (+ id text PRIMARY KEY,+ project text NOT NULL REFERENCES project(resource_id),+ creator text NOT NULL REFERENCES principal(email) ON UPDATE CASCADE,+ status text NOT NULL DEFAULT 'PENDING',+ expire_time timestamptz NOT NULL,+ -- Stored as AccessGrantPayload (proto/store/store/access_grant.proto)+ payload jsonb NOT NULL DEFAULT '{}',+ created_at timestamptz NOT NULL DEFAULT now(),+ updated_at timestamptz NOT NULL DEFAULT now()+);++CREATE INDEX idx_access_grant_project_creator_expire_time ON access_grant(project, creator, expire_time);diff --git a/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sqlindex 802d0c05d6..19525116ba 100644--- a/backend/migrator/migration/LATEST.sql+++ b/backend/migrator/migration/LATEST.sql@@ -575,6 +575,20 @@ CREATE INDEX idx_web_refresh_token_expires_at ON web_refresh_token(expires_at);ALTER SEQUENCE principal_id_seq RESTART WITH 101;+CREATE TABLE access_grant (+ id text PRIMARY KEY,+ project text NOT NULL REFERENCES project(resource_id),+ creator text NOT NULL REFERENCES principal(email) ON UPDATE CASCADE,+ status text NOT NULL DEFAULT 'PENDING',+ expire_time timestamptz NOT NULL,+ -- Stored as AccessGrantPayload (proto/store/store/access_grant.proto)+ payload jsonb NOT NULL DEFAULT '{}',+ created_at timestamptz NOT NULL DEFAULT now(),+ updated_at timestamptz NOT NULL DEFAULT now()+);++CREATE INDEX idx_access_grant_project_creator_expire_time ON access_grant(project, creator, expire_time);+-- Default project.INSERT INTO project (id, name, resource_id) VALUES (1, 'Default', 'default');diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 71bf922ba0..c962f844b0 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -12,8 +12,8 @@ import (func TestLatestVersion(t *testing.T) {files, err := getSortedVersionedFiles()require.NoError(t, err)- require.Equal(t, semver.MustParse("3.15.9"), *files[len(files)-1].version)- require.Equal(t, "migration/3.15/0009##migrate_iam_binding_environment_condition.sql", files[len(files)-1].path)+ require.Equal(t, semver.MustParse("3.15.10"), *files[len(files)-1].version)+ require.Equal(t, "migration/3.15/0010##create_access_grant_table.sql", files[len(files)-1].path)}func TestVersionUnique(t *testing.T) {