diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 60597bc43d2..8cbd423c4f2 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -202,6 +202,19 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON UPDATE NO ACTION ); +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, + POLICY_ID INT(11) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , DEVICE_ID INT(11) NOT NULL , diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index c87b947ecab..22f1540975c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -252,6 +252,20 @@ CREATE TABLE DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CORRECTIVE_ACTION]') AND TYPE IN (N'U')) +CREATE TABLE DM_POLICY_CORRECTIVE_ACTION ( + ID INTEGER IDENTITY(1,1) NOT NULL, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INTEGER DEFAULT NULL, + POLICY_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_POLICY ( ID INTEGER IDENTITY(1,1) NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index cca244f67f5..c6fab7ef01a 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -233,6 +233,19 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON UPDATE NO ACTION )ENGINE = InnoDB; +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, + POLICY_ID INT(11) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +)ENGINE = InnoDB; + CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 5ee36a2193a..371b4a46974 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -364,6 +364,19 @@ CREATE TABLE DM_POLICY ( REFERENCES DM_PROFILE (ID ) ) / + +CREATE TABLE DM_POLICY_CORRECTIVE_ACTION ( + ID NUMBER(10) NOT NULL, + ACTION_TYPE VARCHAR2(45) NOT NULL, + CORRECTIVE_POLICY_ID NUMBER(10) DEFAULT NULL, + POLICY_ID NUMBER(10) NOT NULL, + CONSTRAINT PK_DM_POLICY_CORRECTIVE_ACTION PRIMARY KEY (ID), + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) +) +/ + -- Generate ID using sequence and trigger CREATE SEQUENCE DM_POLICY_seq START WITH 1 INCREMENT BY 1 NOCACHE / diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index e5a5976b6f6..d5d11f6b353 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -202,6 +202,18 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON UPDATE NO ACTION ); +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID BIGSERIAL NOT NULL PRIMARY KEY, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INTEGER DEFAULT NULL, + POLICY_ID INTEGER NOT NULL, + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ID BIGSERIAL NOT NULL PRIMARY KEY, DEVICE_ID INTEGER NOT NULL ,