From d0edbb8aa7715d8e0bd06e278e4e85893fc60925 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Thu, 7 Sep 2017 12:25:54 +0530 Subject: [PATCH] Committing the fixes for the database schema. --- .../resources/dbscripts/cdm/application-mgt/h2.sql | 13 +++++++------ .../dbscripts/cdm/application-mgt/mssql.sql | 3 ++- .../dbscripts/cdm/application-mgt/mysql.sql | 4 ++-- .../dbscripts/cdm/application-mgt/oracle.sql | 3 ++- .../dbscripts/cdm/application-mgt/postgresql.sql | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index 994d61a08bc..323bacca5c4 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -7,6 +7,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS APPM_PLATFORM ( ID INT NOT NULL AUTO_INCREMENT UNIQUE, +IDENTIFIER VARCHAR (100) NOT NULL, TENANT_ID INT NOT NULL , NAME VARCHAR (255), FILE_BASED BOOLEAN, @@ -14,9 +15,10 @@ DESCRIPTION LONGVARCHAR, IS_SHARED BOOLEAN, IS_DEFAULT_TENANT_MAPPING BOOLEAN, ICON_NAME VARCHAR (100), -PRIMARY KEY (IDENTIFIER, TENANT_ID) +PRIMARY KEY (ID) ); + CREATE TABLE IF NOT EXISTS APPM_PLATFORM_PROPERTIES ( ID INT NOT NULL AUTO_INCREMENT, PLATFORM_ID INT NOT NULL, @@ -120,7 +122,6 @@ INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSIO CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( `ID` INT NOT NULL AUTO_INCREMENT, `UUID` VARCHAR(100) NOT NULL, - `IDENTIFIER` VARCHAR(255) NULL, `NAME` VARCHAR(100) NOT NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL, `DESCRIPTION` TEXT NULL, @@ -319,16 +320,16 @@ CREATE TABLE IF NOT EXISTS APPM_VISIBILITY ( VALUE VARCHAR(255), RESOURCE_TYPE_ID INT NOT NULL, APPLICATION_ID INT NULL, - PRIMARY KEY (ID, RESOURCE_TYPE_ID), + PRIMARY KEY (ID), CONSTRAINT fk_APPM_VISIBILITY_APPM_RESOURCE_TYPE1 FOREIGN KEY (RESOURCE_TYPE_ID) REFERENCES APPM_RESOURCE_TYPE (ID) - ON DELETE CASCADE, - ON UPDATE CASCADE, + ON DELETE NO ACTION + ON UPDATE NO ACTION, CONSTRAINT fk_APPM_VISIBILITY_APPM_APPLICATION1 FOREIGN KEY (APPLICATION_ID) REFERENCES APPM_APPLICATION (ID) - ON DELETE CASCADE, + ON DELETE CASCADE ON UPDATE CASCADE); CREATE INDEX FK_APPM_VISIBILITY_RESOURCE_TYPE ON APPM_VISIBILITY(RESOURCE_TYPE_ID ASC); diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql index e4277519561..42fd4cb36b0 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql @@ -1,6 +1,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APPM_PLATFORM]') AND TYPE IN (N'U')) CREATE TABLE APPM_PLATFORM ( ID INT IDENTITY(1,1) NOT NULL UNIQUE, + IDENTIFIER VARCHAR (100) NOT NULL, TENANT_ID INT NOT NULL , NAME VARCHAR (255), FILE_BASED BIT, @@ -8,7 +9,7 @@ CREATE TABLE APPM_PLATFORM ( IS_SHARED BIT, IS_DEFAULT_TENANT_MAPPING BIT, ICON_NAME VARCHAR (100), - PRIMARY KEY (IDENTIFIER, TENANT_ID) + PRIMARY KEY (ID) ); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APPM_PLATFORM_PROPERTIES]') AND TYPE IN (N'U')) diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index 52fe5701e07..f11791f0079 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -16,6 +16,7 @@ SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS APPM_PLATFORM ( ID INT NOT NULL AUTO_INCREMENT UNIQUE, +IDENTIFIER VARCHAR (100) NOT NULL, TENANT_ID INT NOT NULL , NAME VARCHAR (255), FILE_BASED BOOLEAN, @@ -23,7 +24,7 @@ DESCRIPTION VARCHAR (2048), IS_SHARED BOOLEAN, IS_DEFAULT_TENANT_MAPPING BOOLEAN, ICON_NAME VARCHAR (100), -PRIMARY KEY (IDENTIFIER, TENANT_ID) +PRIMARY KEY (ID) ); CREATE TABLE IF NOT EXISTS APPM_PLATFORM_PROPERTIES ( @@ -121,7 +122,6 @@ INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSIO CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( `ID` INT NOT NULL AUTO_INCREMENT, `UUID` VARCHAR(100) NOT NULL, - `IDENTIFIER` VARCHAR(255) NULL, `NAME` VARCHAR(100) NOT NULL, `SHORT_DESCRIPTION` VARCHAR(255) NULL, `DESCRIPTION` TEXT NULL, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql index dde3b71e3f9..4489a049877 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql @@ -7,6 +7,7 @@ -- ----------------------------------------------------- CREATE TABLE APPM_PLATFORM ( ID INT UNIQUE, +IDENTIFIER VARCHAR (100) NOT NULL, TENANT_ID INT NOT NULL , NAME VARCHAR (255), FILE_BASED NUMBER (1), @@ -14,7 +15,7 @@ DESCRIPTION VARCHAR (2048), IS_SHARED NUMBER (1), IS_DEFAULT_TENANT_MAPPING NUMBER (1), ICON_NAME VARCHAR (100), -PRIMARY KEY (IDENTIFIER, TENANT_ID) +PRIMARY KEY (ID) ) / diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql index 3569edfbbfe..7a309c09fb4 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql @@ -4,6 +4,7 @@ CREATE SEQUENCE APPM_PLATFORM_PK_SEQ; CREATE TABLE APPM_PLATFORM ( ID INT DEFAULT NEXTVAL('APPM_PLATFORM_PK_SEQ') UNIQUE, +IDENTIFIER VARCHAR (100) NOT NULL, TENANT_ID INT NOT NULL , NAME VARCHAR (255), FILE_BASED BOOLEAN, @@ -11,7 +12,7 @@ DESCRIPTION VARCHAR(2048), IS_SHARED BOOLEAN, IS_DEFAULT_TENANT_MAPPING BOOLEAN, ICON_NAME VARCHAR (100), -PRIMARY KEY (IDENTIFIER, TENANT_ID) +PRIMARY KEY (ID) ); DROP TABLE IF EXISTS APPM_PLATFORM_PROPERTIES; @@ -137,7 +138,6 @@ CREATE SEQUENCE APPM_APPLICATION_PK_SEQ; CREATE TABLE IF NOT EXISTS APPM_APPLICATION ( ID INT DEFAULT NEXTVAL('APPM_APPLICATION_PK_SEQ') UNIQUE, UUID VARCHAR(100) NOT NULL, - IDENTIFIER VARCHAR(255) NULL, NAME VARCHAR(100) NOT NULL, SHORT_DESCRIPTION VARCHAR(255) NULL, DESCRIPTION TEXT NULL,