From 5988ec4844b7ecadf5adf50a383924abf3821714 Mon Sep 17 00:00:00 2001 From: Fabi <38692350+fgerschwiler@users.noreply.github.com> Date: Tue, 7 Jul 2020 16:53:54 +0200 Subject: [PATCH] fix: merge migrations (#363) * fix: merge migrations * fix: rename env variable --- cmd/zitadel/startup.yaml | 18 +- .../eventsourcing/eventstore/administrator.go | 2 +- .../eventsourcing/handler/iam_member.go | 2 +- .../repository/eventsourcing/handler/org.go | 2 +- .../repository/eventsourcing/spooler/lock.go | 2 +- .../eventsourcing/spooler/lock_test.go | 2 +- .../eventsourcing/view/error_event.go | 2 +- .../eventsourcing/view/iam_member.go | 2 +- .../repository/eventsourcing/view/org.go | 2 +- .../repository/eventsourcing/view/sequence.go | 2 +- migrations/cockroach/V1.10__mgmt_orgs.sql | 34 - migrations/cockroach/V1.11__auth_oidc.sql | 56 -- .../cockroach/V1.12__auth_user_grant_view.sql | 25 - migrations/cockroach/V1.13__auth_org_view.sql | 17 - migrations/cockroach/V1.14__authz.sql | 94 --- .../V1.15__management_project_view.sql | 36 -- migrations/cockroach/V1.16__login_names.sql | 7 - migrations/cockroach/V1.17__org_domains.sql | 16 - migrations/cockroach/V1.18__user_view.sql | 6 - .../cockroach/V1.19__usersession_names.sql | 6 - migrations/cockroach/V1.1__databases.sql | 48 ++ migrations/cockroach/V1.1__management.sql | 16 - .../V1.20__notification_passwordset.sql | 5 - .../cockroach/V1.21__project_grant_view.sql | 5 - migrations/cockroach/V1.22__admin_view.sql | 15 - .../cockroach/V1.23__admin_iam_members.sql | 20 - migrations/cockroach/V1.24__failed_events.sql | 5 - .../V1.25__management_user_grant.sql | 1 - .../cockroach/V1.26__auth_user_grant.sql | 2 - .../cockroach/V1.27__adminapi_grants.sql | 2 - .../V1.2__management_project_view.sql | 123 ---- migrations/cockroach/V1.2__views.sql | 606 ++++++++++++++++++ .../cockroach/V1.3__management_user_view.sql | 57 -- .../cockroach/V1.4__admin_user_grants.sql | 8 - migrations/cockroach/V1.5__auth.sql | 121 ---- .../cockroach/V1.6__management_user_view.sql | 9 - migrations/cockroach/V1.7__notification.sql | 69 -- migrations/cockroach/V1.8__admin.sql | 49 -- migrations/cockroach/V1.9__admin_grant.sql | 6 - 39 files changed, 672 insertions(+), 828 deletions(-) delete mode 100644 migrations/cockroach/V1.10__mgmt_orgs.sql delete mode 100644 migrations/cockroach/V1.11__auth_oidc.sql delete mode 100644 migrations/cockroach/V1.12__auth_user_grant_view.sql delete mode 100644 migrations/cockroach/V1.13__auth_org_view.sql delete mode 100644 migrations/cockroach/V1.14__authz.sql delete mode 100644 migrations/cockroach/V1.15__management_project_view.sql delete mode 100644 migrations/cockroach/V1.16__login_names.sql delete mode 100644 migrations/cockroach/V1.17__org_domains.sql delete mode 100644 migrations/cockroach/V1.18__user_view.sql delete mode 100644 migrations/cockroach/V1.19__usersession_names.sql create mode 100644 migrations/cockroach/V1.1__databases.sql delete mode 100644 migrations/cockroach/V1.1__management.sql delete mode 100644 migrations/cockroach/V1.20__notification_passwordset.sql delete mode 100644 migrations/cockroach/V1.21__project_grant_view.sql delete mode 100644 migrations/cockroach/V1.22__admin_view.sql delete mode 100644 migrations/cockroach/V1.23__admin_iam_members.sql delete mode 100644 migrations/cockroach/V1.24__failed_events.sql delete mode 100644 migrations/cockroach/V1.25__management_user_grant.sql delete mode 100644 migrations/cockroach/V1.26__auth_user_grant.sql delete mode 100644 migrations/cockroach/V1.27__adminapi_grants.sql delete mode 100644 migrations/cockroach/V1.2__management_project_view.sql create mode 100644 migrations/cockroach/V1.2__views.sql delete mode 100644 migrations/cockroach/V1.3__management_user_view.sql delete mode 100644 migrations/cockroach/V1.4__admin_user_grants.sql delete mode 100644 migrations/cockroach/V1.5__auth.sql delete mode 100644 migrations/cockroach/V1.6__management_user_view.sql delete mode 100644 migrations/cockroach/V1.7__notification.sql delete mode 100644 migrations/cockroach/V1.8__admin.sql delete mode 100644 migrations/cockroach/V1.9__admin_grant.sql diff --git a/cmd/zitadel/startup.yaml b/cmd/zitadel/startup.yaml index 12d60684c4..7af5ed8ece 100644 --- a/cmd/zitadel/startup.yaml +++ b/cmd/zitadel/startup.yaml @@ -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 diff --git a/internal/admin/repository/eventsourcing/eventstore/administrator.go b/internal/admin/repository/eventsourcing/eventstore/administrator.go index ab179e5308..d0af36284e 100644 --- a/internal/admin/repository/eventsourcing/eventstore/administrator.go +++ b/internal/admin/repository/eventsourcing/eventstore/administrator.go @@ -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 diff --git a/internal/admin/repository/eventsourcing/handler/iam_member.go b/internal/admin/repository/eventsourcing/handler/iam_member.go index f311b3e1ee..b040171f21 100644 --- a/internal/admin/repository/eventsourcing/handler/iam_member.go +++ b/internal/admin/repository/eventsourcing/handler/iam_member.go @@ -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 } diff --git a/internal/admin/repository/eventsourcing/handler/org.go b/internal/admin/repository/eventsourcing/handler/org.go index 0427739ddb..6b5d61db44 100644 --- a/internal/admin/repository/eventsourcing/handler/org.go +++ b/internal/admin/repository/eventsourcing/handler/org.go @@ -16,7 +16,7 @@ type Org struct { } const ( - orgTable = "admin_api.orgs" + orgTable = "adminapi.orgs" ) func (o *Org) MinimumCycleDuration() time.Duration { return o.cycleDuration } diff --git a/internal/admin/repository/eventsourcing/spooler/lock.go b/internal/admin/repository/eventsourcing/spooler/lock.go index f3823015e2..76317dc700 100644 --- a/internal/admin/repository/eventsourcing/spooler/lock.go +++ b/internal/admin/repository/eventsourcing/spooler/lock.go @@ -8,7 +8,7 @@ import ( ) const ( - lockTable = "admin_api.locks" + lockTable = "adminapi.locks" lockedUntilKey = "locked_until" lockerIDKey = "locker_id" objectTypeKey = "object_type" diff --git a/internal/admin/repository/eventsourcing/spooler/lock_test.go b/internal/admin/repository/eventsourcing/spooler/lock_test.go index bb1c77ddfb..3644a41a72 100644 --- a/internal/admin/repository/eventsourcing/spooler/lock_test.go +++ b/internal/admin/repository/eventsourcing/spooler/lock_test.go @@ -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)) diff --git a/internal/admin/repository/eventsourcing/view/error_event.go b/internal/admin/repository/eventsourcing/view/error_event.go index c509425f99..2cb7bd6754 100644 --- a/internal/admin/repository/eventsourcing/view/error_event.go +++ b/internal/admin/repository/eventsourcing/view/error_event.go @@ -5,7 +5,7 @@ import ( ) const ( - errTable = "admin_api.failed_events" + errTable = "adminapi.failed_events" errColumn = "failed_events" ) diff --git a/internal/admin/repository/eventsourcing/view/iam_member.go b/internal/admin/repository/eventsourcing/view/iam_member.go index c51efae30a..df4f1c5fa4 100644 --- a/internal/admin/repository/eventsourcing/view/iam_member.go +++ b/internal/admin/repository/eventsourcing/view/iam_member.go @@ -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) { diff --git a/internal/admin/repository/eventsourcing/view/org.go b/internal/admin/repository/eventsourcing/view/org.go index efd1a29652..c1d0d74f94 100644 --- a/internal/admin/repository/eventsourcing/view/org.go +++ b/internal/admin/repository/eventsourcing/view/org.go @@ -8,7 +8,7 @@ import ( ) const ( - orgTable = "admin_api.orgs" + orgTable = "adminapi.orgs" ) func (v *View) OrgByID(orgID string) (*model.OrgView, error) { diff --git a/internal/admin/repository/eventsourcing/view/sequence.go b/internal/admin/repository/eventsourcing/view/sequence.go index df08594f91..3f6a800154 100644 --- a/internal/admin/repository/eventsourcing/view/sequence.go +++ b/internal/admin/repository/eventsourcing/view/sequence.go @@ -5,7 +5,7 @@ import ( ) const ( - sequencesTable = "admin_api.current_sequences" + sequencesTable = "adminapi.current_sequences" ) func (v *View) saveCurrentSequence(viewName string, sequence uint64) error { diff --git a/migrations/cockroach/V1.10__mgmt_orgs.sql b/migrations/cockroach/V1.10__mgmt_orgs.sql deleted file mode 100644 index 46f0d4627f..0000000000 --- a/migrations/cockroach/V1.10__mgmt_orgs.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.11__auth_oidc.sql b/migrations/cockroach/V1.11__auth_oidc.sql deleted file mode 100644 index de38f0d349..0000000000 --- a/migrations/cockroach/V1.11__auth_oidc.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.12__auth_user_grant_view.sql b/migrations/cockroach/V1.12__auth_user_grant_view.sql deleted file mode 100644 index 307f5fb6d0..0000000000 --- a/migrations/cockroach/V1.12__auth_user_grant_view.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.13__auth_org_view.sql b/migrations/cockroach/V1.13__auth_org_view.sql deleted file mode 100644 index 9cdb2da0fc..0000000000 --- a/migrations/cockroach/V1.13__auth_org_view.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.14__authz.sql b/migrations/cockroach/V1.14__authz.sql deleted file mode 100644 index 3e38e2ee6b..0000000000 --- a/migrations/cockroach/V1.14__authz.sql +++ /dev/null @@ -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; - diff --git a/migrations/cockroach/V1.15__management_project_view.sql b/migrations/cockroach/V1.15__management_project_view.sql deleted file mode 100644 index b59c56b1b9..0000000000 --- a/migrations/cockroach/V1.15__management_project_view.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.16__login_names.sql b/migrations/cockroach/V1.16__login_names.sql deleted file mode 100644 index 6a2ad281e3..0000000000 --- a/migrations/cockroach/V1.16__login_names.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.17__org_domains.sql b/migrations/cockroach/V1.17__org_domains.sql deleted file mode 100644 index f35919a551..0000000000 --- a/migrations/cockroach/V1.17__org_domains.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.18__user_view.sql b/migrations/cockroach/V1.18__user_view.sql deleted file mode 100644 index 4d27f369f9..0000000000 --- a/migrations/cockroach/V1.18__user_view.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.19__usersession_names.sql b/migrations/cockroach/V1.19__usersession_names.sql deleted file mode 100644 index e89ee9ba34..0000000000 --- a/migrations/cockroach/V1.19__usersession_names.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.1__databases.sql b/migrations/cockroach/V1.1__databases.sql new file mode 100644 index 0000000000..e1ec00597e --- /dev/null +++ b/migrations/cockroach/V1.1__databases.sql @@ -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; diff --git a/migrations/cockroach/V1.1__management.sql b/migrations/cockroach/V1.1__management.sql deleted file mode 100644 index 1746d1b2d7..0000000000 --- a/migrations/cockroach/V1.1__management.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.20__notification_passwordset.sql b/migrations/cockroach/V1.20__notification_passwordset.sql deleted file mode 100644 index 2edbdf2949..0000000000 --- a/migrations/cockroach/V1.20__notification_passwordset.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE notification.notify_users ADD COLUMN password_set BOOLEAN; - -COMMIT; \ No newline at end of file diff --git a/migrations/cockroach/V1.21__project_grant_view.sql b/migrations/cockroach/V1.21__project_grant_view.sql deleted file mode 100644 index c336fd5927..0000000000 --- a/migrations/cockroach/V1.21__project_grant_view.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE management.project_grants ADD COLUMN resource_owner_name TEXT; - -COMMIT; \ No newline at end of file diff --git a/migrations/cockroach/V1.22__admin_view.sql b/migrations/cockroach/V1.22__admin_view.sql deleted file mode 100644 index c32333b179..0000000000 --- a/migrations/cockroach/V1.22__admin_view.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.23__admin_iam_members.sql b/migrations/cockroach/V1.23__admin_iam_members.sql deleted file mode 100644 index 1b7e77b22a..0000000000 --- a/migrations/cockroach/V1.23__admin_iam_members.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.24__failed_events.sql b/migrations/cockroach/V1.24__failed_events.sql deleted file mode 100644 index b8eb5f7af9..0000000000 --- a/migrations/cockroach/V1.24__failed_events.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.25__management_user_grant.sql b/migrations/cockroach/V1.25__management_user_grant.sql deleted file mode 100644 index 078138314e..0000000000 --- a/migrations/cockroach/V1.25__management_user_grant.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE management.user_grants ADD COLUMN display_name TEXT; diff --git a/migrations/cockroach/V1.26__auth_user_grant.sql b/migrations/cockroach/V1.26__auth_user_grant.sql deleted file mode 100644 index 2978c03826..0000000000 --- a/migrations/cockroach/V1.26__auth_user_grant.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE auth.user_grants ADD COLUMN display_name TEXT; -ALTER TABLE authz.user_grants ADD COLUMN display_name TEXT; diff --git a/migrations/cockroach/V1.27__adminapi_grants.sql b/migrations/cockroach/V1.27__adminapi_grants.sql deleted file mode 100644 index 62beddff31..0000000000 --- a/migrations/cockroach/V1.27__adminapi_grants.sql +++ /dev/null @@ -1,2 +0,0 @@ -GRANT DROP ON DATABASE admin_api TO admin_api; -GRANT DROP ON TABLE admin_api.* TO admin_api; \ No newline at end of file diff --git a/migrations/cockroach/V1.2__management_project_view.sql b/migrations/cockroach/V1.2__management_project_view.sql deleted file mode 100644 index 8f88cbe113..0000000000 --- a/migrations/cockroach/V1.2__management_project_view.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.2__views.sql b/migrations/cockroach/V1.2__views.sql new file mode 100644 index 0000000000..991c81a45a --- /dev/null +++ b/migrations/cockroach/V1.2__views.sql @@ -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; diff --git a/migrations/cockroach/V1.3__management_user_view.sql b/migrations/cockroach/V1.3__management_user_view.sql deleted file mode 100644 index 4ebe4ed9aa..0000000000 --- a/migrations/cockroach/V1.3__management_user_view.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.4__admin_user_grants.sql b/migrations/cockroach/V1.4__admin_user_grants.sql deleted file mode 100644 index a31a899704..0000000000 --- a/migrations/cockroach/V1.4__admin_user_grants.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.5__auth.sql b/migrations/cockroach/V1.5__auth.sql deleted file mode 100644 index d483a62898..0000000000 --- a/migrations/cockroach/V1.5__auth.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.6__management_user_view.sql b/migrations/cockroach/V1.6__management_user_view.sql deleted file mode 100644 index 14ff398097..0000000000 --- a/migrations/cockroach/V1.6__management_user_view.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/migrations/cockroach/V1.7__notification.sql b/migrations/cockroach/V1.7__notification.sql deleted file mode 100644 index e6cc9d923a..0000000000 --- a/migrations/cockroach/V1.7__notification.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.8__admin.sql b/migrations/cockroach/V1.8__admin.sql deleted file mode 100644 index 5ec450b3d1..0000000000 --- a/migrations/cockroach/V1.8__admin.sql +++ /dev/null @@ -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; diff --git a/migrations/cockroach/V1.9__admin_grant.sql b/migrations/cockroach/V1.9__admin_grant.sql deleted file mode 100644 index c6e53ce7ff..0000000000 --- a/migrations/cockroach/V1.9__admin_grant.sql +++ /dev/null @@ -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;