From 03835bdeb73d996e47cad56b8cd1c1439ccada7b Mon Sep 17 00:00:00 2001 From: harshanl Date: Tue, 2 Aug 2016 17:40:20 +0530 Subject: [PATCH] Fixed EMM-1449 issue --- .../src/main/resources/dbscripts/cdm/h2.sql | 8 ++++---- .../src/main/resources/dbscripts/cdm/mssql.sql | 16 ++++++++-------- .../src/main/resources/dbscripts/cdm/mysql.sql | 17 +++++++++-------- .../src/main/resources/dbscripts/cdm/oracle.sql | 16 ++++++++-------- .../main/resources/dbscripts/cdm/postgresql.sql | 16 ++++++++-------- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql index f3f3735e50e..82c2eba5366 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -134,7 +134,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ID INT NOT NULL AUTO_INCREMENT , PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INT NOT NULL , - DEVICE_TYPE VARCHAR(20) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , PRIMARY KEY (ID) , @@ -195,7 +195,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ID INT(11) NOT NULL , - DEVICE_TYPE VARCHAR(20) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY @@ -218,7 +218,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ID INT(11) NOT NULL AUTO_INCREMENT, PROFILE_ID INT(11) NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), @@ -339,7 +339,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql index 66ce12dc875..385ac2a135f 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -135,13 +135,13 @@ CREATE TABLE DM_PROFILE ( ID INTEGER NOT NULL IDENTITY , PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INTEGER NOT NULL , - DEVICE_TYPE_ID INTEGER NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME2(0) NOT NULL , UPDATED_TIME DATETIME2(0) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE) + REFERENCES DM_DEVICE_TYPE (NAME ) ON DELETE NO ACTION ON UPDATE NO ACTION ); @@ -196,7 +196,7 @@ CREATE TABLE DM_DEVICE_POLICY ( CREATE TABLE DM_DEVICE_TYPE_POLICY ( ID INTEGER NOT NULL , - DEVICE_TYPE_ID INTEGER NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , POLICY_ID INTEGER NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY @@ -205,8 +205,8 @@ CREATE TABLE DM_DEVICE_TYPE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE) + REFERENCES DM_DEVICE_TYPE (NAME ) ON DELETE NO ACTION ON UPDATE NO ACTION ); @@ -219,7 +219,7 @@ CREATE TABLE DM_PROFILE_FEATURES ( ID INTEGER NOT NULL IDENTITY, PROFILE_ID INTEGER NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , TENANT_ID INTEGER NOT NULL , CONTENT VARBINARY(max) NULL DEFAULT NULL, PRIMARY KEY (ID), @@ -340,7 +340,7 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( CREATE TABLE DM_POLICY_CHANGE_MGT ( ID INTEGER NOT NULL IDENTITY, POLICY_ID INTEGER NOT NULL, - DEVICE_TYPE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql index 1d2013cbc42..098ebc5d98e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( SHARED_WITH_ALL_TENANTS BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID) )ENGINE = InnoDB; +CREATE INDEX device_type_name ON DM_DEVICE_TYPE (NAME); CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER AUTO_INCREMENT NOT NULL, @@ -117,13 +118,13 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ID INT NOT NULL AUTO_INCREMENT , PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INT NOT NULL , - DEVICE_TYPE_ID INT NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , PRIMARY KEY (ID) , CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE) + REFERENCES DM_DEVICE_TYPE (NAME) ON DELETE NO ACTION ON UPDATE NO ACTION )ENGINE = InnoDB; @@ -171,7 +172,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ID INT(11) NOT NULL , - DEVICE_TYPE_ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY @@ -180,8 +181,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME ) ON DELETE NO ACTION ON UPDATE NO ACTION )ENGINE = InnoDB; @@ -191,7 +192,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ID INT(11) NOT NULL AUTO_INCREMENT, PROFILE_ID INT(11) NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), @@ -308,7 +309,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) )ENGINE = InnoDB; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index 18ed9c2abe4..0b1256d5ee4 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -250,13 +250,13 @@ CREATE TABLE DM_PROFILE ( ID NUMBER(10) NOT NULL , PROFILE_NAME VARCHAR2(45) NOT NULL , TENANT_ID NUMBER(10) NOT NULL , - DEVICE_TYPE_ID NUMBER(10) NOT NULL , + DEVICE_TYPE VARCHAR2(300) NOT NULL , CREATED_TIME TIMESTAMP(0) NOT NULL , UPDATED_TIME TIMESTAMP(0) NOT NULL , CONSTRAINT PK_DM_PROFILE PRIMARY KEY (ID) , CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME ) ) / -- Generate ID using sequence and trigger @@ -338,15 +338,15 @@ WHEN (NEW.ID IS NULL) CREATE TABLE DM_DEVICE_TYPE_POLICY ( ID NUMBER(10) NOT NULL , - DEVICE_TYPE_ID NUMBER(10) NOT NULL , + DEVICE_TYPE VARCHAR2(300) NOT NULL , POLICY_ID NUMBER(10) NOT NULL , CONSTRAINT PK_DEV_TYPE_POLICY PRIMARY KEY (ID) , CONSTRAINT FK_DEV_TYPE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ), CONSTRAINT FK_DEV_TYPE_POLICY_DEV_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME ) ) / @@ -355,7 +355,7 @@ CREATE TABLE DM_PROFILE_FEATURES ( ID NUMBER(10) NOT NULL, PROFILE_ID NUMBER(10) NOT NULL, FEATURE_CODE VARCHAR2(100) NOT NULL, - DEVICE_TYPE_ID NUMBER(10) NOT NULL, + DEVICE_TYPE VARCHAR2(300) NOT NULL , TENANT_ID NUMBER(10) NOT NULL , CONTENT BLOB DEFAULT NULL NULL, CONSTRAINT PK_DM_PROF_DM_POLICY_FEATURES PRIMARY KEY (ID), @@ -566,7 +566,7 @@ WHEN (NEW.ID IS NULL) CREATE TABLE DM_POLICY_CHANGE_MGT ( ID NUMBER(10) NOT NULL, POLICY_ID NUMBER(10) NOT NULL, - DEVICE_TYPE_ID NUMBER(10) NOT NULL, + DEVICE_TYPE VARCHAR2(300) NOT NULL, TENANT_ID NUMBER(10) NOT NULL, CONSTRAINT PK_DM_POLICY_CHANGE_MGT PRIMARY KEY (ID) ) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 2da059d3a77..dc3c6229f22 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -103,12 +103,12 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ID BIGSERIAL NOT NULL PRIMARY KEY, PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INTEGER NOT NULL , - DEVICE_TYPE_ID INTEGER NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME TIMESTAMP NOT NULL , UPDATED_TIME TIMESTAMP NOT NULL , CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME ) ON DELETE NO ACTION ON UPDATE NO ACTION ); @@ -151,7 +151,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ID INTEGER NOT NULL, - DEVICE_TYPE_ID INTEGER NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , POLICY_ID INTEGER NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY @@ -160,8 +160,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME ) ON DELETE NO ACTION ON UPDATE NO ACTION ); @@ -170,7 +170,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ID BIGSERIAL NOT NULL PRIMARY KEY, PROFILE_ID INTEGER NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , TENANT_ID INTEGER NOT NULL , CONTENT BYTEA NULL DEFAULT NULL, CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -272,7 +272,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID BIGSERIAL NOT NULL PRIMARY KEY, POLICY_ID INTEGER NOT NULL, - DEVICE_TYPE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, TENANT_ID INTEGER NOT NULL );