From b557e8165a369c43b0b4a7d45b7719a7de4f3cb3 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Thu, 12 Dec 2024 15:15:43 +0530 Subject: [PATCH] Add dbscripts related to user store --- .../distribution/assembly.xml | 4 + .../src/main/resources/README.txt | 2 +- .../main/resources/dbscripts/db2/db2_user.sql | 587 ++++++++++++++++++ .../resources/dbscripts/mssql/mssql_user.sql | 304 +++++++++ .../resources/dbscripts/mysql/mysql_user.sql | 275 ++++++++ .../dbscripts/oracle-rac/oracle_rac_user.sql | 500 +++++++++++++++ .../dbscripts/oracle/oracle_user.sql | 505 +++++++++++++++ .../dbscripts/postgres/postgresql_user.sql | 320 ++++++++++ 8 files changed, 2496 insertions(+), 1 deletion(-) create mode 100644 monitoring-dashboard/distribution/src/main/resources/dbscripts/db2/db2_user.sql create mode 100644 monitoring-dashboard/distribution/src/main/resources/dbscripts/mssql/mssql_user.sql create mode 100644 monitoring-dashboard/distribution/src/main/resources/dbscripts/mysql/mysql_user.sql create mode 100644 monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle-rac/oracle_rac_user.sql create mode 100644 monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle/oracle_user.sql create mode 100644 monitoring-dashboard/distribution/src/main/resources/dbscripts/postgres/postgresql_user.sql diff --git a/monitoring-dashboard/distribution/assembly.xml b/monitoring-dashboard/distribution/assembly.xml index d5cd13aa7..01949f805 100644 --- a/monitoring-dashboard/distribution/assembly.xml +++ b/monitoring-dashboard/distribution/assembly.xml @@ -45,6 +45,10 @@ cipher-standalone-config.properties + + ${project.basedir}/src/main/resources/dbscripts + dbscripts + ${project.basedir}/src/main/resources/conf/security conf/security diff --git a/monitoring-dashboard/distribution/src/main/resources/README.txt b/monitoring-dashboard/distribution/src/main/resources/README.txt index ae5cb3183..16b6a7ba1 100644 --- a/monitoring-dashboard/distribution/src/main/resources/README.txt +++ b/monitoring-dashboard/distribution/src/main/resources/README.txt @@ -2,7 +2,7 @@ WSO2 Integration Control Plane ====================================================================== Welcome to the Integration Control plane ${project.version} for WSO2 Micro Integrator ${mi.version}. -This is a lightweight UI server that hosts a React application which is used to monitor the Micro Integrator runtime & ballerina services. +This is a lightweight UI server that hosts a React application which is used to monitor the Micro Integrator runtime & Ballerina services. Configure the MI servers ====================================================================== diff --git a/monitoring-dashboard/distribution/src/main/resources/dbscripts/db2/db2_user.sql b/monitoring-dashboard/distribution/src/main/resources/dbscripts/db2/db2_user.sql new file mode 100644 index 000000000..b276034c8 --- /dev/null +++ b/monitoring-dashboard/distribution/src/main/resources/dbscripts/db2/db2_user.sql @@ -0,0 +1,587 @@ +CREATE TABLE UM_TENANT( + UM_ID DECIMAL(31,0) NOT NULL, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_EMAIL VARCHAR(255), + UM_ACTIVE SMALLINT DEFAULT 0, + UM_CREATED_DATE TIMESTAMP NOT NULL, + UM_USER_CONFIG BLOB(2G) NOT LOGGED, + PRIMARY KEY(UM_ID), + UNIQUE(UM_DOMAIN_NAME) +)/ + +CREATE UNIQUE INDEX INDEX_UM_TENANT_UM_DOMAIN_NAME + ON UM_TENANT (UM_DOMAIN_NAME)/ + +CREATE SEQUENCE UM_TENANT_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_TENANT_TRIGGER NO CASCADE BEFORE INSERT ON UM_TENANT +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_TENANT_SEQUENCE); + +END/ + +CREATE TABLE UM_DOMAIN( + UM_DOMAIN_ID DECIMAL(31,0) NOT NULL, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID), + UNIQUE(UM_DOMAIN_NAME,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_DOMAIN_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_DOMAIN_TRIGGER NO CASCADE BEFORE INSERT ON UM_DOMAIN +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_DOMAIN_ID) + = (NEXTVAL FOR UM_DOMAIN_SEQUENCE); + +END/ + + +CREATE TABLE UM_USER( + UM_ID DECIMAL(31,0) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE SMALLINT DEFAULT 0, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + PRIMARY KEY(UM_ID,UM_TENANT_ID), + UNIQUE(UM_USER_NAME,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_USER_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_USER_TRIGGER NO CASCADE BEFORE INSERT ON UM_USER +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_USER_SEQUENCE); + +END/ + +CREATE TABLE UM_SYSTEM_USER ( + UM_ID DECIMAL(31,0) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE SMALLINT DEFAULT 0, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_NAME, UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_SYSTEM_USER_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_SYSTEM_USER_TRIGGER NO CASCADE BEFORE INSERT ON UM_SYSTEM_USER +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_SYSTEM_USER_SEQUENCE); + +END/ + +CREATE TABLE UM_USER_ATTRIBUTE( + UM_ID DECIMAL(31,0) NOT NULL, + UM_ATTR_NAME VARCHAR(255) NOT NULL, + UM_ATTR_VALUE VARCHAR(255), + UM_PROFILE_ID VARCHAR(255), + UM_USER_ID DECIMAL(31,0), + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + FOREIGN KEY(UM_USER_ID,UM_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE INDEX UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID)/ + +CREATE SEQUENCE UM_USER_ATTRIBUTE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_USER_ATTRIBUTE1 NO CASCADE BEFORE INSERT ON UM_USER_ATTRIBUTE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_USER_ATTRIBUTE_SEQUENCE); + +END/ + + +CREATE TABLE UM_ROLE( + UM_ID DECIMAL(31,0) NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UM_SHARED_ROLE SMALLINT DEFAULT 0, + PRIMARY KEY(UM_ID,UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_ROLE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_ROLE_TRIGGER NO CASCADE BEFORE INSERT ON UM_ROLE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_ROLE_SEQUENCE); + +END/ + +CREATE TABLE UM_MODULE( + UM_ID INTEGER NOT NULL, + UM_MODULE_NAME VARCHAR(100) NOT NULL, + PRIMARY KEY(UM_ID), + UNIQUE(UM_MODULE_NAME) +)/ + + +CREATE SEQUENCE UM_MODULE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_MODULE_TRIGGER NO CASCADE BEFORE INSERT ON UM_MODULE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_MODULE_SEQUENCE); + +END/ + + +CREATE TABLE UM_MODULE_ACTIONS( + UM_ACTION VARCHAR(255) NOT NULL, + UM_MODULE_ID INTEGER NOT NULL, + PRIMARY KEY(UM_ACTION, UM_MODULE_ID), + FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE +)/ + +CREATE TABLE UM_PERMISSION( + UM_ID DECIMAL(31,0) NOT NULL, + UM_RESOURCE_ID VARCHAR(255) NOT NULL, + UM_ACTION VARCHAR(255) NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UM_MODULE_ID INTEGER DEFAULT 0, + UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID), + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_PERMISSION_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_PERMISSION_TRI1 NO CASCADE BEFORE INSERT ON UM_PERMISSION +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_PERMISSION_SEQUENCE); + +END/ + +CREATE INDEX INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION + ON UM_PERMISSION (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID)/ + +CREATE TABLE UM_ROLE_PERMISSION( + UM_ID DECIMAL(31,0) NOT NULL, + UM_PERMISSION_ID DECIMAL(31,0) NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UM_DOMAIN_ID DECIMAL(31,0) NOT NULL, + UNIQUE(UM_PERMISSION_ID,UM_ROLE_NAME,UM_TENANT_ID,UM_DOMAIN_ID), + FOREIGN KEY(UM_PERMISSION_ID,UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_ROLE_PERMISSION_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_ROLE_PERMISSIO1 NO CASCADE BEFORE INSERT ON UM_ROLE_PERMISSION +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_ROLE_PERMISSION_SEQUENCE); + +END/ + + +CREATE TABLE UM_USER_PERMISSION( + UM_ID DECIMAL(31,0) NOT NULL, + UM_PERMISSION_ID DECIMAL(31,0) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UNIQUE(UM_PERMISSION_ID,UM_USER_NAME,UM_TENANT_ID), + FOREIGN KEY(UM_PERMISSION_ID,UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID,UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_USER_PERMISSION_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_USER_PERMISSIO1 NO CASCADE BEFORE INSERT ON UM_USER_PERMISSION +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_USER_PERMISSION_SEQUENCE); + +END/ + + +CREATE TABLE UM_USER_ROLE( + UM_ID DECIMAL(31,0) NOT NULL, + UM_ROLE_ID DECIMAL(31,0) NOT NULL, + UM_USER_ID DECIMAL(31,0) NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID), + FOREIGN KEY(UM_USER_ID,UM_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID), + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_USER_ROLE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_USER_ROLE_TRIG1 NO CASCADE BEFORE INSERT ON UM_USER_ROLE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_USER_ROLE_SEQUENCE); + +END/ + +CREATE TABLE UM_ACCOUNT_MAPPING( + UM_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER NOT NULL, + UM_USER_STORE_DOMAIN VARCHAR(100) NOT NULL, + UM_ACC_LINK_ID INTEGER NOT NULL, + UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID), + FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID) +)/ + +CREATE SEQUENCE UM_ACCOUNT_MAPPING_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_ACCOUNT_MAPPING_TRIG1 NO CASCADE BEFORE INSERT ON UM_ACCOUNT_MAPPING +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_ACCOUNT_MAPPING_SEQUENCE); + +END/ + +CREATE TABLE UM_SHARED_USER_ROLE( + UM_ROLE_ID DECIMAL(31,0) NOT NULL, + UM_USER_ID DECIMAL(31,0) NOT NULL, + UM_USER_TENANT_ID DECIMAL(31,0) NOT NULL, + UM_ROLE_TENANT_ID DECIMAL(31,0) NOT NULL, + UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE +)/ + +CREATE TABLE UM_DIALECT( + UM_ID DECIMAL(31,0) NOT NULL, + UM_DIALECT_URI VARCHAR(255) NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UNIQUE(UM_DIALECT_URI,UM_TENANT_ID), + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_DIALECT_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_DIALECT_TRIGGER NO CASCADE BEFORE INSERT ON UM_DIALECT +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_DIALECT_SEQUENCE); + +END/ + + +CREATE TABLE UM_CLAIM( + UM_ID DECIMAL(31,0) NOT NULL, + UM_DIALECT_ID DECIMAL(31,0) NOT NULL, + UM_CLAIM_URI VARCHAR(255) NOT NULL, + UM_DISPLAY_TAG VARCHAR(255), + UM_DESCRIPTION VARCHAR(255), + UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255), + UM_MAPPED_ATTRIBUTE VARCHAR(255), + UM_REG_EX VARCHAR(255), + UM_SUPPORTED SMALLINT, + UM_REQUIRED SMALLINT, + UM_DISPLAY_ORDER DECIMAL(31,0), + UM_CHECKED_ATTRIBUTE SMALLINT, + UM_READ_ONLY SMALLINT, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UNIQUE(UM_DIALECT_ID,UM_CLAIM_URI,UM_TENANT_ID), + FOREIGN KEY(UM_DIALECT_ID,UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID,UM_TENANT_ID), + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_CLAIM_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + +CREATE TRIGGER UM_CLAIM_TRIGGER NO CASCADE BEFORE INSERT ON UM_CLAIM +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_CLAIM_SEQUENCE); + +END/ + + +CREATE TABLE UM_PROFILE_CONFIG( + UM_ID DECIMAL(31,0) NOT NULL, + UM_DIALECT_ID DECIMAL(31,0), + UM_PROFILE_NAME VARCHAR(255), + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + FOREIGN KEY(UM_DIALECT_ID,UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID,UM_TENANT_ID), + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_PROFILE_CONFIG_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_PROFILE_CONFIG1 NO CASCADE BEFORE INSERT ON UM_PROFILE_CONFIG +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_PROFILE_CONFIG_SEQUENCE); + +END/ + + +CREATE TABLE UM_CLAIM_BEHAVIOR( + UM_ID DECIMAL(31,0) NOT NULL, + UM_PROFILE_ID DECIMAL(31,0), + UM_CLAIM_ID DECIMAL(31,0), + UM_BEHAVIOUR SMALLINT, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + FOREIGN KEY(UM_PROFILE_ID,UM_TENANT_ID) REFERENCES UM_PROFILE_CONFIG(UM_ID,UM_TENANT_ID), + FOREIGN KEY(UM_CLAIM_ID,UM_TENANT_ID) REFERENCES UM_CLAIM(UM_ID,UM_TENANT_ID), + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_CLAIM_BEHAVIOR_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_CLAIM_BEHAVIOR1 NO CASCADE BEFORE INSERT ON UM_CLAIM_BEHAVIOR +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_CLAIM_BEHAVIOR_SEQUENCE); + +END/ + + +CREATE TABLE UM_HYBRID_ROLE( + UM_ID DECIMAL(31,0) NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + PRIMARY KEY(UM_ID,UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME,UM_TENANT_ID) +)/ + +CREATE INDEX UM_ROLE_NAME_IND ON UM_HYBRID_ROLE(UM_ROLE_NAME)/ + +CREATE SEQUENCE UM_HYBRID_ROLE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_HYBRID_ROLE_TR1 NO CASCADE BEFORE INSERT ON UM_HYBRID_ROLE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_HYBRID_ROLE_SEQUENCE); + +END/ + + +CREATE TABLE UM_HYBRID_USER_ROLE( + UM_ID DECIMAL(31,0) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_ROLE_ID DECIMAL(31,0) NOT NULL, + UM_TENANT_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UM_DOMAIN_ID DECIMAL(31,0) DEFAULT 0 NOT NULL, + UNIQUE(UM_USER_NAME,UM_ROLE_ID,UM_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY(UM_ID,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_HYBRID_USER_ROLE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_HYBRID_USER_RO1 NO CASCADE BEFORE INSERT ON UM_HYBRID_USER_ROLE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_HYBRID_USER_ROLE_SEQUENCE); + +END/ + +CREATE TABLE UM_SYSTEM_ROLE( + UM_ID DECIMAL(31,0) NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME,UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_SYSTEM_ROLE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_SYSTEM_ROLE_TRIGGER NO CASCADE BEFORE INSERT ON UM_SYSTEM_ROLE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_SYSTEM_ROLE_SEQUENCE); + +END/ + +CREATE TABLE UM_SYSTEM_USER_ROLE( + UM_ID DECIMAL(31,0) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0 NOT NULL, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_SYSTEM_USER_ROLE_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UM_SYSTEM_USER_ROLE_TRIGGER NO CASCADE BEFORE INSERT ON UM_SYSTEM_USER_ROLE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_SYSTEM_USER_ROLE_SEQUENCE); + +END/ + + +CREATE TABLE UM_HYBRID_REMEMBER_ME ( + UM_ID DECIMAL(31,0) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_COOKIE_VALUE VARCHAR(1024), + UM_CREATED_TIME TIMESTAMP, + UM_TENANT_ID INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +)/ + +CREATE SEQUENCE UM_HYBRID_REMEMBER_ME_SEQUENCE AS DECIMAL(27,0) + INCREMENT BY 1 + START WITH 1 + NO CACHE/ + + +CREATE TRIGGER UMHYBRID_REMEMB_ME NO CASCADE BEFORE INSERT ON UM_HYBRID_REMEMBER_ME +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.UM_ID) + = (NEXTVAL FOR UM_HYBRID_REMEMBER_ME_SEQUENCE); + +END/ + diff --git a/monitoring-dashboard/distribution/src/main/resources/dbscripts/mssql/mssql_user.sql b/monitoring-dashboard/distribution/src/main/resources/dbscripts/mssql/mssql_user.sql new file mode 100644 index 000000000..90a6b7abe --- /dev/null +++ b/monitoring-dashboard/distribution/src/main/resources/dbscripts/mssql/mssql_user.sql @@ -0,0 +1,304 @@ +--CREATE TABLE UM_TENANT_ + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_TENANT]') AND TYPE IN (N'U')) +CREATE TABLE UM_TENANT ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_EMAIL VARCHAR(255), + UM_ACTIVE BIT DEFAULT 0, + UM_CREATED_DATE DATETIME NOT NULL, + UM_USER_CONFIG VARBINARY(MAX), + PRIMARY KEY (UM_ID), + UNIQUE(UM_DOMAIN_NAME)); + +IF EXISTS (SELECT NAME FROM SYSINDEXES WHERE NAME = 'INDEX_UM_TENANT_UM_DOMAIN_NAME') +DROP INDEX UM_TENANT.INDEX_UM_TENANT_UM_DOMAIN_NAME +CREATE INDEX INDEX_UM_TENANT_UM_DOMAIN_NAME ON UM_TENANT (UM_DOMAIN_NAME); + +--CREATE TABLE UM_USER + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_USER]') AND TYPE IN (N'U')) +CREATE TABLE UM_USER ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_USER_ID VARCHAR(255) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BIT DEFAULT 0, + UM_CHANGED_TIME DATETIME NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_ID, UM_TENANT_ID) +); + +--CREATE TABLE UM_DOMAIN +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_DOMAIN]') AND TYPE IN (N'U')) +CREATE TABLE UM_DOMAIN( + UM_DOMAIN_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID), + UNIQUE(UM_DOMAIN_NAME,UM_TENANT_ID) +); + + +--CREATE TABLE UM_SYSTEM_USER +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_SYSTEM_USER]') AND TYPE IN (N'U')) +CREATE TABLE UM_SYSTEM_USER ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BIT DEFAULT 0, + UM_CHANGED_TIME DATETIME NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_NAME, UM_TENANT_ID) +); + + +--CREATE TABLE UM_USER_ATTRIBUTE + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_USER_ATTRIBUTE]') AND TYPE IN (N'U')) +CREATE TABLE UM_USER_ATTRIBUTE ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_ATTR_NAME VARCHAR(255) NOT NULL, + UM_ATTR_VALUE VARCHAR(1024), + UM_PROFILE_ID VARCHAR(255), + UM_USER_ID INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID)); + +IF EXISTS (SELECT NAME FROM SYSINDEXES WHERE NAME = 'UM_USER_ID_INDEX') +DROP INDEX UM_USER_ATTRIBUTE.UM_USER_ID_INDEX +CREATE INDEX UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID); + + +--CREATE TABLE UM_ROLE + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_ROLE]') AND TYPE IN (N'U')) +CREATE TABLE UM_ROLE ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_SHARED_ROLE BIT DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME, UM_TENANT_ID) +); + + +--CREATES TABLE UM_MODULE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_MODULE]') AND TYPE IN (N'U')) +CREATE TABLE UM_MODULE( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_MODULE_NAME VARCHAR(100), + UNIQUE(UM_MODULE_NAME), + PRIMARY KEY(UM_ID) +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_MODULE_ACTIONS]') AND TYPE IN (N'U')) +CREATE TABLE UM_MODULE_ACTIONS( + UM_ACTION VARCHAR(255) NOT NULL, + UM_MODULE_ID INTEGER NOT NULL, + PRIMARY KEY(UM_ACTION, UM_MODULE_ID), + FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE +); + + +--CREATE TABLE UM_PERMISSION + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_PERMISSION]') AND TYPE IN (N'U')) +CREATE TABLE UM_PERMISSION ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_RESOURCE_ID VARCHAR(255) NOT NULL, + UM_ACTION VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_MODULE_ID INTEGER DEFAULT 0, + UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +IF EXISTS (SELECT name FROM sysindexes WHERE name = 'INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION') +DROP INDEX UM_PERMISSION.INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION +CREATE INDEX INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION ON UM_PERMISSION (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID); + +--CREATE TABLE UM_ROLE_PERMISSION + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_ROLE_PERMISSION]') AND TYPE IN (N'U')) +CREATE TABLE UM_ROLE_PERMISSION ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_PERMISSION_ID, UM_ROLE_NAME, UM_TENANT_ID, UM_DOMAIN_ID), + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +--CREATE TABLE UM_USER_PERMISSION +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_USER_PERMISSION]') AND TYPE IN (N'U')) +CREATE TABLE UM_USER_PERMISSION ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_PERMISSION_ID, UM_USER_NAME, UM_TENANT_ID), + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- create table UM_USER_ROLE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_USER_ROLE]') AND TYPE IN (N'U')) +CREATE TABLE UM_USER_ROLE ( + UM_ID INTEGER IDENTITY(1,1) NOT NULL, + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_SHARED_USER_ROLE]') AND TYPE IN (N'U')) +CREATE TABLE UM_SHARED_USER_ROLE( + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_USER_TENANT_ID INTEGER NOT NULL, + UM_ROLE_TENANT_ID INTEGER NOT NULL, + UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_ACCOUNT_MAPPING]') AND TYPE IN (N'U')) +CREATE TABLE UM_ACCOUNT_MAPPING( + UM_ID INTEGER IDENTITY(1,1), + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER NOT NULL, + UM_USER_STORE_DOMAIN VARCHAR(100), + UM_ACC_LINK_ID INTEGER NOT NULL, + UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID), + FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID) +); + + +-- create table UM_DIALECT +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_DIALECT]') AND TYPE IN (N'U')) +CREATE TABLE UM_DIALECT( + UM_ID INTEGER IDENTITY(1, 1), + UM_DIALECT_URI VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_URI, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- create table UM_CLAIM +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_CLAIM]') AND TYPE IN (N'U')) +CREATE TABLE UM_CLAIM( + UM_ID INTEGER IDENTITY(1, 1), + UM_DIALECT_ID INTEGER, + UM_CLAIM_URI VARCHAR(255), + UM_DISPLAY_TAG VARCHAR(255), + UM_DESCRIPTION VARCHAR(255), + UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255), + UM_MAPPED_ATTRIBUTE VARCHAR(255), + UM_REG_EX VARCHAR(255), + UM_SUPPORTED SMALLINT, + UM_REQUIRED SMALLINT, + UM_DISPLAY_ORDER INTEGER, + UM_CHECKED_ATTRIBUTE SMALLINT, + UM_READ_ONLY SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_ID, UM_CLAIM_URI, UM_TENANT_ID,UM_MAPPED_ATTRIBUTE_DOMAIN), + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- create table UM_PROFILE_CONFIG +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_PROFILE_CONFIG]') AND TYPE IN (N'U')) +CREATE TABLE UM_PROFILE_CONFIG( + UM_ID INTEGER IDENTITY(1, 1), + UM_DIALECT_ID INTEGER, + UM_PROFILE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- create table UM_CLAIM_BEHAVIOR +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_CLAIM_BEHAVIOR]') AND TYPE IN (N'U')) +CREATE TABLE UM_CLAIM_BEHAVIOR( + UM_ID INTEGER IDENTITY(1, 1), + UM_PROFILE_ID INTEGER, + UM_CLAIM_ID INTEGER, + UM_BEHAVIOUR SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_PROFILE_ID, UM_TENANT_ID) REFERENCES UM_PROFILE_CONFIG(UM_ID, UM_TENANT_ID), + FOREIGN KEY(UM_CLAIM_ID, UM_TENANT_ID) REFERENCES UM_CLAIM(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- create table UM_HYBRID_ROLE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_HYBRID_ROLE]') AND TYPE IN (N'U')) +CREATE TABLE UM_HYBRID_ROLE( + UM_ID INTEGER IDENTITY(1, 1), + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) +); + +CREATE INDEX UM_ROLE_NAME_IND ON UM_HYBRID_ROLE(UM_ROLE_NAME); + +-- create table UM_HYBRID_USER_ROLE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_HYBRID_USER_ROLE]') AND TYPE IN (N'U')) +CREATE TABLE UM_HYBRID_USER_ROLE( + UM_ID INTEGER IDENTITY(1, 1) NOT NULL, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID, UM_DOMAIN_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); +-- create table UM_SYSTEM_ROLE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_SYSTEM_ROLE]') AND TYPE IN (N'U')) +CREATE TABLE UM_SYSTEM_ROLE( + UM_ID INTEGER IDENTITY(1, 1) NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME,UM_TENANT_ID) +); + +-- create table UM_SYSTEM_USER_ROLE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_SYSTEM_USER_ROLE]') AND TYPE IN (N'U')) +CREATE TABLE UM_SYSTEM_USER_ROLE( + UM_ID INTEGER IDENTITY(1, 1), + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- create table UM_HYBRID_USER_ROLE +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[UM_HYBRID_REMEMBER_ME]') AND TYPE IN (N'U')) +CREATE TABLE UM_HYBRID_REMEMBER_ME( + UM_ID INTEGER IDENTITY(1, 1), + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_COOKIE_VALUE VARCHAR(1024), + UM_CREATED_TIME DATETIME, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); diff --git a/monitoring-dashboard/distribution/src/main/resources/dbscripts/mysql/mysql_user.sql b/monitoring-dashboard/distribution/src/main/resources/dbscripts/mysql/mysql_user.sql new file mode 100644 index 000000000..4b16b85f8 --- /dev/null +++ b/monitoring-dashboard/distribution/src/main/resources/dbscripts/mysql/mysql_user.sql @@ -0,0 +1,275 @@ +CREATE TABLE UM_TENANT +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_EMAIL VARCHAR(255), + UM_ACTIVE BOOLEAN DEFAULT FALSE, + UM_CREATED_DATE TIMESTAMP NOT NULL, + UM_USER_CONFIG LONGBLOB, + PRIMARY KEY (UM_ID), + UNIQUE (UM_DOMAIN_NAME) +) ENGINE INNODB; + +CREATE TABLE UM_DOMAIN +( + UM_DOMAIN_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID), + UNIQUE (UM_DOMAIN_NAME, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE UNIQUE INDEX INDEX_UM_TENANT_UM_DOMAIN_NAME + ON UM_TENANT (UM_DOMAIN_NAME); + +CREATE TABLE UM_USER +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_ID VARCHAR(255) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_USER_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE UM_SYSTEM_USER +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_USER_NAME, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE UM_ROLE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_SHARED_ROLE BOOLEAN DEFAULT FALSE, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) +) ENGINE INNODB; + + +CREATE TABLE UM_MODULE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_MODULE_NAME VARCHAR(100), + UNIQUE (UM_MODULE_NAME), + PRIMARY KEY (UM_ID) +) ENGINE INNODB; + +CREATE TABLE UM_MODULE_ACTIONS +( + UM_ACTION VARCHAR(255) NOT NULL, + UM_MODULE_ID INTEGER NOT NULL, + PRIMARY KEY (UM_ACTION, UM_MODULE_ID), + FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE (UM_ID) ON DELETE CASCADE +) ENGINE INNODB; + +CREATE TABLE UM_PERMISSION +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_RESOURCE_ID VARCHAR(255) NOT NULL, + UM_ACTION VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_MODULE_ID INTEGER DEFAULT 0, + UNIQUE (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE INDEX INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION ON UM_PERMISSION (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID); + +CREATE TABLE UM_ROLE_PERMISSION +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_PERMISSION_ID, UM_ROLE_NAME, UM_TENANT_ID, UM_DOMAIN_ID), + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION (UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN (UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +-- REMOVED UNIQUE (UM_PERMISSION_ID, UM_ROLE_ID) +CREATE TABLE UM_USER_PERMISSION +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION (UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +-- REMOVED UNIQUE (UM_PERMISSION_ID, UM_USER_ID) +CREATE TABLE UM_USER_ROLE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE (UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER (UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE UM_SHARED_USER_ROLE +( + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_USER_TENANT_ID INTEGER NOT NULL, + UM_ROLE_TENANT_ID INTEGER NOT NULL, + UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_USER_TENANT_ID, UM_ROLE_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_ROLE_TENANT_ID) REFERENCES UM_ROLE (UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_USER_ID, UM_USER_TENANT_ID) REFERENCES UM_USER (UM_ID, UM_TENANT_ID) ON DELETE CASCADE +) ENGINE INNODB; + +CREATE TABLE UM_ACCOUNT_MAPPING +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER NOT NULL, + UM_USER_STORE_DOMAIN VARCHAR(100), + UM_ACC_LINK_ID INTEGER NOT NULL, + UNIQUE (UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID), + FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT (UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID) +) ENGINE INNODB; + + +CREATE TABLE UM_USER_ATTRIBUTE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ATTR_NAME VARCHAR(255) NOT NULL, + UM_ATTR_VALUE VARCHAR(1024), + UM_PROFILE_ID VARCHAR(255), + UM_USER_ID INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER (UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE INDEX UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE (UM_USER_ID); + +CREATE TABLE UM_DIALECT +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DIALECT_URI VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_DIALECT_URI, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE UM_CLAIM +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DIALECT_ID INTEGER NOT NULL, + UM_CLAIM_URI VARCHAR(255) NOT NULL, + UM_DISPLAY_TAG VARCHAR(255), + UM_DESCRIPTION VARCHAR(255), + UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255), + UM_MAPPED_ATTRIBUTE VARCHAR(255), + UM_REG_EX VARCHAR(255), + UM_SUPPORTED SMALLINT, + UM_REQUIRED SMALLINT, + UM_DISPLAY_ORDER INTEGER, + UM_CHECKED_ATTRIBUTE SMALLINT, + UM_READ_ONLY SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_DIALECT_ID, UM_CLAIM_URI, UM_TENANT_ID, UM_MAPPED_ATTRIBUTE_DOMAIN), + FOREIGN KEY (UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT (UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + + +CREATE TABLE UM_PROFILE_CONFIG +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_DIALECT_ID INTEGER NOT NULL, + UM_PROFILE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT (UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS UM_CLAIM_BEHAVIOR +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_PROFILE_ID INTEGER, + UM_CLAIM_ID INTEGER, + UM_BEHAVIOUR SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_PROFILE_ID, UM_TENANT_ID) REFERENCES UM_PROFILE_CONFIG (UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_CLAIM_ID, UM_TENANT_ID) REFERENCES UM_CLAIM (UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE UM_HYBRID_ROLE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE INDEX UM_ROLE_NAME_IND ON UM_HYBRID_ROLE (UM_ROLE_NAME); + +CREATE TABLE UM_HYBRID_USER_ROLE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID, UM_DOMAIN_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE (UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN (UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE UM_SYSTEM_ROLE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) +) ENGINE INNODB; + +CREATE TABLE UM_SYSTEM_USER_ROLE +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE (UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; + + +CREATE TABLE UM_HYBRID_REMEMBER_ME +( + UM_ID INTEGER NOT NULL AUTO_INCREMENT, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_COOKIE_VALUE VARCHAR(1024), + UM_CREATED_TIME TIMESTAMP, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) ENGINE INNODB; diff --git a/monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle-rac/oracle_rac_user.sql b/monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle-rac/oracle_rac_user.sql new file mode 100644 index 000000000..902c9f770 --- /dev/null +++ b/monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle-rac/oracle_rac_user.sql @@ -0,0 +1,500 @@ +CREATE TABLE UM_TENANT ( + UM_ID INTEGER, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_EMAIL VARCHAR(255), + UM_ACTIVE NUMBER(1) DEFAULT 0, + UM_CREATED_DATE TIMESTAMP NOT NULL, + UM_USER_CONFIG BLOB, + PRIMARY KEY (UM_ID), + UNIQUE(UM_DOMAIN_NAME)) +/ +CREATE SEQUENCE UM_TENANT_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_TENANT_TRIGGER + BEFORE INSERT + ON UM_TENANT + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_TENANT_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_DOMAIN( + UM_DOMAIN_ID INTEGER NOT NULL, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID), + UNIQUE(UM_DOMAIN_NAME,UM_TENANT_ID) +) +/ + +CREATE SEQUENCE UM_DOMAIN_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ + +CREATE OR REPLACE TRIGGER UM_DOMAIN_TRIGGER + BEFORE INSERT + ON UM_DOMAIN + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_DOMAIN_SEQUENCE.nextval INTO :NEW.UM_DOMAIN_ID FROM dual; + END; +/ + +CREATE TABLE UM_USER ( + UM_ID INTEGER, + UM_USER_ID VARCHAR2(255) NOT NULL, + UM_USER_NAME VARCHAR2(255) NOT NULL, + UM_USER_PASSWORD VARCHAR2(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE NUMBER(1) DEFAULT 0, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_USER_TRIGGER + BEFORE INSERT + ON UM_USER + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_SYSTEM_USER ( + UM_ID INTEGER, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE NUMBER(1) DEFAULT 0, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_NAME, UM_TENANT_ID)) + +/ + +CREATE SEQUENCE UM_SYSTEM_USER_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ + +CREATE OR REPLACE TRIGGER UM_SYSTEM_USER_TRIGGER + BEFORE INSERT + ON UM_SYSTEM_USER + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_SYSTEM_USER_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_USER_ATTRIBUTE ( + UM_ID INTEGER, + UM_ATTR_NAME VARCHAR2(255) NOT NULL, + UM_ATTR_VALUE VARCHAR2(255), + UM_PROFILE_ID VARCHAR(255), + UM_USER_ID INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_ATTRIBUTE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE INDEX UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID) +/ +CREATE OR REPLACE TRIGGER UM_USER_ATTRIBUTE_TRIGGER + BEFORE INSERT + ON UM_USER_ATTRIBUTE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_ATTRIBUTE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_ROLE ( + UM_ID INTEGER, + UM_ROLE_NAME VARCHAR2(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_SHARED_ROLE CHAR(1) DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_ROLE_TRIGGER + BEFORE INSERT + ON UM_ROLE + + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_MODULE( + UM_ID INTEGER, + UM_MODULE_NAME VARCHAR(100), + UNIQUE(UM_MODULE_NAME), + PRIMARY KEY(UM_ID) +) +/ + +CREATE SEQUENCE UM_MODULE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ + +CREATE OR REPLACE TRIGGER UM_MODULE_TRIGGER + BEFORE INSERT + ON UM_MODULE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_MODULE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_MODULE_ACTIONS( + UM_ACTION VARCHAR(255) NOT NULL, + UM_MODULE_ID INTEGER NOT NULL, + PRIMARY KEY(UM_ACTION, UM_MODULE_ID), + FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE +) +/ + +CREATE TABLE UM_PERMISSION ( + UM_ID INTEGER, + UM_RESOURCE_ID VARCHAR2(255) NOT NULL, + UM_ACTION VARCHAR2(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_MODULE_ID INTEGER DEFAULT 0, + UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_PERMISSION_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_PERMISSION_TRIGGER + BEFORE INSERT + ON UM_PERMISSION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_PERMISSION_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ +CREATE TABLE UM_ROLE_PERMISSION ( + UM_ID INTEGER, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + --FOREIGN KEY (UM_ROLE_ID) REFERENCES UM_ROLE(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_ROLE_PERMISSION_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_ROLE_PERMISSION_TRIGGER + BEFORE INSERT + ON UM_ROLE_PERMISSION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_ROLE_PERMISSION_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_USER_PERMISSION ( + UM_ID INTEGER, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_PERMISSION_ID, UM_USER_NAME, UM_TENANT_ID), + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + --FOREIGN KEY (UM_USER_ID) REFERENCES UM_USER(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_PERMISSION_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_USER_PERMISSION_TRIGGER + BEFORE INSERT + ON UM_USER_PERMISSION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_PERMISSION_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_USER_ROLE ( + UM_ID INTEGER, + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_USER_ROLE_TRIGGER + BEFORE INSERT + ON UM_USER_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_SHARED_USER_ROLE( + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_USER_TENANT_ID INTEGER NOT NULL, + UM_ROLE_TENANT_ID INTEGER NOT NULL, + UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE +) +/ + +CREATE TABLE UM_ACCOUNT_MAPPING( + UM_ID INTEGER, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER NOT NULL, + UM_USER_STORE_DOMAIN VARCHAR(100), + UM_ACC_LINK_ID INTEGER NOT NULL, + UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID), + FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID) +) +/ + +CREATE SEQUENCE UM_ACCOUNT_MAPPING_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_ACCOUNT_MAPPING_TRIGGER + BEFORE INSERT + ON UM_ACCOUNT_MAPPING + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_ACCOUNT_MAPPING_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_DIALECT( + UM_ID INTEGER, + UM_DIALECT_URI VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_URI, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_DIALECT_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_DIALECT_TRIGGER + BEFORE INSERT + ON UM_DIALECT + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_DIALECT_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_CLAIM( + UM_ID INTEGER, + UM_DIALECT_ID INTEGER NOT NULL, + UM_CLAIM_URI VARCHAR(255) NOT NULL, + UM_DISPLAY_TAG VARCHAR(255), + UM_DESCRIPTION VARCHAR(255), + UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255), + UM_MAPPED_ATTRIBUTE VARCHAR(255), + UM_REG_EX VARCHAR(255), + UM_SUPPORTED SMALLINT, + UM_REQUIRED SMALLINT, + UM_DISPLAY_ORDER INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_CHECKED_ATTRIBUTE SMALLINT, + UM_READ_ONLY SMALLINT, + UNIQUE(UM_DIALECT_ID, UM_CLAIM_URI, UM_MAPPED_ATTRIBUTE_DOMAIN, UM_TENANT_ID), + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_CLAIM_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_CLAIM_TRIGGER + BEFORE INSERT + ON UM_CLAIM + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_CLAIM_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_PROFILE_CONFIG( + UM_ID INTEGER, + UM_DIALECT_ID INTEGER, + UM_PROFILE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_PROFILE_CONFIG_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_PROFILE_CONFIG_TRIGGER + BEFORE INSERT + ON UM_PROFILE_CONFIG + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_PROFILE_CONFIG_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_CLAIM_BEHAVIOR( + UM_ID INTEGER, + UM_PROFILE_ID INTEGER, + UM_CLAIM_ID INTEGER, + UM_BEHAVIOUR SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_PROFILE_ID, UM_TENANT_ID) REFERENCES UM_PROFILE_CONFIG(UM_ID, UM_TENANT_ID), + FOREIGN KEY(UM_CLAIM_ID, UM_TENANT_ID) REFERENCES UM_CLAIM(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_CLAIM_BEHAVIOR_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_CLAIM_BEHAVIOR_TRIGGER + BEFORE INSERT + ON UM_CLAIM_BEHAVIOR + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_CLAIM_BEHAVIOR_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_HYBRID_ROLE( + UM_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) +) +/ +CREATE INDEX UM_ROLE_NAME_IND ON UM_HYBRID_ROLE(UM_ROLE_NAME) +/ +CREATE SEQUENCE UM_HYBRID_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_HYBRID_ROLE_TRIGGER + BEFORE INSERT + ON UM_HYBRID_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_HYBRID_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ +CREATE TABLE UM_HYBRID_USER_ROLE( + UM_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID, UM_DOMAIN_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID,UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_HYBRID_USER_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_HYBRID_USER_ROLE_TRIGGER + BEFORE INSERT + ON UM_HYBRID_USER_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_HYBRID_USER_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ +CREATE TABLE UM_HYBRID_REMEMBER_ME( + UM_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_COOKIE_VALUE VARCHAR(1024), + UM_CREATED_TIME TIMESTAMP, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_HYBRID_REMEMBER_ME_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_HYBRID_REMEMBER_ME_TRIGGER + BEFORE INSERT + ON UM_HYBRID_REMEMBER_ME + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_HYBRID_REMEMBER_ME_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_SYSTEM_ROLE( + UM_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME,UM_TENANT_ID) +) +/ + +CREATE SEQUENCE UM_SYSTEM_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_SYSTEM_ROLE_TRIGGER + BEFORE INSERT + ON UM_SYSTEM_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_SYSTEM_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_SYSTEM_USER_ROLE( + UM_ID INTEGER, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ + +CREATE SEQUENCE UM_SYSTEM_USER_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER UM_SYSTEM_USER_ROLE_TRIGGER + BEFORE INSERT + ON UM_SYSTEM_USER_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_SYSTEM_USER_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ diff --git a/monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle/oracle_user.sql b/monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle/oracle_user.sql new file mode 100644 index 000000000..3409cff7c --- /dev/null +++ b/monitoring-dashboard/distribution/src/main/resources/dbscripts/oracle/oracle_user.sql @@ -0,0 +1,505 @@ +CREATE TABLE UM_TENANT ( + UM_ID INTEGER, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_EMAIL VARCHAR(255), + UM_ACTIVE NUMBER(1) DEFAULT 0, + UM_CREATED_DATE TIMESTAMP NOT NULL, + UM_USER_CONFIG BLOB, + PRIMARY KEY (UM_ID), + UNIQUE(UM_DOMAIN_NAME)) +/ +CREATE SEQUENCE UM_TENANT_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_TENANT_TRIGGER + BEFORE INSERT + ON UM_TENANT + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_TENANT_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_DOMAIN( + UM_DOMAIN_ID INTEGER NOT NULL, + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID), + UNIQUE(UM_DOMAIN_NAME,UM_TENANT_ID) +) +/ + +CREATE SEQUENCE UM_DOMAIN_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER UM_DOMAIN_TRIGGER + BEFORE INSERT + ON UM_DOMAIN + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_DOMAIN_SEQUENCE.nextval INTO :NEW.UM_DOMAIN_ID FROM dual; + END; +/ + +CREATE TABLE UM_USER ( + UM_ID INTEGER, + UM_USER_ID VARCHAR2(255) NOT NULL, + UM_USER_NAME VARCHAR2(255) NOT NULL, + UM_USER_PASSWORD VARCHAR2(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE NUMBER(1) DEFAULT 0, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_USER_TRIGGER + BEFORE INSERT + ON UM_USER + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_SYSTEM_USER ( + UM_ID INTEGER, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE NUMBER(1) DEFAULT 0, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_NAME, UM_TENANT_ID)) + +/ + +CREATE SEQUENCE UM_SYSTEM_USER_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER UM_SYSTEM_USER_TRIGGER + BEFORE INSERT + ON UM_SYSTEM_USER + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_SYSTEM_USER_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_USER_ATTRIBUTE ( + UM_ID INTEGER, + UM_ATTR_NAME VARCHAR2(255) NOT NULL, + UM_ATTR_VALUE VARCHAR2(255), + UM_PROFILE_ID VARCHAR(255), + UM_USER_ID INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_ATTRIBUTE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE INDEX UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID) +/ +CREATE OR REPLACE TRIGGER UM_USER_ATTRIBUTE_TRIGGER + BEFORE INSERT + ON UM_USER_ATTRIBUTE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_ATTRIBUTE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_ROLE ( + UM_ID INTEGER, + UM_ROLE_NAME VARCHAR2(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_SHARED_ROLE CHAR(1) DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_ROLE_TRIGGER + BEFORE INSERT + ON UM_ROLE + + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_MODULE( + UM_ID INTEGER, + UM_MODULE_NAME VARCHAR(100), + UNIQUE(UM_MODULE_NAME), + PRIMARY KEY(UM_ID) +) +/ + +CREATE SEQUENCE UM_MODULE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER UM_MODULE_TRIGGER + BEFORE INSERT + ON UM_MODULE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_MODULE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_MODULE_ACTIONS( + UM_ACTION VARCHAR(255) NOT NULL, + UM_MODULE_ID INTEGER NOT NULL, + PRIMARY KEY(UM_ACTION, UM_MODULE_ID), + FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE +) +/ + +CREATE TABLE UM_PERMISSION ( + UM_ID INTEGER, + UM_RESOURCE_ID VARCHAR2(255) NOT NULL, + UM_ACTION VARCHAR2(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_MODULE_ID INTEGER DEFAULT 0, + UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_PERMISSION_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_PERMISSION_TRIGGER + BEFORE INSERT + ON UM_PERMISSION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_PERMISSION_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ +CREATE TABLE UM_ROLE_PERMISSION ( + UM_ID INTEGER, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + --FOREIGN KEY (UM_ROLE_ID) REFERENCES UM_ROLE(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_ROLE_PERMISSION_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_ROLE_PERMISSION_TRIGGER + BEFORE INSERT + ON UM_ROLE_PERMISSION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_ROLE_PERMISSION_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_USER_PERMISSION ( + UM_ID INTEGER, + UM_PERMISSION_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_PERMISSION_ID, UM_USER_NAME, UM_TENANT_ID), + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + --FOREIGN KEY (UM_USER_ID) REFERENCES UM_USER(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_PERMISSION_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_USER_PERMISSION_TRIGGER + BEFORE INSERT + ON UM_USER_PERMISSION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_PERMISSION_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_USER_ROLE ( + UM_ID INTEGER, + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID)) +/ +CREATE SEQUENCE UM_USER_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_USER_ROLE_TRIGGER + BEFORE INSERT + ON UM_USER_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_USER_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_SHARED_USER_ROLE( + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_USER_TENANT_ID INTEGER NOT NULL, + UM_ROLE_TENANT_ID INTEGER NOT NULL, + UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE +) +/ + +CREATE TABLE UM_ACCOUNT_MAPPING( + UM_ID INTEGER, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER NOT NULL, + UM_USER_STORE_DOMAIN VARCHAR(100), + UM_ACC_LINK_ID INTEGER NOT NULL, + UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID), + FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID) +) +/ + +CREATE SEQUENCE UM_ACCOUNT_MAPPING_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_ACCOUNT_MAPPING_TRIGGER + BEFORE INSERT + ON UM_ACCOUNT_MAPPING + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_ACCOUNT_MAPPING_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_DIALECT( + UM_ID INTEGER, + UM_DIALECT_URI VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_URI, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_DIALECT_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_DIALECT_TRIGGER + BEFORE INSERT + ON UM_DIALECT + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_DIALECT_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_CLAIM( + UM_ID INTEGER, + UM_DIALECT_ID INTEGER NOT NULL, + UM_CLAIM_URI VARCHAR(255) NOT NULL, + UM_DISPLAY_TAG VARCHAR(255), + UM_DESCRIPTION VARCHAR(255), + UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255), + UM_MAPPED_ATTRIBUTE VARCHAR(255), + UM_REG_EX VARCHAR(255), + UM_SUPPORTED SMALLINT, + UM_REQUIRED SMALLINT, + UM_DISPLAY_ORDER INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_CHECKED_ATTRIBUTE SMALLINT, + UM_READ_ONLY SMALLINT, + UNIQUE(UM_DIALECT_ID, UM_CLAIM_URI, UM_MAPPED_ATTRIBUTE_DOMAIN, UM_TENANT_ID), + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_CLAIM_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_CLAIM_TRIGGER + BEFORE INSERT + ON UM_CLAIM + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_CLAIM_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_PROFILE_CONFIG( + UM_ID INTEGER, + UM_DIALECT_ID INTEGER, + UM_PROFILE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_PROFILE_CONFIG_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_PROFILE_CONFIG_TRIGGER + BEFORE INSERT + ON UM_PROFILE_CONFIG + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_PROFILE_CONFIG_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_CLAIM_BEHAVIOR( + UM_ID INTEGER, + UM_PROFILE_ID INTEGER, + UM_CLAIM_ID INTEGER, + UM_BEHAVIOUR SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_PROFILE_ID, UM_TENANT_ID) REFERENCES UM_PROFILE_CONFIG(UM_ID, UM_TENANT_ID), + FOREIGN KEY(UM_CLAIM_ID, UM_TENANT_ID) REFERENCES UM_CLAIM(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_CLAIM_BEHAVIOR_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_CLAIM_BEHAVIOR_TRIGGER + BEFORE INSERT + ON UM_CLAIM_BEHAVIOR + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_CLAIM_BEHAVIOR_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + +CREATE TABLE UM_HYBRID_ROLE( + UM_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) +) +/ +CREATE INDEX UM_ROLE_NAME_IND ON UM_HYBRID_ROLE(UM_ROLE_NAME) +/ + +CREATE SEQUENCE UM_HYBRID_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_HYBRID_ROLE_TRIGGER + BEFORE INSERT + ON UM_HYBRID_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_HYBRID_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ +CREATE TABLE UM_HYBRID_USER_ROLE( + UM_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID, UM_DOMAIN_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID,UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_HYBRID_USER_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_HYBRID_USER_ROLE_TRIGGER + BEFORE INSERT + ON UM_HYBRID_USER_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_HYBRID_USER_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ +CREATE TABLE UM_HYBRID_REMEMBER_ME( + UM_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_COOKIE_VALUE VARCHAR(1024), + UM_CREATED_TIME TIMESTAMP, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ +CREATE SEQUENCE UM_HYBRID_REMEMBER_ME_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_HYBRID_REMEMBER_ME_TRIGGER + BEFORE INSERT + ON UM_HYBRID_REMEMBER_ME + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_HYBRID_REMEMBER_ME_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + +CREATE TABLE UM_SYSTEM_ROLE( + UM_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME,UM_TENANT_ID) +) +/ + +CREATE SEQUENCE UM_SYSTEM_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER UM_SYSTEM_ROLE_TRIGGER + BEFORE INSERT + ON UM_SYSTEM_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_SYSTEM_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + + + +CREATE TABLE UM_SYSTEM_USER_ROLE( + UM_ID INTEGER, + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +) +/ + +CREATE SEQUENCE UM_SYSTEM_USER_ROLE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER UM_SYSTEM_USER_ROLE_TRIGGER + BEFORE INSERT + ON UM_SYSTEM_USER_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT UM_SYSTEM_USER_ROLE_SEQUENCE.nextval INTO :NEW.UM_ID FROM dual; + END; +/ + diff --git a/monitoring-dashboard/distribution/src/main/resources/dbscripts/postgres/postgresql_user.sql b/monitoring-dashboard/distribution/src/main/resources/dbscripts/postgres/postgresql_user.sql new file mode 100644 index 000000000..da605b4d9 --- /dev/null +++ b/monitoring-dashboard/distribution/src/main/resources/dbscripts/postgres/postgresql_user.sql @@ -0,0 +1,320 @@ +DROP TABLE IF EXISTS UM_TENANT; +DROP SEQUENCE IF EXISTS UM_TENANT_PK_SEQ; +CREATE SEQUENCE UM_TENANT_PK_SEQ; +CREATE TABLE UM_TENANT ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_TENANT_PK_SEQ'), + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_EMAIL VARCHAR(255), + UM_ACTIVE BOOLEAN DEFAULT FALSE, + UM_CREATED_DATE TIMESTAMP NOT NULL, + UM_USER_CONFIG BYTEA, + PRIMARY KEY (UM_ID), + UNIQUE(UM_DOMAIN_NAME)); + +CREATE INDEX INDEX_UM_TENANT_UM_DOMAIN_NAME + ON UM_TENANT (UM_DOMAIN_NAME); + + +DROP TABLE IF EXISTS UM_DOMAIN; +DROP SEQUENCE IF EXISTS UM_DOMAIN_PK_SEQ; +CREATE SEQUENCE UM_DOMAIN_PK_SEQ; +CREATE TABLE UM_DOMAIN( + UM_DOMAIN_ID INTEGER DEFAULT NEXTVAL('UM_DOMAIN_PK_SEQ'), + UM_DOMAIN_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID), + UNIQUE(UM_DOMAIN_NAME,UM_TENANT_ID) +); + + +DROP TABLE IF EXISTS UM_USER CASCADE; +DROP SEQUENCE IF EXISTS UM_USER_PK_SEQ; +CREATE SEQUENCE UM_USER_PK_SEQ; +CREATE TABLE UM_USER ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_USER_PK_SEQ'), + UM_USER_ID VARCHAR(255) NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_ID, UM_TENANT_ID) +); + + +DROP TABLE IF EXISTS UM_SYSTEM_USER CASCADE; +DROP SEQUENCE IF EXISTS UM_SYSTEM_USER_PK_SEQ; +CREATE SEQUENCE UM_SYSTEM_USER_PK_SEQ; +CREATE TABLE UM_SYSTEM_USER ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_SYSTEM_USER_PK_SEQ'), + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_USER_PASSWORD VARCHAR(255) NOT NULL, + UM_SALT_VALUE VARCHAR(31), + UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE, + UM_CHANGED_TIME TIMESTAMP NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_USER_NAME, UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_ROLE CASCADE; +DROP SEQUENCE IF EXISTS UM_ROLE_PK_SEQ; +CREATE SEQUENCE UM_ROLE_PK_SEQ; +CREATE TABLE UM_ROLE ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_ROLE_PK_SEQ'), + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_SHARED_ROLE BOOLEAN DEFAULT FALSE, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME, UM_TENANT_ID) +); + + +DROP TABLE IF EXISTS UM_MODULE CASCADE; +DROP SEQUENCE IF EXISTS UM_MODULE_PK_SEQ; +CREATE SEQUENCE UM_MODULE_PK_SEQ; +CREATE TABLE UM_MODULE( + UM_ID INTEGER DEFAULT NEXTVAL('UM_MODULE_PK_SEQ'), + UM_MODULE_NAME VARCHAR(100), + UNIQUE(UM_MODULE_NAME), + PRIMARY KEY(UM_ID) +); + +DROP TABLE IF EXISTS UM_MODULE_ACTIONS CASCADE; +CREATE TABLE UM_MODULE_ACTIONS( + UM_ACTION VARCHAR(255) NOT NULL, + UM_MODULE_ID INTEGER NOT NULL, + PRIMARY KEY(UM_ACTION, UM_MODULE_ID), + FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE +); + + +DROP TABLE IF EXISTS UM_PERMISSION CASCADE; +DROP SEQUENCE IF EXISTS UM_PERMISSION_PK_SEQ; +CREATE SEQUENCE UM_PERMISSION_PK_SEQ; +CREATE TABLE UM_PERMISSION ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_PERMISSION_PK_SEQ'), + UM_RESOURCE_ID VARCHAR(255) NOT NULL, + UM_ACTION VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_MODULE_ID INTEGER DEFAULT 0, + UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +CREATE INDEX INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION + ON UM_PERMISSION (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID); + + +DROP TABLE IF EXISTS UM_ROLE_PERMISSION; +DROP SEQUENCE IF EXISTS UM_ROLE_PERMISSION_PK_SEQ; +CREATE SEQUENCE UM_ROLE_PERMISSION_PK_SEQ; +CREATE TABLE UM_ROLE_PERMISSION ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_ROLE_PERMISSION_PK_SEQ'), + UM_PERMISSION_ID INTEGER NOT NULL, + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- REMOVED UNIQUE (UM_PERMISSION_ID, UM_ROLE_ID) +DROP TABLE IF EXISTS UM_USER_PERMISSION; +DROP SEQUENCE IF EXISTS UM_USER_PERMISSION_PK_SEQ; +CREATE SEQUENCE UM_USER_PERMISSION_PK_SEQ; +CREATE TABLE UM_USER_PERMISSION ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_USER_PERMISSION_PK_SEQ'), + UM_PERMISSION_ID INTEGER NOT NULL, + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_IS_ALLOWED SMALLINT NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +-- REMOVED UNIQUE (UM_PERMISSION_ID, UM_USER_ID) +DROP TABLE IF EXISTS UM_USER_ROLE; +DROP SEQUENCE IF EXISTS UM_USER_ROLE_PK_SEQ; +CREATE SEQUENCE UM_USER_ROLE_PK_SEQ; +CREATE TABLE UM_USER_ROLE ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_USER_ROLE_PK_SEQ'), + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID, UM_TENANT_ID), + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_SHARED_USER_ROLE; +CREATE TABLE UM_SHARED_USER_ROLE( + UM_ROLE_ID INTEGER NOT NULL, + UM_USER_ID INTEGER NOT NULL, + UM_USER_TENANT_ID INTEGER NOT NULL, + UM_ROLE_TENANT_ID INTEGER NOT NULL, + UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID), + FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE , + FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE +); + +DROP TABLE IF EXISTS UM_ACCOUNT_MAPPING; +DROP SEQUENCE IF EXISTS UM_ACCOUNT_MAPPING_SEQ; +CREATE SEQUENCE UM_ACCOUNT_MAPPING_SEQ; +CREATE TABLE UM_ACCOUNT_MAPPING( + UM_ID INTEGER DEFAULT NEXTVAL('UM_ACCOUNT_MAPPING_SEQ'), + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER NOT NULL, + UM_USER_STORE_DOMAIN VARCHAR(100), + UM_ACC_LINK_ID INTEGER NOT NULL, + UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID), + FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID) +); + +DROP TABLE IF EXISTS UM_USER_ATTRIBUTE; +DROP SEQUENCE IF EXISTS UM_USER_ATTRIBUTE_PK_SEQ; +CREATE SEQUENCE UM_USER_ATTRIBUTE_PK_SEQ; +CREATE TABLE UM_USER_ATTRIBUTE ( + UM_ID INTEGER DEFAULT NEXTVAL('UM_USER_ATTRIBUTE_PK_SEQ'), + UM_ATTR_NAME VARCHAR(255) NOT NULL, + UM_ATTR_VALUE VARCHAR(1024), + UM_PROFILE_ID VARCHAR(255), + UM_USER_ID INTEGER, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +CREATE INDEX UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID); + +DROP TABLE IF EXISTS UM_DIALECT CASCADE; +DROP SEQUENCE IF EXISTS UM_DIALECT_PK_SEQ; +CREATE SEQUENCE UM_DIALECT_PK_SEQ; +CREATE TABLE UM_DIALECT( + UM_ID INTEGER DEFAULT NEXTVAL('UM_DIALECT_PK_SEQ'), + UM_DIALECT_URI VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_URI, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_CLAIM; +DROP SEQUENCE IF EXISTS UM_CLAIM_PK_SEQ; +CREATE SEQUENCE UM_CLAIM_PK_SEQ; +CREATE TABLE UM_CLAIM( + UM_ID INTEGER DEFAULT NEXTVAL('UM_CLAIM_PK_SEQ'), + UM_DIALECT_ID INTEGER NOT NULL, + UM_CLAIM_URI VARCHAR(255) NOT NULL, + UM_DISPLAY_TAG VARCHAR(255), + UM_DESCRIPTION VARCHAR(255), + UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255), + UM_MAPPED_ATTRIBUTE VARCHAR(255), + UM_REG_EX VARCHAR(255), + UM_SUPPORTED SMALLINT, + UM_REQUIRED SMALLINT, + UM_DISPLAY_ORDER INTEGER, + UM_CHECKED_ATTRIBUTE SMALLINT, + UM_READ_ONLY SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE(UM_DIALECT_ID, UM_CLAIM_URI, UM_TENANT_ID), + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_PROFILE_CONFIG; +DROP SEQUENCE IF EXISTS UM_PROFILE_CONFIG_PK_SEQ; +CREATE SEQUENCE UM_PROFILE_CONFIG_PK_SEQ; +CREATE TABLE UM_PROFILE_CONFIG( + UM_ID INTEGER DEFAULT NEXTVAL('UM_PROFILE_CONFIG_PK_SEQ'), + UM_DIALECT_ID INTEGER NOT NULL, + UM_PROFILE_NAME VARCHAR(255), + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_CLAIM_BEHAVIOR; +DROP SEQUENCE IF EXISTS UM_CLAIM_BEHAVIOR_PK_SEQ; +CREATE SEQUENCE UM_CLAIM_BEHAVIOR_PK_SEQ; +CREATE TABLE UM_CLAIM_BEHAVIOR( + UM_ID INTEGER DEFAULT NEXTVAL('UM_CLAIM_BEHAVIOR_PK_SEQ'), + UM_PROFILE_ID INTEGER, + UM_CLAIM_ID INTEGER, + UM_BEHAVIOUR SMALLINT, + UM_TENANT_ID INTEGER DEFAULT 0, + FOREIGN KEY(UM_PROFILE_ID, UM_TENANT_ID) REFERENCES UM_PROFILE_CONFIG(UM_ID, UM_TENANT_ID), + FOREIGN KEY(UM_CLAIM_ID, UM_TENANT_ID) REFERENCES UM_CLAIM(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_HYBRID_ROLE; +DROP SEQUENCE IF EXISTS UM_HYBRID_ROLE_PK_SEQ; +CREATE SEQUENCE UM_HYBRID_ROLE_PK_SEQ; +CREATE TABLE UM_HYBRID_ROLE( + UM_ID INTEGER DEFAULT NEXTVAL('UM_HYBRID_ROLE_PK_SEQ'), + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) +); + +CREATE INDEX UM_ROLE_NAME_IND ON UM_HYBRID_ROLE(UM_ROLE_NAME); + +DROP TABLE IF EXISTS UM_HYBRID_USER_ROLE; +DROP SEQUENCE IF EXISTS UM_HYBRID_USER_ROLE_PK_SEQ; +CREATE SEQUENCE UM_HYBRID_USER_ROLE_PK_SEQ; +CREATE TABLE UM_HYBRID_USER_ROLE( + UM_ID INTEGER DEFAULT NEXTVAL('UM_HYBRID_USER_ROLE_PK_SEQ'), + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UM_DOMAIN_ID INTEGER, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID, UM_DOMAIN_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID, UM_TENANT_ID) ON DELETE CASCADE, + FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_SYSTEM_ROLE; +DROP SEQUENCE IF EXISTS UM_SYSTEM_ROLE_PK_SEQ; +CREATE SEQUENCE UM_SYSTEM_ROLE_PK_SEQ; +CREATE TABLE UM_SYSTEM_ROLE( + UM_ID INTEGER DEFAULT NEXTVAL('UM_SYSTEM_ROLE_PK_SEQ'), + UM_ROLE_NAME VARCHAR(255) NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID), + UNIQUE(UM_ROLE_NAME,UM_TENANT_ID) +); + +DROP TABLE IF EXISTS UM_SYSTEM_USER_ROLE; +DROP SEQUENCE IF EXISTS UM_SYSTEM_USER_ROLE_PK_SEQ; +CREATE SEQUENCE UM_SYSTEM_USER_ROLE_PK_SEQ; +CREATE TABLE UM_SYSTEM_USER_ROLE( + UM_ID INTEGER DEFAULT NEXTVAL('UM_SYSTEM_USER_ROLE_PK_SEQ'), + UM_USER_NAME VARCHAR(255), + UM_ROLE_ID INTEGER NOT NULL, + UM_TENANT_ID INTEGER DEFAULT 0, + UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID), + FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID), + PRIMARY KEY (UM_ID, UM_TENANT_ID) +); + + + +DROP TABLE IF EXISTS UM_HYBRID_REMEMBER_ME; +DROP SEQUENCE IF EXISTS UM_HYBRID_REMEMBER_ME_PK_SEQ; +CREATE SEQUENCE UM_HYBRID_REMEMBER_ME_PK_SEQ; +CREATE TABLE UM_HYBRID_REMEMBER_ME( + UM_ID INTEGER DEFAULT NEXTVAL('UM_HYBRID_REMEMBER_ME_PK_SEQ'), + UM_USER_NAME VARCHAR(255) NOT NULL, + UM_COOKIE_VALUE VARCHAR(1024), + UM_CREATED_TIME TIMESTAMP, + UM_TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (UM_ID, UM_TENANT_ID) +);