zitadel/migrations/cockroach/V1.96__members.sql
Silvan b43362ad15
fix(projections): add member (#2699)
* refactor(domain): add user type

* fix(projections): start with login names

* fix(login_policy): correct handling of user domain claimed event

* fix(projections): add members

* refactor: simplify member projections

* add migration for members

* add metadata to member projections

* refactor: login name projection

* fix: set correct suffixes on login name projections

* test(projections): login name reduces

* fix: correct cols in reduce member

* test(projections): org, iam, project members

* member additional cols and conds as opt,
add project grant members

* fix(migration): members

* fix(migration): correct database name

* migration version

* migs

* better naming for member cond and col

* split project and project grant members
2021-12-02 09:31:44 +01:00

57 lines
1.4 KiB
SQL

CREATE TABLE zitadel.projections.org_members (
org_id STRING NOT NULL
, user_id STRING NOT NULL
, roles STRING[]
, creation_date TIMESTAMPTZ NOT NULL
, change_date TIMESTAMPTZ NOT NULL
, sequence INT8 NOT NULL
, resource_owner STRING NOT NULL
, PRIMARY KEY (org_id, user_id)
, INDEX idx_user (user_id)
);
CREATE TABLE zitadel.projections.iam_members (
iam_id STRING NOT NULL
, user_id STRING NOT NULL
, roles STRING[]
, creation_date TIMESTAMPTZ NOT NULL
, change_date TIMESTAMPTZ NOT NULL
, sequence INT8 NOT NULL
, resource_owner STRING NOT NULL
, PRIMARY KEY (iam_id, user_id)
, INDEX idx_user (user_id)
);
CREATE TABLE zitadel.projections.project_members (
project_id STRING NOT NULL
, user_id STRING NOT NULL
, roles STRING[]
, creation_date TIMESTAMPTZ NOT NULL
, change_date TIMESTAMPTZ NOT NULL
, sequence INT8 NOT NULL
, resource_owner STRING NOT NULL
, PRIMARY KEY (project_id, user_id)
, INDEX idx_user (user_id)
);
CREATE TABLE zitadel.projections.project_grant_members (
project_id STRING NOT NULL
, user_id STRING NOT NULL
, grant_id STRING
, roles STRING[]
, creation_date TIMESTAMPTZ NOT NULL
, change_date TIMESTAMPTZ NOT NULL
, sequence INT8 NOT NULL
, resource_owner STRING NOT NULL
, PRIMARY KEY (project_id, grant_id, user_id)
, INDEX idx_user (user_id)
);