From e98af24f29f5bb786a6a0246ba41823cd9617b04 Mon Sep 17 00:00:00 2001 From: Vishanth Date: Fri, 20 Jan 2017 15:37:58 +0530 Subject: [PATCH] fixing dm_profile constraint issue --- .../src/main/resources/dbscripts/cdm/mssql.sql | 4 ++-- .../src/main/resources/dbscripts/cdm/mysql.sql | 2 +- .../src/main/resources/dbscripts/cdm/oracle.sql | 2 +- .../src/main/resources/dbscripts/cdm/postgresql.sql | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) 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 db405cdc1eb..82dba1d7704 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 @@ -5,11 +5,11 @@ CREATE TABLE DM_DEVICE_TYPE ( PROVIDER_TENANT_ID INTEGER NULL, SHARED_WITH_ALL_TENANTS BIT NOT NULL DEFAULT 0, PRIMARY KEY (ID), - CONSTRAINT DEVICE_TYPE_NAME UNIQUE(NAME) + CONSTRAINT DEVICE_TYPE_NAME UNIQUE(NAME, PROVIDER_TENANT_ID) ); IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DEVICE_TYPE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_TYPE')) -CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME); +CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID); IF NOT EXISTS(SELECT * FROM SYS.OBJECTS 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 5d8faece3f2..e1a960351de 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 @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( PRIMARY KEY (ID) )ENGINE = InnoDB; -CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME); +CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID); CREATE TABLE IF NOT EXISTS DM_GROUP ( ID INTEGER AUTO_INCREMENT NOT NULL, 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 f2e71c9c9c3..5e4836b01e7 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 @@ -4,7 +4,7 @@ CREATE TABLE DM_DEVICE_TYPE ( PROVIDER_TENANT_ID INTEGER DEFAULT 0, SHARED_WITH_ALL_TENANTS NUMBER(1) DEFAULT 0 NOT NULL, CONSTRAINT PK_DM_DEVICE_TYPE PRIMARY KEY (ID), - UNIQUE (NAME) + UNIQUE (NAME, PROVIDER_TENANT_ID) ) / -- Generate ID using sequence and trigger 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 d5c035e26b1..f1e3549226a 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 @@ -3,10 +3,10 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( NAME VARCHAR(300) DEFAULT NULL, PROVIDER_TENANT_ID INTEGER DEFAULT 0, SHARED_WITH_ALL_TENANTS BOOLEAN NOT NULL DEFAULT FALSE, - UNIQUE(NAME) + UNIQUE(NAME, PROVIDER_TENANT_ID) ); -CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME); +CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID); CREATE TABLE IF NOT EXISTS DM_GROUP ( ID BIGSERIAL NOT NULL PRIMARY KEY,