mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix: merge migrations (#363)
* fix: merge migrations * fix: rename env variable
This commit is contained in:
parent
c6e8597eeb
commit
5988ec4844
@ -219,14 +219,14 @@ Admin:
|
||||
SQL:
|
||||
Host: $ZITADEL_EVENTSTORE_HOST
|
||||
Port: $ZITADEL_EVENTSTORE_PORT
|
||||
User: 'admin_api'
|
||||
Password: $CR_ADMIN_PASSWORD
|
||||
User: 'adminapi'
|
||||
Password: $CR_ADMINAPI_PASSWORD
|
||||
Database: 'eventstore'
|
||||
SSL:
|
||||
Mode: $CR_SSL_MODE
|
||||
RootCert: $CR_ROOT_CERT
|
||||
Cert: $CR_ADMIN_CERT
|
||||
Key: $CR_ADMIN_KEY
|
||||
Cert: $CR_ADMINAPI_CERT
|
||||
Key: $CR_ADMINAPI_KEY
|
||||
Cache:
|
||||
Type: 'fastcache'
|
||||
Config:
|
||||
@ -234,14 +234,14 @@ Admin:
|
||||
View:
|
||||
Host: $ZITADEL_EVENTSTORE_HOST
|
||||
Port: $ZITADEL_EVENTSTORE_PORT
|
||||
User: 'admin_api'
|
||||
Password: $CR_ADMIN_PASSWORD
|
||||
Database: 'admin_api'
|
||||
User: 'adminapi'
|
||||
Password: $CR_ADMINAPI_PASSWORD
|
||||
Database: 'adminapi'
|
||||
SSL:
|
||||
Mode: $CR_SSL_MODE
|
||||
RootCert: $CR_ROOT_CERT
|
||||
Cert: $CR_ADMIN_CERT
|
||||
Key: $CR_ADMIN_KEY
|
||||
Cert: $CR_ADMINAPI_CERT
|
||||
Key: $CR_ADMINAPI_KEY
|
||||
Spooler:
|
||||
ConcurrentTasks: 1
|
||||
BulkLimit: 100
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
var dbList = []string{"management", "auth", "authz", "admin_api", "notification"}
|
||||
var dbList = []string{"management", "auth", "authz", "adminapi", "notification"}
|
||||
|
||||
type AdministratorRepo struct {
|
||||
View *view.View
|
||||
|
@ -21,7 +21,7 @@ type IamMember struct {
|
||||
}
|
||||
|
||||
const (
|
||||
iamMemberTable = "admin_api.iam_members"
|
||||
iamMemberTable = "adminapi.iam_members"
|
||||
)
|
||||
|
||||
func (m *IamMember) MinimumCycleDuration() time.Duration { return m.cycleDuration }
|
||||
|
@ -16,7 +16,7 @@ type Org struct {
|
||||
}
|
||||
|
||||
const (
|
||||
orgTable = "admin_api.orgs"
|
||||
orgTable = "adminapi.orgs"
|
||||
)
|
||||
|
||||
func (o *Org) MinimumCycleDuration() time.Duration { return o.cycleDuration }
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
lockTable = "admin_api.locks"
|
||||
lockTable = "adminapi.locks"
|
||||
lockedUntilKey = "locked_until"
|
||||
lockerIDKey = "locker_id"
|
||||
objectTypeKey = "object_type"
|
||||
|
@ -57,7 +57,7 @@ func (db *dbMock) expectReleaseSavepoint() *dbMock {
|
||||
|
||||
func (db *dbMock) expectRenew(lockerID, view string, affectedRows int64) *dbMock {
|
||||
query := db.mock.
|
||||
ExpectExec(`INSERT INTO admin_api\.locks \(object_type, locker_id, locked_until\) VALUES \(\$1, \$2, now\(\)\+\$3\) ON CONFLICT \(object_type\) DO UPDATE SET locked_until = now\(\)\+\$4, locker_id = \$5 WHERE \(locks\.locked_until < now\(\) OR locks\.locker_id = \$6\) AND locks\.object_type = \$7`).
|
||||
ExpectExec(`INSERT INTO adminapi\.locks \(object_type, locker_id, locked_until\) VALUES \(\$1, \$2, now\(\)\+\$3\) ON CONFLICT \(object_type\) DO UPDATE SET locked_until = now\(\)\+\$4, locker_id = \$5 WHERE \(locks\.locked_until < now\(\) OR locks\.locker_id = \$6\) AND locks\.object_type = \$7`).
|
||||
WithArgs(view, lockerID, sqlmock.AnyArg(), sqlmock.AnyArg(), lockerID, lockerID, view).
|
||||
WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
errTable = "admin_api.failed_events"
|
||||
errTable = "adminapi.failed_events"
|
||||
errColumn = "failed_events"
|
||||
)
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
iamMemberTable = "admin_api.iam_members"
|
||||
iamMemberTable = "adminapi.iam_members"
|
||||
)
|
||||
|
||||
func (v *View) IamMemberByIDs(orgID, userID string) (*model.IamMemberView, error) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
orgTable = "admin_api.orgs"
|
||||
orgTable = "adminapi.orgs"
|
||||
)
|
||||
|
||||
func (v *View) OrgByID(orgID string) (*model.OrgView, error) {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
sequencesTable = "admin_api.current_sequences"
|
||||
sequencesTable = "adminapi.current_sequences"
|
||||
)
|
||||
|
||||
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
||||
|
@ -1,34 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE management.orgs (
|
||||
id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
resource_owner TEXT,
|
||||
org_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
name TEXT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.org_members (
|
||||
user_id TEXT,
|
||||
org_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (org_id, user_id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,56 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE auth.keys (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
private BOOLEAN,
|
||||
expiry TIMESTAMPTZ,
|
||||
algorithm TEXT,
|
||||
usage SMALLINT,
|
||||
key JSONB,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id, private)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.applications (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
app_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
app_name TEXT,
|
||||
project_id TEXT,
|
||||
app_type SMALLINT,
|
||||
is_oidc BOOLEAN,
|
||||
oidc_client_id TEXT,
|
||||
oidc_redirect_uris TEXT ARRAY,
|
||||
oidc_response_types SMALLINT ARRAY,
|
||||
oidc_grant_types SMALLINT ARRAY,
|
||||
oidc_application_type SMALLINT,
|
||||
oidc_auth_method_type SMALLINT,
|
||||
oidc_post_logout_redirect_uris TEXT ARRAY,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
ALTER TABLE auth.tokens ADD COLUMN scopes TEXT ARRAY;
|
||||
ALTER TABLE auth.tokens ADD COLUMN audience TEXT ARRAY;
|
||||
|
||||
ALTER TABLE auth.users ADD COLUMN init_required BOOLEAN;
|
||||
ALTER TABLE management.users ADD COLUMN init_required BOOLEAN;
|
||||
|
||||
ALTER TABLE auth.auth_requests ADD COLUMN code TEXT;
|
||||
ALTER TABLE auth.auth_requests ADD COLUMN request_type smallint;
|
||||
|
||||
ALTER TABLE auth.user_sessions ADD COLUMN mfa_software_verification_type smallint;
|
||||
ALTER TABLE auth.user_sessions ADD COLUMN mfa_hardware_verification_type smallint;
|
||||
|
||||
COMMIT;
|
@ -1,25 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE auth.user_grants (
|
||||
id TEXT,
|
||||
resource_owner TEXT,
|
||||
project_id TEXT,
|
||||
user_id TEXT,
|
||||
org_name TEXT,
|
||||
org_domain TEXT,
|
||||
project_name TEXT,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
email TEXT,
|
||||
role_keys TEXT Array,
|
||||
|
||||
grant_state SMALLINT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,17 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE auth.orgs (
|
||||
id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
resource_owner TEXT,
|
||||
org_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
name TEXT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,94 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE DATABASE authz;
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE USER authz;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE authz TO authz;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO authz;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO authz;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE auth TO authz;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE auth.* TO authz;
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE authz.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.failed_event (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.user_grants (
|
||||
id TEXT,
|
||||
resource_owner TEXT,
|
||||
project_id TEXT,
|
||||
user_id TEXT,
|
||||
org_name TEXT,
|
||||
org_domain TEXT,
|
||||
project_name TEXT,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
email TEXT,
|
||||
role_keys TEXT Array,
|
||||
|
||||
grant_state SMALLINT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.applications (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
app_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
app_name TEXT,
|
||||
project_id TEXT,
|
||||
app_type SMALLINT,
|
||||
is_oidc BOOLEAN,
|
||||
oidc_client_id TEXT,
|
||||
oidc_redirect_uris TEXT ARRAY,
|
||||
oidc_response_types SMALLINT ARRAY,
|
||||
oidc_grant_types SMALLINT ARRAY,
|
||||
oidc_application_type SMALLINT,
|
||||
oidc_auth_method_type SMALLINT,
|
||||
oidc_post_logout_redirect_uris TEXT ARRAY,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
@ -1,36 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
DROP TABLE management.granted_projects;
|
||||
|
||||
CREATE TABLE management.projects (
|
||||
project_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
project_name TEXT,
|
||||
project_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (project_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_grants (
|
||||
grant_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
project_id TEXT,
|
||||
project_name TEXT,
|
||||
org_name TEXT,
|
||||
org_domain TEXT,
|
||||
project_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
org_id TEXT,
|
||||
granted_role_keys TEXT Array,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (grant_id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,7 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
|
||||
ALTER TABLE auth.users ADD COLUMN login_names TEXT ARRAY;
|
||||
ALTER TABLE management.users ADD COLUMN login_names TEXT ARRAY;
|
||||
|
||||
COMMIT;
|
@ -1,16 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE management.org_domains (
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
org_id TEXT,
|
||||
verified BOOLEAN,
|
||||
primary_domain BOOLEAN,
|
||||
|
||||
PRIMARY KEY (org_id, domain)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,6 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE auth.users ADD COLUMN preferred_login_name TEXT;
|
||||
ALTER TABLE management.users ADD COLUMN preferred_login_name TEXT;
|
||||
|
||||
COMMIT;
|
@ -1,6 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE auth.user_sessions ADD COLUMN user_display_name TEXT;
|
||||
ALTER TABLE auth.user_sessions ADD COLUMN login_name TEXT;
|
||||
|
||||
COMMIT;
|
48
migrations/cockroach/V1.1__databases.sql
Normal file
48
migrations/cockroach/V1.1__databases.sql
Normal file
@ -0,0 +1,48 @@
|
||||
CREATE DATABASE management;
|
||||
CREATE DATABASE auth;
|
||||
CREATE DATABASE notification;
|
||||
CREATE DATABASE adminapi;
|
||||
CREATE DATABASE authz;
|
||||
|
||||
CREATE USER management;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE management TO management;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO management;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO management;
|
||||
|
||||
|
||||
CREATE USER adminapi;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE, DROP ON DATABASE adminapi TO adminapi;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO adminapi;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO adminapi;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE auth TO adminapi;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE authz TO adminapi;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE management TO adminapi;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE notification TO adminapi;
|
||||
|
||||
|
||||
CREATE USER auth;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE auth TO auth;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO auth;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO auth;
|
||||
|
||||
|
||||
CREATE USER notification;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE notification TO notification;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO notification;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO notification;
|
||||
|
||||
CREATE USER authz;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE authz TO authz;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO authz;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO authz;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE auth TO authz;
|
@ -1,16 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE DATABASE management;
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE USER management;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE management TO management;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO management;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO management;
|
||||
|
||||
COMMIT;
|
@ -1,5 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE notification.notify_users ADD COLUMN password_set BOOLEAN;
|
||||
|
||||
COMMIT;
|
@ -1,5 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE management.project_grants ADD COLUMN resource_owner_name TEXT;
|
||||
|
||||
COMMIT;
|
@ -1,15 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE auth TO admin_api;
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE auth.* TO admin_api;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE authz TO admin_api;
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE authz.* TO admin_api;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE management TO admin_api;
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE management.* TO admin_api;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE notification TO admin_api;
|
||||
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE notification.* TO admin_api;
|
||||
|
||||
COMMIT;
|
@ -1,20 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE admin_api.iam_members (
|
||||
user_id TEXT,
|
||||
|
||||
iam_id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (user_id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,5 +0,0 @@
|
||||
ALTER TABLE management.failed_event RENAME TO management.failed_events;
|
||||
ALTER TABLE auth.failed_event RENAME TO auth.failed_events;
|
||||
ALTER TABLE notification.failed_event RENAME TO notification.failed_events;
|
||||
ALTER TABLE authz.failed_event RENAME TO authz.failed_events;
|
||||
ALTER TABLE admin_api.failed_event RENAME TO admin_api.failed_events;
|
@ -1 +0,0 @@
|
||||
ALTER TABLE management.user_grants ADD COLUMN display_name TEXT;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE auth.user_grants ADD COLUMN display_name TEXT;
|
||||
ALTER TABLE authz.user_grants ADD COLUMN display_name TEXT;
|
@ -1,2 +0,0 @@
|
||||
GRANT DROP ON DATABASE admin_api TO admin_api;
|
||||
GRANT DROP ON TABLE admin_api.* TO admin_api;
|
@ -1,123 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
|
||||
CREATE TABLE management.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE management.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE management.failed_event (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE management.granted_projects (
|
||||
project_id TEXT,
|
||||
org_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
project_name TEXT,
|
||||
org_name TEXT,
|
||||
org_domain TEXT,
|
||||
project_type SMALLINT,
|
||||
project_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
grant_id TEXT,
|
||||
granted_role_keys TEXT Array,
|
||||
sequence BIGINT,
|
||||
|
||||
|
||||
PRIMARY KEY (project_id, org_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_roles (
|
||||
project_id TEXT,
|
||||
role_key TEXT,
|
||||
display_name TEXT,
|
||||
resource_owner TEXT,
|
||||
org_id TEXT,
|
||||
group_name TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (org_id, project_id, role_key)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_members (
|
||||
user_id TEXT,
|
||||
project_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (project_id, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_grant_members (
|
||||
user_id TEXT,
|
||||
grant_id TEXT,
|
||||
project_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (grant_id, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.applications (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
app_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
app_name TEXT,
|
||||
project_id TEXT,
|
||||
app_type SMALLINT,
|
||||
is_oidc BOOLEAN,
|
||||
oidc_client_id TEXT,
|
||||
oidc_redirect_uris TEXT ARRAY,
|
||||
oidc_response_types SMALLINT ARRAY,
|
||||
oidc_grant_types SMALLINT ARRAY,
|
||||
oidc_application_type SMALLINT,
|
||||
oidc_auth_method_type SMALLINT,
|
||||
oidc_post_logout_redirect_uris TEXT ARRAY,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
COMMIT;
|
606
migrations/cockroach/V1.2__views.sql
Normal file
606
migrations/cockroach/V1.2__views.sql
Normal file
@ -0,0 +1,606 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE management.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE management.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE management.failed_events (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE management.projects (
|
||||
project_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
project_name TEXT,
|
||||
project_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (project_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_grants (
|
||||
grant_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
project_id TEXT,
|
||||
project_name TEXT,
|
||||
org_name TEXT,
|
||||
project_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
org_id TEXT,
|
||||
granted_role_keys TEXT Array,
|
||||
sequence BIGINT,
|
||||
resource_owner_name TEXT,
|
||||
|
||||
PRIMARY KEY (grant_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_roles (
|
||||
project_id TEXT,
|
||||
role_key TEXT,
|
||||
display_name TEXT,
|
||||
resource_owner TEXT,
|
||||
org_id TEXT,
|
||||
group_name TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (org_id, project_id, role_key)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_members (
|
||||
user_id TEXT,
|
||||
project_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (project_id, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.project_grant_members (
|
||||
user_id TEXT,
|
||||
grant_id TEXT,
|
||||
project_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (grant_id, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.applications (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
app_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
app_name TEXT,
|
||||
project_id TEXT,
|
||||
app_type SMALLINT,
|
||||
is_oidc BOOLEAN,
|
||||
oidc_client_id TEXT,
|
||||
oidc_redirect_uris TEXT ARRAY,
|
||||
oidc_response_types SMALLINT ARRAY,
|
||||
oidc_grant_types SMALLINT ARRAY,
|
||||
oidc_application_type SMALLINT,
|
||||
oidc_auth_method_type SMALLINT,
|
||||
oidc_post_logout_redirect_uris TEXT ARRAY,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.users (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
user_state SMALLINT,
|
||||
last_login TIMESTAMPTZ,
|
||||
password_change TIMESTAMPTZ,
|
||||
user_name TEXT,
|
||||
login_names TEXT ARRAY,
|
||||
preferred_login_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
nick_Name TEXT,
|
||||
display_name TEXT,
|
||||
preferred_language TEXT,
|
||||
gender SMALLINT,
|
||||
email TEXT,
|
||||
is_email_verified BOOLEAN,
|
||||
phone TEXT,
|
||||
is_phone_verified BOOLEAN,
|
||||
country TEXT,
|
||||
locality TEXT,
|
||||
postal_code TEXT,
|
||||
region TEXT,
|
||||
street_address TEXT,
|
||||
otp_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
password_set BOOLEAN,
|
||||
password_change_required BOOLEAN,
|
||||
mfa_max_set_up SMALLINT,
|
||||
mfa_init_skipped TIMESTAMPTZ,
|
||||
init_required BOOLEAN,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.user_grants (
|
||||
id TEXT,
|
||||
resource_owner TEXT,
|
||||
project_id TEXT,
|
||||
user_id TEXT,
|
||||
org_name TEXT,
|
||||
project_name TEXT,
|
||||
user_name TEXT,
|
||||
display_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
email TEXT,
|
||||
role_keys TEXT Array,
|
||||
|
||||
grant_state SMALLINT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.failed_events (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.auth_requests (
|
||||
id TEXT,
|
||||
request JSONB,
|
||||
code TEXT,
|
||||
request_type smallint,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.users (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
user_state SMALLINT,
|
||||
password_set BOOLEAN,
|
||||
password_change_required BOOLEAN,
|
||||
password_change TIMESTAMPTZ,
|
||||
last_login TIMESTAMPTZ,
|
||||
user_name TEXT,
|
||||
login_names TEXT ARRAY,
|
||||
preferred_login_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
nick_name TEXT,
|
||||
display_name TEXT,
|
||||
preferred_language TEXT,
|
||||
gender SMALLINT,
|
||||
email TEXT,
|
||||
is_email_verified BOOLEAN,
|
||||
phone TEXT,
|
||||
is_phone_verified BOOLEAN,
|
||||
country TEXT,
|
||||
locality TEXT,
|
||||
postal_code TEXT,
|
||||
region TEXT,
|
||||
street_address TEXT,
|
||||
otp_state SMALLINT,
|
||||
mfa_max_set_up SMALLINT,
|
||||
mfa_init_skipped TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
init_required BOOLEAN,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.user_sessions (
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
state SMALLINT,
|
||||
user_agent_id TEXT,
|
||||
user_id TEXT,
|
||||
user_name TEXT,
|
||||
password_verification TIMESTAMPTZ,
|
||||
mfa_software_verification TIMESTAMPTZ,
|
||||
mfa_hardware_verification TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
mfa_software_verification_type SMALLINT,
|
||||
mfa_hardware_verification_type SMALLINT,
|
||||
user_display_name TEXT,
|
||||
login_name TEXT,
|
||||
|
||||
PRIMARY KEY (user_agent_id, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.tokens (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
application_id TEXT,
|
||||
user_agent_id TEXT,
|
||||
user_id TEXT,
|
||||
expiration TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
scopes TEXT ARRAY,
|
||||
audience TEXT ARRAY,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE notification.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE notification.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE notification.failed_events (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE notification.notify_users (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
nick_Name TEXT,
|
||||
display_name TEXT,
|
||||
preferred_language TEXT,
|
||||
gender SMALLINT,
|
||||
last_email TEXT,
|
||||
verified_email TEXT,
|
||||
last_phone TEXT,
|
||||
verified_phone TEXT,
|
||||
sequence BIGINT,
|
||||
password_set BOOLEAN,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE adminapi.orgs (
|
||||
id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
resource_owner TEXT,
|
||||
org_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
name TEXT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE adminapi.failed_events (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE adminapi.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE adminapi.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE management.orgs (
|
||||
id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
resource_owner TEXT,
|
||||
org_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
name TEXT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.org_members (
|
||||
user_id TEXT,
|
||||
org_id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (org_id, user_id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE auth.keys (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
private BOOLEAN,
|
||||
expiry TIMESTAMPTZ,
|
||||
algorithm TEXT,
|
||||
usage SMALLINT,
|
||||
key JSONB,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id, private)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.applications (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
app_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
app_name TEXT,
|
||||
project_id TEXT,
|
||||
app_type SMALLINT,
|
||||
is_oidc BOOLEAN,
|
||||
oidc_client_id TEXT,
|
||||
oidc_redirect_uris TEXT ARRAY,
|
||||
oidc_response_types SMALLINT ARRAY,
|
||||
oidc_grant_types SMALLINT ARRAY,
|
||||
oidc_application_type SMALLINT,
|
||||
oidc_auth_method_type SMALLINT,
|
||||
oidc_post_logout_redirect_uris TEXT ARRAY,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.user_grants (
|
||||
id TEXT,
|
||||
resource_owner TEXT,
|
||||
project_id TEXT,
|
||||
user_id TEXT,
|
||||
org_name TEXT,
|
||||
project_name TEXT,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
display_name TEXT,
|
||||
email TEXT,
|
||||
role_keys TEXT Array,
|
||||
|
||||
grant_state SMALLINT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.orgs (
|
||||
id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
resource_owner TEXT,
|
||||
org_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
name TEXT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.failed_events (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.user_grants (
|
||||
id TEXT,
|
||||
resource_owner TEXT,
|
||||
project_id TEXT,
|
||||
user_id TEXT,
|
||||
org_name TEXT,
|
||||
project_name TEXT,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
display_name TEXT,
|
||||
email TEXT,
|
||||
role_keys TEXT Array,
|
||||
|
||||
grant_state SMALLINT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE authz.applications (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
app_state SMALLINT,
|
||||
resource_owner TEXT,
|
||||
app_name TEXT,
|
||||
project_id TEXT,
|
||||
app_type SMALLINT,
|
||||
is_oidc BOOLEAN,
|
||||
oidc_client_id TEXT,
|
||||
oidc_redirect_uris TEXT ARRAY,
|
||||
oidc_response_types SMALLINT ARRAY,
|
||||
oidc_grant_types SMALLINT ARRAY,
|
||||
oidc_application_type SMALLINT,
|
||||
oidc_auth_method_type SMALLINT,
|
||||
oidc_post_logout_redirect_uris TEXT ARRAY,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.org_domains (
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
org_id TEXT,
|
||||
verified BOOLEAN,
|
||||
primary_domain BOOLEAN,
|
||||
|
||||
PRIMARY KEY (org_id, domain)
|
||||
);
|
||||
|
||||
CREATE TABLE adminapi.iam_members (
|
||||
user_id TEXT,
|
||||
|
||||
iam_id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
user_name TEXT,
|
||||
email_address TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
roles TEXT ARRAY,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (user_id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,57 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE management.users (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
user_state SMALLINT,
|
||||
last_login TIMESTAMPTZ,
|
||||
password_change TIMESTAMPTZ,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
nick_Name TEXT,
|
||||
display_name TEXT,
|
||||
preferred_language TEXT,
|
||||
gender SMALLINT,
|
||||
email TEXT,
|
||||
is_email_verified BOOLEAN,
|
||||
phone TEXT,
|
||||
is_phone_verified BOOLEAN,
|
||||
country TEXT,
|
||||
locality TEXT,
|
||||
postal_code TEXT,
|
||||
region TEXT,
|
||||
street_address TEXT,
|
||||
otp_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE management.user_grants (
|
||||
id TEXT,
|
||||
resource_owner TEXT,
|
||||
project_id TEXT,
|
||||
user_id TEXT,
|
||||
org_name TEXT,
|
||||
org_domain TEXT,
|
||||
project_name TEXT,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
email TEXT,
|
||||
role_keys TEXT Array,
|
||||
|
||||
grant_state SMALLINT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,8 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE USER admin_api;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO admin_api;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO admin_api;
|
||||
|
||||
COMMIT;
|
@ -1,121 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE DATABASE auth;
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE USER auth;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE auth TO auth;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO auth;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO auth;
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE auth.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.failed_event (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.auth_requests (
|
||||
id TEXT,
|
||||
request JSONB,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.users (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
user_state SMALLINT,
|
||||
password_set BOOLEAN,
|
||||
password_change_required BOOLEAN,
|
||||
password_change TIMESTAMPTZ,
|
||||
last_login TIMESTAMPTZ,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
nick_name TEXT,
|
||||
display_name TEXT,
|
||||
preferred_language TEXT,
|
||||
gender SMALLINT,
|
||||
email TEXT,
|
||||
is_email_verified BOOLEAN,
|
||||
phone TEXT,
|
||||
is_phone_verified BOOLEAN,
|
||||
country TEXT,
|
||||
locality TEXT,
|
||||
postal_code TEXT,
|
||||
region TEXT,
|
||||
street_address TEXT,
|
||||
otp_state SMALLINT,
|
||||
mfa_max_set_up SMALLINT,
|
||||
mfa_init_skipped TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.user_sessions (
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
state SMALLINT,
|
||||
user_agent_id TEXT,
|
||||
user_id TEXT,
|
||||
user_name TEXT,
|
||||
password_verification TIMESTAMPTZ,
|
||||
mfa_software_verification TIMESTAMPTZ,
|
||||
mfa_hardware_verification TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (user_agent_id, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE auth.tokens (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
application_id TEXT,
|
||||
user_agent_id TEXT,
|
||||
user_id TEXT,
|
||||
expiration TIMESTAMPTZ,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
COMMIT;
|
@ -1,9 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE management.users
|
||||
ADD COLUMN password_set BOOLEAN,
|
||||
ADD COLUMN password_change_required BOOLEAN,
|
||||
ADD COLUMN mfa_max_set_up SMALLINT,
|
||||
ADD COLUMN mfa_init_skipped TIMESTAMPTZ;
|
||||
|
||||
COMMIT;
|
@ -1,69 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE DATABASE notification;
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE USER notification;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE notification TO notification;
|
||||
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO notification;
|
||||
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO notification;
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE notification.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE notification.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
CREATE TABLE notification.failed_event (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE notification.notify_users (
|
||||
id TEXT,
|
||||
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
|
||||
resource_owner TEXT,
|
||||
user_name TEXT,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
nick_Name TEXT,
|
||||
display_name TEXT,
|
||||
preferred_language TEXT,
|
||||
gender SMALLINT,
|
||||
last_email TEXT,
|
||||
verified_email TEXT,
|
||||
last_phone TEXT,
|
||||
verified_phone TEXT,
|
||||
sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
COMMIT;
|
@ -1,49 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE DATABASE admin_api;
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE admin_api.orgs (
|
||||
id TEXT,
|
||||
creation_date TIMESTAMPTZ,
|
||||
change_date TIMESTAMPTZ,
|
||||
resource_owner TEXT,
|
||||
org_state SMALLINT,
|
||||
sequence BIGINT,
|
||||
|
||||
domain TEXT,
|
||||
name TEXT,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE admin_api.failed_event (
|
||||
view_name TEXT,
|
||||
failed_sequence BIGINT,
|
||||
failure_count SMALLINT,
|
||||
err_msg TEXT,
|
||||
|
||||
PRIMARY KEY (view_name, failed_sequence)
|
||||
);
|
||||
|
||||
CREATE TABLE admin_api.locks (
|
||||
locker_id TEXT,
|
||||
locked_until TIMESTAMPTZ,
|
||||
object_type TEXT,
|
||||
|
||||
PRIMARY KEY (object_type)
|
||||
);
|
||||
|
||||
CREATE TABLE admin_api.current_sequences (
|
||||
view_name TEXT,
|
||||
|
||||
current_sequence BIGINT,
|
||||
|
||||
PRIMARY KEY (view_name)
|
||||
);
|
||||
|
||||
|
||||
COMMIT;
|
@ -1,6 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE admin_api TO admin_api;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE admin_api.* TO admin_api;
|
||||
|
||||
COMMIT;
|
Loading…
Reference in New Issue
Block a user