From 105288860503984b133e22a32b15afbd76b092d3 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sun, 16 Sep 2018 17:37:25 +0530 Subject: [PATCH 1/3] Test Case for StorageManagementUtilTest (#4) * Adding unit test for StorageManagementUtilTest.java * formatting fixes --- .../StorageManagementUtilTest.java | 75 +++++++++++++++++++ .../src/test/resources/testng.xml | 1 + 2 files changed, 76 insertions(+) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/StorageManagementUtilTest.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/StorageManagementUtilTest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/StorageManagementUtilTest.java new file mode 100644 index 0000000000..68817849cf --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/StorageManagementUtilTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.wso2.carbon.device.application.mgt.core; + +import org.junit.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException; +import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +public class StorageManagementUtilTest { + private static final String TEMP_FOLDER = "src/test/resources/util/temp"; + private static final String APK_FILE = "src/test/resources/util/app-debug.apk"; + private static final String APK_FILE_NAME = "/app-debug.apk"; + + @BeforeMethod + public void before() throws IOException { + File file = new File(TEMP_FOLDER); + if (file.exists()) { + StorageManagementUtil.deleteDir(file); + } + } + + @Test + public void testCreateArtifactDirectory() { + try { + StorageManagementUtil.createArtifactDirectory(TEMP_FOLDER); + } catch (ResourceManagementException e) { + e.printStackTrace(); + Assert.fail("Directory creation failed."); + } + } + + @Test + public void testSaveFile() throws IOException, ResourceManagementException { + StorageManagementUtil.createArtifactDirectory(TEMP_FOLDER); + InputStream apk = new FileInputStream(APK_FILE); + StorageManagementUtil.saveFile(apk, TEMP_FOLDER + APK_FILE_NAME); + File file = new File(TEMP_FOLDER + APK_FILE_NAME); + if (!file.exists()) { + Assert.fail("File saving failed."); + } + } + + @AfterMethod + public void deleteFileTest() throws IOException, ResourceManagementException { + File file = new File(TEMP_FOLDER); + StorageManagementUtil.deleteDir(file); + if (file.exists()) { + Assert.fail("File deleting failed."); + } + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/testng.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/testng.xml index ca512950bc..9a69c5a87f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/testng.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/testng.xml @@ -23,6 +23,7 @@ + \ No newline at end of file From 6a9cec4c89e90d804d71e6aea60aa3515bd523b1 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Mon, 17 Sep 2018 19:28:26 +0530 Subject: [PATCH 2/3] Add scopes to publisher mgt API (#5) --- .../services/ApplicationManagementAPI.java | 44 ++++++------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementAPI.java index aee5a524e3..6c1d633f51 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/ApplicationManagementAPI.java @@ -73,32 +73,14 @@ import javax.ws.rs.core.Response; @Scope( name = "Get Application Details", description = "Get application details", - key = "perm:application:get", - permissions = {"/device-mgt/application/get"} - ), - @Scope( - name = "Create an Application", - description = "Create an application", - key = "perm:application:create", - permissions = {"/device-mgt/application/create"} + key = "perm:app:publisher:view", + permissions = {"/device-mgt/application/view"} ), @Scope( name = "Update an Application", description = "Update an application", - key = "perm:application:update", + key = "perm:app:publisher:update", permissions = {"/device-mgt/application/update"} - ), - @Scope( - name = "Login to Application Management", - description = "Login to Application Management", - key = "perm:application-mgt:login", - permissions = {"/device-mgt/application-mgt/login"} - ), - @Scope( - name = "Delete an Application", - description = "Delete an application", - key = "perm:application:delete", - permissions = {"/device-mgt/application/delete"} ) } ) @@ -122,7 +104,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:get") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") }) } ) @@ -172,7 +154,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:get") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") }) } ) @@ -215,7 +197,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:update") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") }) } ) @@ -254,7 +236,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:create") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") }) } ) @@ -313,7 +295,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:delete") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") }) } ) @@ -349,7 +331,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:create") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") }) } ) @@ -393,7 +375,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:create") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") }) } ) @@ -436,7 +418,7 @@ public interface ApplicationManagementAPI { tags = "Application Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application:update") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") }) } ) @@ -475,7 +457,7 @@ public interface ApplicationManagementAPI { tags = "Lifecycle Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:lifecycle:get") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") }) } ) @@ -507,7 +489,7 @@ public interface ApplicationManagementAPI { tags = "Lifecycle Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:lifecycle:add") + @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") }) } ) From 000ce6ee540c09cdecf7dee97bfc4f921f38c5a1 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Tue, 18 Sep 2018 22:07:04 +0530 Subject: [PATCH 3/3] DB Scripts for App Manager (#6) MySQL and H2 DB Scripts --- .../dbscripts/cdm/application-mgt/h2.sql | 472 ++++++---------- .../dbscripts/cdm/application-mgt/mysql.sql | 513 +++++++----------- 2 files changed, 346 insertions(+), 639 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 ad3d082962..710182c632 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 @@ -1,350 +1,206 @@ -- ----------------------------------------------------- --- Schema WSO2DM_APPM_DB --- ----------------------------------------------------- - --- ----------------------------------------------------- --- Table APPM_PLATFORM --- ----------------------------------------------------- -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, -DESCRIPTION LONGVARCHAR, -IS_SHARED BOOLEAN, -IS_DEFAULT_TENANT_MAPPING BOOLEAN, -ICON_NAME VARCHAR (100), -PRIMARY KEY (ID) -); - - -CREATE TABLE IF NOT EXISTS APPM_PLATFORM_PROPERTIES ( -ID INT NOT NULL AUTO_INCREMENT, -PLATFORM_ID INT NOT NULL, -PROP_NAME VARCHAR (100) NOT NULL, -OPTIONAL BOOLEAN, -DEFAUL_VALUE VARCHAR (255), -FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE, -PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME) -); - -CREATE TABLE IF NOT EXISTS APPM_PLATFORM_TENANT_MAPPING ( -ID INT NOT NULL AUTO_INCREMENT, -TENANT_ID INT NOT NULL , -PLATFORM_ID INT NOT NULL, -FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE, -PRIMARY KEY (ID, TENANT_ID, PLATFORM_ID) -); - -CREATE INDEX IF NOT EXISTS FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC); - --- ----------------------------------------------------- --- Table APPM_APPLICATION_CATEGORY --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY ( - ID INT NOT NULL AUTO_INCREMENT, - NAME VARCHAR(100) NOT NULL UNIQUE, - DESCRIPTION TEXT NULL, +-- Table AP_APP +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_APP ( + ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(45) NOT NULL, + TYPE VARCHAR(200) NOT NULL, + TENANT_ID VARCHAR(45) NOT NULL, + APP_CATEGORY VARCHAR(45) NULL DEFAULT NULL, + RESTRICTED INT(11) NOT NULL, + STATUS VARCHAR(45) NOT NULL DEFAULT 'ACTIVE', + SUB_TYPE VARCHAR(45) NOT NULL, + CURRENCY VARCHAR(45) NULL DEFAULT '$', + DM_DEVICE_TYPE_ID INT(11) NOT NULL, PRIMARY KEY (ID)); -INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION) VALUES ('Sports', 'Applications that involve sports.'); -INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION) VALUES ('Education', 'Application related with education'); -INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION) VALUES ('News', 'Applications involving news'); -- ----------------------------------------------------- --- Table `APPM_LIFECYCLE_STATE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE ( - ID INT NOT NULL AUTO_INCREMENT UNIQUE, - NAME VARCHAR(100) NOT NULL, - IDENTIFIER VARCHAR(100) NOT NULL, - DESCRIPTION TEXT NULL, +-- Table AP_APP_RELEASE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_APP_RELEASE ( + ID INT(11) NOT NULL AUTO_INCREMENT, + VERSION VARCHAR(10) NOT NULL, + TENANT_ID VARCHAR(45) NOT NULL, + UUID VARCHAR(200) NOT NULL, + RELEASE_TYPE VARCHAR(45) NOT NULL, + APP_PRICE DECIMAL(6,2) NULL DEFAULT NULL, + STORED_LOCATION VARCHAR(45) NOT NULL, + BANNER_LOCATION VARCHAR(45) NOT NULL, + SC_1_LOCATION VARCHAR(45) NOT NULL, + SC_2_LOCATION VARCHAR(45) NULL DEFAULT NULL, + SC_3_LOCATION VARCHAR(45) NULL DEFAULT NULL, + APP_HASH_VALUE VARCHAR(1000) NOT NULL, + SHARED_WITH_ALL_TENANTS INT(11) NULL DEFAULT NULL, + APP_META_INFO VARCHAR(20000) NULL DEFAULT NULL, + RATING DOUBLE NULL DEFAULT NULL, + RATED_USERS INT(11) NULL, + AP_APP_ID INT(11) NOT NULL, + PRIMARY KEY (ID, AP_APP_ID), + CONSTRAINT fk_AP_APP_RELEASE_AP_APP1 + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID)); + +CREATE INDEX fk_AP_APP_RELEASE_AP_APP1_idx ON AP_APP_RELEASE (AP_APP_ID ASC); + + +-- ----------------------------------------------------- +-- Table AP_APP_REVIEW +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_APP_REVIEW ( + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + COMMENT VARCHAR(250) NOT NULL, + REPLY_COMMENT VARCHAR(250) NULL, + CREATED_AT TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + MODEFIED_AT TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + RATING INT(11) NULL, + USERNAME VARCHAR(45) NOT NULL, + AP_APP_RELEASE_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, PRIMARY KEY (ID), - UNIQUE INDEX APPM_LIFECYCLE_STATE_IDENTIFIER_UNIQUE (IDENTIFIER ASC)); - -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('CREATED', 'CREATED', 'Application creation -initial state'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('IN REVIEW', 'IN REVIEW', 'Application is in in-review state'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('APPROVED', 'APPROVED', 'State in which Application is approved after reviewing.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('REJECTED', 'REJECTED', 'State in which Application is rejected after reviewing.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('PUBLISHED', 'PUBLISHED', 'State in which Application is in published state.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('UNPUBLISHED', 'UNPUBLISHED', 'State in which Application is in un published state.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); + CONSTRAINT fk_AP_APP_COMMENT_AP_APP_RELEASE1 + FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID) + REFERENCES AP_APP_RELEASE (ID , AP_APP_ID)); +CREATE INDEX fk_AP_APP_COMMENT_AP_APP_RELEASE1_idx ON AP_APP_REVIEW (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); -CREATE TABLE IF NOT EXISTS APPM_LC_STATE_TRANSITION -( - ID INT NOT NULL AUTO_INCREMENT UNIQUE, - INITIAL_STATE INT, - NEXT_STATE INT, - PERMISSION VARCHAR(1024), - DESCRIPTION VARCHAR(2048), - PRIMARY KEY (INITIAL_STATE, NEXT_STATE), - FOREIGN KEY (INITIAL_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE, - FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE -); - -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (1, 2, null, 'Submit for review'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (2, 1, null, 'Revoke from review'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (3, 5, null, 'PUBLISH'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (5, 6, null, 'UN PUBLISH'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (6, 5, null, 'PUBLISH'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (4, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (6, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (6, 7, null, 'Retire'); -- ----------------------------------------------------- --- Table APPM_APPLICATION +-- Table AP_APP_LIFECYCLE_STATE -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `UUID` VARCHAR(100) NOT NULL, - `NAME` VARCHAR(100) NOT NULL, - `SHORT_DESCRIPTION` VARCHAR(255) NULL, - `DESCRIPTION` TEXT NULL, - `SCREEN_SHOT_COUNT` INT DEFAULT 0, - `VIDEO_NAME` VARCHAR(100) NULL, - `CREATED_BY` VARCHAR(255) NULL, - `CREATED_AT` DATETIME NOT NULL, - `MODIFIED_AT` DATETIME NULL, - `IS_FREE` TINYINT(1) NULL, - `PAYMENT_CURRENCY` VARCHAR(45) NULL, - `PAYMENT_PRICE` DECIMAL(10,2) NULL, - `APPLICATION_CATEGORY_ID` INT NOT NULL, - `LIFECYCLE_STATE_ID` INT NOT NULL, - `LIFECYCLE_STATE_MODIFIED_BY` VARCHAR(255) NULL, - `LIFECYCLE_STATE_MODIFIED_AT` DATETIME NULL, - `TENANT_ID` INT NOT NULL, - `PLATFORM_ID` INT NOT NULL, - PRIMARY KEY (`ID`, `APPLICATION_CATEGORY_ID`, `LIFECYCLE_STATE_ID`, `PLATFORM_ID`), - UNIQUE INDEX `UUID_UNIQUE` (`UUID` ASC), - FOREIGN KEY (`APPLICATION_CATEGORY_ID`) - REFERENCES `APPM_APPLICATION_CATEGORY` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_APPM_APPLICATION_APPM_LIFECYCLE_STATE1` - FOREIGN KEY (`LIFECYCLE_STATE_ID`) - REFERENCES `APPM_LIFECYCLE_STATE` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_APPM_APPLICATION_APPM_PLATFORM1` - FOREIGN KEY (`PLATFORM_ID`) - REFERENCES `APPM_PLATFORM` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION); - -CREATE INDEX IF NOT EXISTS FK_APPLICATION_APPLICATION_CATEGORY ON APPM_APPLICATION(APPLICATION_CATEGORY_ID ASC); +CREATE TABLE IF NOT EXISTS AP_APP_LIFECYCLE_STATE ( + ID INT(11) NOT NULL AUTO_INCREMENT, + CURRENT_STATE VARCHAR(45) NOT NULL, + PREVIOUSE_STATE VARCHAR(45) NOT NULL, + TENANT_ID VARCHAR(45) NOT NULL, + UPDATED_BY VARCHAR(100) NOT NULL, + UPDATED_AT TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + AP_APP_RELEASE_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, + PRIMARY KEY (ID, AP_APP_RELEASE_ID, AP_APP_ID), + CONSTRAINT fk_AP_APP_LIFECYCLE_STATE_AP_APP_RELEASE1 + FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID) + REFERENCES AP_APP_RELEASE (ID , AP_APP_ID)); --- ----------------------------------------------------- --- Table APPM_APPLICATION_PROPERTY --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTY ( - PROP_KEY VARCHAR(255) NOT NULL, - PROP_VAL TEXT NULL, - APPLICATION_ID INT NOT NULL, - PRIMARY KEY (PROP_KEY, APPLICATION_ID), - CONSTRAINT FK_APPLICATION_PROPERTY_APPLICATION - FOREIGN KEY (APPLICATION_ID) - REFERENCES APPM_APPLICATION (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION); +CREATE INDEX fk_AP_APP_LIFECYCLE_STATE_AP_APP_RELEASE1_idx ON AP_APP_LIFECYCLE_STATE (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); -CREATE INDEX FK_APPLICATION_PROPERTY_APPLICATION ON APPM_APPLICATION_PROPERTY(APPLICATION_ID ASC); -- ----------------------------------------------------- --- Table APPM_APPLICATION_RELEASE +-- Table AP_APP_TAG -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( - ID INT NOT NULL AUTO_INCREMENT, - VERSION_NAME VARCHAR(100) NOT NULL, - RELEASE_RESOURCE TEXT NULL, - RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', - RELEASE_DETAILS TEXT NULL, - CREATED_AT DATETIME NOT NULL, - APPM_APPLICATION_ID INT NOT NULL, - IS_DEFAULT TINYINT NULL, - PRIMARY KEY (APPM_APPLICATION_ID, VERSION_NAME), - CONSTRAINT FK_APPLICATION_VERSION_APPLICATION - FOREIGN KEY (APPM_APPLICATION_ID) - REFERENCES APPM_APPLICATION (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION); - -CREATE INDEX FK_APPLICATION_VERSION_APPLICATION ON APPM_APPLICATION_RELEASE(APPM_APPLICATION_ID ASC); +CREATE TABLE IF NOT EXISTS AP_APP_TAG ( + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + TAG VARCHAR(45) NOT NULL, + AP_APP_ID INT(11) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_AP_APP_TAGS_AP_APP1 + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID)); --- ----------------------------------------------------- --- Table APPM_RELEASE_PROPERTY --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_RELEASE_PROPERTY ( - PROP_KEY VARCHAR(255) NOT NULL, - PROP_VALUE TEXT NULL, - APPLICATION_RELEASE_ID INT NOT NULL, - PRIMARY KEY (PROP_KEY, APPLICATION_RELEASE_ID), - CONSTRAINT FK_RELEASE_PROPERTY_APPLICATION_RELEASE - FOREIGN KEY (APPLICATION_RELEASE_ID) - REFERENCES APPM_APPLICATION_RELEASE (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION); +CREATE INDEX fk_AP_APP_TAGS_AP_APP1_idx ON AP_APP_TAG (AP_APP_ID ASC); -CREATE INDEX FK_RELEASE_PROPERTY_APPLICATION_RELEASE ON APPM_RELEASE_PROPERTY(APPLICATION_RELEASE_ID ASC); -- ----------------------------------------------------- --- Table APPM_RESOURCE_TYPE +-- Table AP_DEVICE_SUBSCRIPTION -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_RESOURCE_TYPE ( - ID INT NOT NULL AUTO_INCREMENT, - NAME VARCHAR(45) NULL, - DESCRIPTION TEXT NULL, - PRIMARY KEY (ID)); +CREATE TABLE IF NOT EXISTS AP_DEVICE_SUBSCRIPTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + SUBSCRIBED_BY VARCHAR(100) NOT NULL, + SUBSCRIBED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + DM_ENROLMENT_ID INT(11) NOT NULL, + AP_APP_RELEASE_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_AP_DEVICE_SUBSCRIPTION_AP_APP_RELEASE1 + FOREIGN KEY (AP_APP_ID , AP_APP_RELEASE_ID) + REFERENCES AP_APP_RELEASE (AP_APP_ID , ID)); -INSERT INTO APPM_RESOURCE_TYPE (NAME , DESCRIPTION) VALUES ('PUBLIC', 'OPEN VISIBILITY, CAN BE VIEWED BY ALL LOGGED IN USERS'); -INSERT INTO APPM_RESOURCE_TYPE (NAME , DESCRIPTION) VALUES ('ROLES', 'ROLE BASED RESTRICTION, CAN BE VIEWED BY ONLY GIVEN - SET OF USER WHO HAVE THE SPECIFIED ROLE'); -INSERT INTO APPM_RESOURCE_TYPE (NAME , DESCRIPTION) VALUES ('DEVICE_GROUPS', 'DEVICE GROUP LEVEL RESTRICTION, -CAN BE VIEWED BY THE DEVICES/ROLES BELONG TO THE GROUP'); +CREATE INDEX fk_AP_DEVICE_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_DEVICE_SUBSCRIPTION (AP_APP_ID ASC, AP_APP_RELEASE_ID ASC); -- ----------------------------------------------------- --- Table APPM_SUBSCRIPTION +-- Table AP_GROUP_SUBSCRIPTION -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_SUBSCRIPTION ( - ID INT NOT NULL AUTO_INCREMENT, - VALUE VARCHAR(255) NOT NULL, - CREATED_AT DATETIME NOT NULL, - RESOURCE_TYPE_ID INT NOT NULL, - APPLICATION_ID INT NOT NULL, - APPLICATION_RELEASE_ID INT NULL, - PRIMARY KEY (ID, APPLICATION_ID, RESOURCE_TYPE_ID), - CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_RESOURCE_TYPE1 - FOREIGN KEY (RESOURCE_TYPE_ID) - REFERENCES APPM_RESOURCE_TYPE (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_APPLICATION1 - FOREIGN KEY (APPLICATION_ID) - REFERENCES APPM_APPLICATION (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_APPLICATION_RELEASE1 - FOREIGN KEY (APPLICATION_RELEASE_ID) - REFERENCES APPM_APPLICATION_RELEASE (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION); - -CREATE INDEX FK_APPLICATION_SUBSCRIPTION_RESOURCE_TYPE ON APPM_SUBSCRIPTION(RESOURCE_TYPE_ID ASC); -CREATE INDEX FK_APPLICATION_SUBSCRIPTION_APPLICATION ON APPM_SUBSCRIPTION(APPLICATION_ID ASC); -CREATE INDEX FK_APPLICATION_SUBSCRIPTION_APPLICATION_RELEASE ON APPM_SUBSCRIPTION(APPLICATION_RELEASE_ID ASC); +CREATE TABLE IF NOT EXISTS AP_GROUP_SUBSCRIPTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + SUBSCRIBED_BY VARCHAR(100) NOT NULL, + SUBSCRIBED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + DM_GROUP_ID INT(11) NOT NULL, + AP_APP_RELEASE_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_AP_GROUP_SUBSCRIPTION_AP_APP_RELEASE1 + FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID) + REFERENCES AP_APP_RELEASE (ID , AP_APP_ID)); --- ----------------------------------------------------- --- Table APPM_COMMENT --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_COMMENT ( - ID INT NOT NULL AUTO_INCREMENT, - APPLICATION_RELEASE_ID INT NOT NULL, - COMMENT_SUBJECT VARCHAR(255) NULL, - COMMENT_BODY TEXT NULL, - RATING INT NULL, - PARENT_ID INT NULL, - CREATED_AT DATETIME NOT NULL, - CREATED_BY VARCHAR(45) NULL, - MODIFIED_AT DATETIME NULL, - PUBLISHED TINYINT NULL, - APPROVED TINYINT NULL, - PRIMARY KEY (ID, APPLICATION_RELEASE_ID), - CONSTRAINT FK_APPLICATION_COMMENTS_APPLICATION_RELEASE - FOREIGN KEY (APPLICATION_RELEASE_ID) - REFERENCES APPM_APPLICATION_RELEASE (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION); +CREATE INDEX fk_AP_GROUP_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_GROUP_SUBSCRIPTION (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); -CREATE INDEX FK_APPLICATION_COMMENTS_APPLICATION_RELEASE ON APPM_COMMENT(APPLICATION_RELEASE_ID ASC); -- ----------------------------------------------------- --- Table APPM_PLATFORM_TAG +-- Table AP_ROLE_SUBSCRIPTION -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_PLATFORM_TAG ( - NAME VARCHAR(100) NOT NULL, - PLATFORM_ID INT NOT NULL, - PRIMARY KEY (PLATFORM_ID, name), - CONSTRAINT fk_APPM_SUPPORTED_PLATFORM_TAGS_APPM_SUPPORTED_PLATFORM1 - FOREIGN KEY (PLATFORM_ID) - REFERENCES APPM_PLATFORM (ID) - ON DELETE CASCADE - ON UPDATE CASCADE); - -CREATE INDEX FK_PLATFORM_TAGS_PLATFORM ON APPM_PLATFORM_TAG(PLATFORM_ID ASC); +CREATE TABLE IF NOT EXISTS AP_ROLE_SUBSCRIPTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + ROLE_NAME VARCHAR(100) NOT NULL, + SUBSCRIBED_BY VARCHAR(100) NOT NULL, + SUBSCRIBED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + AP_APP_RELEASE_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_AP_ROLE_SUBSCRIPTION_AP_APP_RELEASE1 + FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID) + REFERENCES AP_APP_RELEASE (ID , AP_APP_ID)); --- ----------------------------------------------------- --- Table APPM_APPLICATION_TAG --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TAG ( - name VARCHAR(45) NOT NULL, - APPLICATION_ID INT NOT NULL, - PRIMARY KEY (APPLICATION_ID, name), - CONSTRAINT fk_APPM_APPLICATION_TAG_APPM_APPLICATION1 - FOREIGN KEY (APPLICATION_ID) - REFERENCES APPM_APPLICATION (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION); +CREATE INDEX fk_AP_ROLE_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_ROLE_SUBSCRIPTION (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); -CREATE INDEX FK_APPLICATION_TAG_APPLICATION ON APPM_APPLICATION_TAG(APPLICATION_ID ASC); -- ----------------------------------------------------- --- Table APPM_VISIBILITY +-- Table AP_UNRESTRICTED_ROLE -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_VISIBILITY ( - ID INT NOT NULL AUTO_INCREMENT, - VALUE VARCHAR(255), - RESOURCE_TYPE_ID INT NOT NULL, - APPLICATION_ID INT NULL, +CREATE TABLE IF NOT EXISTS AP_UNRESTRICTED_ROLE ( + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + ROLE VARCHAR(45) NOT NULL, + AP_APP_ID INT(11) NOT NULL, PRIMARY KEY (ID), - CONSTRAINT fk_APPM_VISIBILITY_APPM_RESOURCE_TYPE1 - FOREIGN KEY (RESOURCE_TYPE_ID) - REFERENCES APPM_RESOURCE_TYPE (ID) - 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 UPDATE CASCADE); + CONSTRAINT fk_AP_APP_VISIBILITY_AP_APP1 + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID)); + +CREATE INDEX fk_AP_APP_VISIBILITY_AP_APP1_idx ON AP_UNRESTRICTED_ROLE (AP_APP_ID ASC); -CREATE INDEX FK_APPM_VISIBILITY_RESOURCE_TYPE ON APPM_VISIBILITY(RESOURCE_TYPE_ID ASC); -CREATE INDEX FK_VISIBILITY_APPLICATION ON APPM_VISIBILITY(APPLICATION_ID ASC); -- ----------------------------------------------------- --- Table APPM_SUBSCRIPTION_PROPERTIES +-- Table AP_USER_SUBSCRIPTION -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_SUBSCRIPTION_PROPERTIES ( - PROP_KEY VARCHAR(500) NOT NULL, - PROP_VALUE VARCHAR(500) NULL, - APPM_SUBSCRIPTION_ID INT NOT NULL, - PRIMARY KEY (PROP_KEY, APPM_SUBSCRIPTION_ID), - CONSTRAINT fk_APPM_SUBSCRIPTION_PROPERTIES_APPM_SUBSCRIPTION1 - FOREIGN KEY (APPM_SUBSCRIPTION_ID) - REFERENCES APPM_SUBSCRIPTION (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION); +CREATE TABLE IF NOT EXISTS AP_USER_SUBSCRIPTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + USER_NAME VARCHAR(100) NOT NULL, + SUBSCRIBED_BY VARCHAR(100) NOT NULL, + SUBSCRIBED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + AP_APP_RELEASE_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_AP_USER_SUBSCRIPTION_AP_APP_RELEASE1 + FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID) + REFERENCES AP_APP_RELEASE (ID , AP_APP_ID)); -CREATE INDEX FK_SUBSCRIPTION_PROPERTIES_SUBSCRIPTION ON APPM_SUBSCRIPTION_PROPERTIES(APPM_SUBSCRIPTION_ID ASC); \ No newline at end of file +CREATE INDEX fk_AP_USER_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_USER_SUBSCRIPTION (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); 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 14b21ad7f8..641c994660 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 @@ -1,5 +1,5 @@ -- MySQL Script generated by MySQL Workbench --- 2017-06-14 12:46:43 +0530 +-- Tue 18 Sep 2018 17:40:45 +0530 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering @@ -7,401 +7,252 @@ SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; --- ----------------------------------------------------- --- Schema WSO2DM_APPM_DB --- ----------------------------------------------------- - --- ----------------------------------------------------- --- Table `APPM_PLATFORM` --- ----------------------------------------------------- -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, -DESCRIPTION VARCHAR (2048), -IS_SHARED BOOLEAN, -IS_DEFAULT_TENANT_MAPPING BOOLEAN, -ICON_NAME VARCHAR (100), -PRIMARY KEY (ID) -); - -CREATE TABLE IF NOT EXISTS APPM_PLATFORM_PROPERTIES ( -ID INT NOT NULL AUTO_INCREMENT, -PLATFORM_ID INT NOT NULL, -PROP_NAME VARCHAR (100) NOT NULL, -OPTIONAL BOOLEAN, -DEFAUL_VALUE VARCHAR (255), -FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE, -PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME) -); - -- ----------------------------------------------------- --- Table `APPM_PLATFORM_TENENT_MAPPING` +-- Table `AP_APP` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_PLATFORM_TENANT_MAPPING` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `PLATFORM_ID` INT NOT NULL, - `TENANT_ID` INT NOT NULL, - PRIMARY KEY (`ID`, `PLATFORM_ID`), - INDEX `FK_PLATFROM_TENANT_MAPPING_PLATFORM` (`PLATFORM_ID` ASC), - CONSTRAINT `fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1` - FOREIGN KEY (`PLATFORM_ID`) - REFERENCES `APPM_PLATFORM` (`ID`) - ON DELETE CASCADE - ON UPDATE CASCADE ) - ENGINE = InnoDB - COMMENT = 'This table contains the data related relationship between application platofrm and appication mappings'; - --- ----------------------------------------------------- --- Table `APPM_APPLICATION_CATEGORY` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_CATEGORY` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `NAME` VARCHAR(100) NOT NULL UNIQUE, - `DESCRIPTION` TEXT NULL, +CREATE TABLE IF NOT EXISTS `AP_APP` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `NAME` VARCHAR(45) NOT NULL, + `TYPE` VARCHAR(200) NOT NULL, + `TENANT_ID` VARCHAR(45) NOT NULL, + `APP_CATEGORY` VARCHAR(45) NULL DEFAULT NULL, + `RESTRICTED` INT(11) NOT NULL, + `STATUS` VARCHAR(45) NOT NULL DEFAULT 'ACTIVE', + `SUB_TYPE` VARCHAR(45) NOT NULL, + `CURRENCY` VARCHAR(45) NULL DEFAULT '$', + `DM_DEVICE_TYPE_ID` INT(11) NOT NULL, PRIMARY KEY (`ID`)) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the application category'; - -INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION) VALUES ('Sports', 'Applications that involve sports.'); -INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION) VALUES ('Education', 'Application related with education'); -INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION) VALUES ('News', 'Applications involving news'); - --- ----------------------------------------------------- --- Table `APPM_LIFECYCLE_STATE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE ( - ID INT NOT NULL AUTO_INCREMENT UNIQUE, - NAME VARCHAR(100) NOT NULL, - IDENTIFIER VARCHAR(100) NOT NULL, - DESCRIPTION TEXT NULL, - PRIMARY KEY (ID), - UNIQUE INDEX APPM_LIFECYCLE_STATE_IDENTIFIER_UNIQUE (IDENTIFIER ASC)); - -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('CREATED', 'CREATED', -'Application creation initial state'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('IN REVIEW', 'IN REVIEW', 'Application is in in-review state'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('APPROVED', 'APPROVED', 'State in which Application is approved after reviewing.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('REJECTED', 'REJECTED', 'State in which Application is rejected after reviewing.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('PUBLISHED', 'PUBLISHED', 'State in which Application is in published state.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('UNPUBLISHED', 'UNPUBLISHED', 'State in which Application is in un published state.'); -INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) -VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); - - -CREATE TABLE IF NOT EXISTS APPM_LC_STATE_TRANSITION -( - ID INT NOT NULL AUTO_INCREMENT UNIQUE, - INITIAL_STATE INT, - NEXT_STATE INT, - PERMISSION VARCHAR(1024), - DESCRIPTION VARCHAR(2048), - PRIMARY KEY (INITIAL_STATE, NEXT_STATE), - FOREIGN KEY (INITIAL_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE, - FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE -); - -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (1, 2, null, 'Submit for review'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (2, 1, null, 'Revoke from review'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (3, 5, null, 'PUBLISH'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (5, 6, null, 'UN PUBLISH'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (6, 5, null, 'PUBLISH'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (4, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (6, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES - (6, 7, null, 'Retire'); - --- ----------------------------------------------------- --- Table `APPM_APPLICATION` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_APPLICATION` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `UUID` VARCHAR(100) NOT NULL, - `NAME` VARCHAR(100) NOT NULL, - `SHORT_DESCRIPTION` VARCHAR(255) NULL, - `DESCRIPTION` TEXT NULL, - `VIDEO_NAME` VARCHAR(100) NULL, - `SCREEN_SHOT_COUNT` INT DEFAULT 0, - `CREATED_BY` VARCHAR(255) NULL, - `CREATED_AT` DATETIME NOT NULL, - `MODIFIED_AT` DATETIME NULL, - `IS_FREE` TINYINT(1) NULL, - `PAYMENT_CURRENCY` VARCHAR(45) NULL, - `PAYMENT_PRICE` DECIMAL(10,2) NULL, - `APPLICATION_CATEGORY_ID` INT NOT NULL, - `LIFECYCLE_STATE_ID` INT NOT NULL, - `LIFECYCLE_STATE_MODIFIED_BY` VARCHAR(255) NULL, - `LIFECYCLE_STATE_MODIFIED_AT` DATETIME NULL, - `TENANT_ID` INT NULL, - `PLATFORM_ID` INT NOT NULL, - PRIMARY KEY (`ID`, `APPLICATION_CATEGORY_ID`, `LIFECYCLE_STATE_ID`, `PLATFORM_ID`), - UNIQUE INDEX `UUID_UNIQUE` (`UUID` ASC), - INDEX `FK_APPLICATION_APPLICATION_CATEGORY` (`APPLICATION_CATEGORY_ID` ASC), - INDEX `FK_APPLICATION_LIFECYCLE_STATE` (`LIFECYCLE_STATE_ID` ASC), - INDEX `FK_APPM_APPLICATION_APPM_PLATFORM` (`PLATFORM_ID` ASC), - CONSTRAINT `FK_APPLICATION_APPLICATION_CATEGORY` - FOREIGN KEY (`APPLICATION_CATEGORY_ID`) - REFERENCES `APPM_APPLICATION_CATEGORY` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_APPM_APPLICATION_APPM_LIFECYCLE_STATE1` - FOREIGN KEY (`LIFECYCLE_STATE_ID`) - REFERENCES `APPM_LIFECYCLE_STATE` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_APPM_APPLICATION_APPM_PLATFORM1` - FOREIGN KEY (`PLATFORM_ID`) - REFERENCES `APPM_PLATFORM` (`ID`) + DEFAULT CHARACTER SET = utf8; + + +-- ----------------------------------------------------- +-- Table `AP_APP_RELEASE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `AP_APP_RELEASE` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `VERSION` VARCHAR(10) NOT NULL, + `TENANT_ID` VARCHAR(45) NOT NULL, + `UUID` VARCHAR(200) NOT NULL, + `RELEASE_TYPE` VARCHAR(45) NOT NULL, + `APP_PRICE` DECIMAL(6,2) NULL DEFAULT NULL, + `STORED_LOCATION` VARCHAR(45) NOT NULL, + `BANNER_LOCATION` VARCHAR(45) NOT NULL, + `SC_1_LOCATION` VARCHAR(45) NOT NULL, + `SC_2_LOCATION` VARCHAR(45) NULL DEFAULT NULL, + `SC_3_LOCATION` VARCHAR(45) NULL DEFAULT NULL, + `APP_HASH_VALUE` VARCHAR(1000) NOT NULL, + `SHARED_WITH_ALL_TENANTS` INT(11) NULL DEFAULT NULL, + `APP_META_INFO` VARCHAR(20000) NULL DEFAULT NULL, + `RATING` DOUBLE NULL DEFAULT NULL, + `RATED_USERS` INT(11) NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`, `AP_APP_ID`), + CONSTRAINT `fk_AP_APP_RELEASE_AP_APP1` + FOREIGN KEY (`AP_APP_ID`) + REFERENCES `AP_APP` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the applications'; + DEFAULT CHARACTER SET = utf8 + COMMENT = ' '; + +CREATE INDEX `fk_AP_APP_RELEASE_AP_APP1_idx` ON `AP_APP_RELEASE` (`AP_APP_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_APPLICATION_PROPERTY` +-- Table `AP_APP_REVIEW` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_PROPERTY` ( - `PROP_KEY` VARCHAR(255) NOT NULL, - `PROP_VAL` TEXT NULL, - `APPLICATION_ID` INT NOT NULL, - PRIMARY KEY (`PROP_KEY`, `APPLICATION_ID`), - INDEX `FK_APPLICATION_PROPERTY_APPLICATION` (`APPLICATION_ID` ASC), - CONSTRAINT `FK_APPLICATION_PROPERTY_APPLICATION` - FOREIGN KEY (`APPLICATION_ID`) - REFERENCES `APPM_APPLICATION` (`ID`) +CREATE TABLE IF NOT EXISTS `AP_APP_REVIEW` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `TENANT_ID` VARCHAR(45) NOT NULL, + `COMMENT` VARCHAR(250) NOT NULL, + `REPLY_COMMENT` VARCHAR(250) NULL, + `CREATED_AT` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + `MODEFIED_AT` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `RATING` INT(11) NULL, + `USERNAME` VARCHAR(45) NOT NULL, + `AP_APP_RELEASE_ID` INT(11) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_AP_APP_COMMENT_AP_APP_RELEASE1` + FOREIGN KEY (`AP_APP_RELEASE_ID` , `AP_APP_ID`) + REFERENCES `AP_APP_RELEASE` (`ID` , `AP_APP_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the properties that related to the application'; + DEFAULT CHARACTER SET = utf8; + +CREATE INDEX `fk_AP_APP_COMMENT_AP_APP_RELEASE1_idx` ON `AP_APP_REVIEW` (`AP_APP_RELEASE_ID` ASC, `AP_APP_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_APPLICATION_RELEASE` +-- Table `AP_APP_LIFECYCLE_STATE` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_RELEASE` ( - `ID` INT NOT NULL AUTO_INCREMENT UNIQUE , - `VERSION_NAME` VARCHAR(100) NOT NULL, - `RELEASE_RESOURCE` TEXT NULL, - `RELEASE_CHANNEL` VARCHAR(50) DEFAULT 'ALPHA', - `RELEASE_DETAILS` TEXT NULL, - `CREATED_AT` DATETIME NOT NULL, - `APPM_APPLICATION_ID` INT NOT NULL, - `IS_DEFAULT` TINYINT(1) NULL, - PRIMARY KEY (`APPM_APPLICATION_ID`, `VERSION_NAME`), - INDEX `FK_APPLICATION_VERSION_APPLICATION` (`APPM_APPLICATION_ID` ASC), - CONSTRAINT `FK_APPLICATION_VERSION_APPLICATION` - FOREIGN KEY (`APPM_APPLICATION_ID`) - REFERENCES `APPM_APPLICATION` (`ID`) +CREATE TABLE IF NOT EXISTS `AP_APP_LIFECYCLE_STATE` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `CURRENT_STATE` VARCHAR(45) NOT NULL, + `PREVIOUSE_STATE` VARCHAR(45) NOT NULL, + `TENANT_ID` VARCHAR(45) NOT NULL, + `UPDATED_BY` VARCHAR(100) NOT NULL, + `UPDATED_AT` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `AP_APP_RELEASE_ID` INT(11) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`, `AP_APP_RELEASE_ID`, `AP_APP_ID`), + CONSTRAINT `fk_AP_APP_LIFECYCLE_STATE_AP_APP_RELEASE1` + FOREIGN KEY (`AP_APP_RELEASE_ID` , `AP_APP_ID`) + REFERENCES `AP_APP_RELEASE` (`ID` , `AP_APP_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the application releases'; + DEFAULT CHARACTER SET = utf8; + +CREATE INDEX `fk_AP_APP_LIFECYCLE_STATE_AP_APP_RELEASE1_idx` ON `AP_APP_LIFECYCLE_STATE` (`AP_APP_RELEASE_ID` ASC, `AP_APP_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_RELEASE_PROPERTY` +-- Table `AP_APP_TAG` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_RELEASE_PROPERTY` ( - `PROP_KEY` VARCHAR(255) NOT NULL, - `PROP_VALUE` TEXT NULL, - `APPLICATION_RELEASE_ID` INT NOT NULL, - PRIMARY KEY (`PROP_KEY`, `APPLICATION_RELEASE_ID`), - INDEX `FK_RELEASE_PROPERTY_APPLICATION_RELEASE` (`APPLICATION_RELEASE_ID` ASC), - CONSTRAINT `FK_RELEASE_PROPERTY_APPLICATION_RELEASE` - FOREIGN KEY (`APPLICATION_RELEASE_ID`) - REFERENCES `APPM_APPLICATION_RELEASE` (`ID`) +CREATE TABLE IF NOT EXISTS `AP_APP_TAG` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `TENANT_ID` VARCHAR(45) NOT NULL, + `TAG` VARCHAR(45) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_AP_APP_TAGS_AP_APP1` + FOREIGN KEY (`AP_APP_ID`) + REFERENCES `AP_APP` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the properties that related to the application release'; - - --- ----------------------------------------------------- --- Table `APPM_RESOURCE_TYPE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_RESOURCE_TYPE` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `NAME` VARCHAR(45) NULL, - `DESCRIPTION` TEXT NULL, - PRIMARY KEY (`ID`)) - ENGINE = InnoDB; + DEFAULT CHARACTER SET = utf8; -INSERT INTO APPM_RESOURCE_TYPE (NAME , DESCRIPTION) VALUES ('PUBLIC', 'OPEN VISIBILITY, CAN BE VIEWED BY ALL LOGGED IN USERS'); -INSERT INTO APPM_RESOURCE_TYPE (NAME , DESCRIPTION) VALUES ('ROLES', 'ROLE BASED RESTRICTION, CAN BE VIEWED BY ONLY GIVEN - SET OF USER WHO HAVE THE SPECIFIED ROLE'); -INSERT INTO APPM_RESOURCE_TYPE (NAME , DESCRIPTION) VALUES ('DEVICE_GROUPS', 'DEVICE GROUP LEVEL RESTRICTION, -CAN BE VIEWED BY THE DEVICES/ROLES BELONG TO THE GROUP'); +CREATE INDEX `fk_AP_APP_TAGS_AP_APP1_idx` ON `AP_APP_TAG` (`AP_APP_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_SUBSCRIPTION` +-- Table `AP_DEVICE_SUBSCRIPTION` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_SUBSCRIPTION` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `VALUE` VARCHAR(255) NOT NULL, - `CREATED_AT` DATETIME NOT NULL, - `RESOURCE_TYPE_ID` INT NOT NULL, - `APPLICATION_ID` INT NOT NULL, - `APPLICATION_RELEASE_ID` INT NULL, - PRIMARY KEY (`ID`, `APPLICATION_ID`, `RESOURCE_TYPE_ID`), - INDEX `FK_APPLICATION_SUBSCRIPTION_RESOURCE_TYPE` (`RESOURCE_TYPE_ID` ASC), - INDEX `FK_APPLICATION_SUBSCRIPTION_APPLICATION` (`APPLICATION_ID` ASC), - INDEX `FK_APPLICATION_SUBSCRIPTION_APPLICATION_RELEASE` (`APPLICATION_RELEASE_ID` ASC), - CONSTRAINT `fk_APPM_APPLICATION_SUBSCRIPTION_APPM_RESOURCE_TYPE1` - FOREIGN KEY (`RESOURCE_TYPE_ID`) - REFERENCES `APPM_RESOURCE_TYPE` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_APPM_APPLICATION_SUBSCRIPTION_APPM_APPLICATION1` - FOREIGN KEY (`APPLICATION_ID`) - REFERENCES `APPM_APPLICATION` (`ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_APPM_APPLICATION_SUBSCRIPTION_APPM_APPLICATION_RELEASE1` - FOREIGN KEY (`APPLICATION_RELEASE_ID`) - REFERENCES `APPM_APPLICATION_RELEASE` (`ID`) +CREATE TABLE IF NOT EXISTS `AP_DEVICE_SUBSCRIPTION` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `TENANT_ID` VARCHAR(45) NOT NULL, + `SUBSCRIBED_BY` VARCHAR(100) NOT NULL, + `SUBSCRIBED_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `UNSUBSCRIBED` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_BY` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_TIMESTAMP` TIMESTAMP NULL DEFAULT NULL, + `DM_ENROLMENT_ID` INT(11) NOT NULL, + `AP_APP_RELEASE_ID` INT(11) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_AP_DEVICE_SUBSCRIPTION_AP_APP_RELEASE1` + FOREIGN KEY (`AP_APP_ID` , `AP_APP_RELEASE_ID`) + REFERENCES `AP_APP_RELEASE` (`AP_APP_ID` , `ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the application subscriptions'; + DEFAULT CHARACTER SET = utf8; + +CREATE INDEX `fk_AP_DEVICE_SUBSCRIPTION_AP_APP_RELEASE1_idx` ON `AP_DEVICE_SUBSCRIPTION` (`AP_APP_ID` ASC, `AP_APP_RELEASE_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_COMMENT` +-- Table `AP_GROUP_SUBSCRIPTION` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_COMMENT` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `APPLICATION_RELEASE_ID` INT NOT NULL, - `COMMENT_SUBJECT` VARCHAR(255) NULL, - `COMMENT_BODY` TEXT NULL, - `RATING` INT NULL, - `PARENT_ID` INT NULL, - `CREATED_AT` DATETIME NOT NULL, - `CREATED_BY` VARCHAR(45) NULL, - `MODIFIED_AT` DATETIME NULL, - `PUBLISHED` TINYINT(1) NULL, - `APPROVED` TINYINT(1) NULL, - PRIMARY KEY (`ID`, `APPLICATION_RELEASE_ID`), - INDEX `FK_APPLICATION_COMMENTS_APPLICATION_RELEASE` (`APPLICATION_RELEASE_ID` ASC), - CONSTRAINT `FK_APPLICATION_COMMENTS_APPLICATION_RELEASE` - FOREIGN KEY (`APPLICATION_RELEASE_ID`) - REFERENCES `APPM_APPLICATION_RELEASE` (`ID`) +CREATE TABLE IF NOT EXISTS `AP_GROUP_SUBSCRIPTION` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `TENANT_ID` VARCHAR(45) NOT NULL, + `SUBSCRIBED_BY` VARCHAR(100) NOT NULL, + `SUBSCRIBED_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `UNSUBSCRIBED` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_BY` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_TIMESTAMP` TIMESTAMP NULL DEFAULT NULL, + `DM_GROUP_ID` INT(11) NOT NULL, + `AP_APP_RELEASE_ID` INT(11) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_AP_GROUP_SUBSCRIPTION_AP_APP_RELEASE1` + FOREIGN KEY (`AP_APP_RELEASE_ID` , `AP_APP_ID`) + REFERENCES `AP_APP_RELEASE` (`ID` , `AP_APP_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the application comments'; + DEFAULT CHARACTER SET = utf8; - --- ----------------------------------------------------- --- Table `APPM_PLATFORM_TAG` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_PLATFORM_TAG` ( - `name` VARCHAR(100) NOT NULL, - `PLATFORM_ID` INT NOT NULL, - PRIMARY KEY (`PLATFORM_ID`, `name`), - INDEX `FK_PLATFORM_TAGS_PLATFORM` (`PLATFORM_ID` ASC), - CONSTRAINT `fk_APPM_SUPPORTED_PLATFORM_TAGS_APPM_SUPPORTED_PLATFORM1` - FOREIGN KEY (`PLATFORM_ID`) - REFERENCES `APPM_PLATFORM` (`ID`) - ON DELETE CASCADE - ON UPDATE CASCADE) - ENGINE = InnoDB - COMMENT = 'This table contains the data related to the app platform tag'; +CREATE INDEX `fk_AP_GROUP_SUBSCRIPTION_AP_APP_RELEASE1_idx` ON `AP_GROUP_SUBSCRIPTION` (`AP_APP_RELEASE_ID` ASC, `AP_APP_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_APPLICATION_TAG` +-- Table `AP_ROLE_SUBSCRIPTION` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_TAG` ( - `NAME` VARCHAR(45) NOT NULL, - `APPLICATION_ID` INT NOT NULL, - PRIMARY KEY (`APPLICATION_ID`, `NAME`), - INDEX `FK_APPLICATION_TAG_APPLICATION` (`APPLICATION_ID` ASC), - CONSTRAINT `fk_APPM_APPLICATION_TAG_APPM_APPLICATION1` - FOREIGN KEY (`APPLICATION_ID`) - REFERENCES `APPM_APPLICATION` (`ID`) +CREATE TABLE IF NOT EXISTS `AP_ROLE_SUBSCRIPTION` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `TENANT_ID` VARCHAR(45) NOT NULL, + `ROLE_NAME` VARCHAR(100) NOT NULL, + `SUBSCRIBED_BY` VARCHAR(100) NOT NULL, + `SUBSCRIBED_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `UNSUBSCRIBED` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_BY` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_TIMESTAMP` TIMESTAMP NULL DEFAULT NULL, + `AP_APP_RELEASE_ID` INT(11) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_AP_ROLE_SUBSCRIPTION_AP_APP_RELEASE1` + FOREIGN KEY (`AP_APP_RELEASE_ID` , `AP_APP_ID`) + REFERENCES `AP_APP_RELEASE` (`ID` , `AP_APP_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB - COMMENT = 'This table contains the data related to the application tags'; + DEFAULT CHARACTER SET = utf8; + +CREATE INDEX `fk_AP_ROLE_SUBSCRIPTION_AP_APP_RELEASE1_idx` ON `AP_ROLE_SUBSCRIPTION` (`AP_APP_RELEASE_ID` ASC, `AP_APP_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_VISIBILITY` +-- Table `AP_UNRESTRICTED_ROLE` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_VISIBILITY` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `VALUE` VARCHAR(255), - `RESOURCE_TYPE_ID` INT NOT NULL, - `APPLICATION_ID` INT NULL, +CREATE TABLE IF NOT EXISTS `AP_UNRESTRICTED_ROLE` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `TENANT_ID` VARCHAR(45) NOT NULL, + `ROLE` VARCHAR(45) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, PRIMARY KEY (`ID`), - INDEX `FK_APPM_VISIBILITY_RESOURCE_TYPE` (`RESOURCE_TYPE_ID` ASC), - INDEX `FK_VISIBILITY_APPLICATION` (`APPLICATION_ID` ASC), - CONSTRAINT `fk_APPM_VISIBILITY_APPM_RESOURCE_TYPE1` - FOREIGN KEY (`RESOURCE_TYPE_ID`) - REFERENCES `APPM_RESOURCE_TYPE` (`ID`) + CONSTRAINT `fk_AP_APP_VISIBILITY_AP_APP1` + FOREIGN KEY (`AP_APP_ID`) + REFERENCES `AP_APP` (`ID`) 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 UPDATE CASCADE ) - ENGINE = InnoDB; + ON UPDATE NO ACTION) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + +CREATE INDEX `fk_AP_APP_VISIBILITY_AP_APP1_idx` ON `AP_UNRESTRICTED_ROLE` (`AP_APP_ID` ASC); -- ----------------------------------------------------- --- Table `APPM_SUBSCRIPTION_PROPERTIES` +-- Table `AP_USER_SUBSCRIPTION` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_SUBSCRIPTION_PROPERTIES` ( - `PROP_KEY` VARCHAR(255) NOT NULL, - `PROP_VALUE` TEXT NULL, - `APPM_SUBSCRIPTION_ID` INT NOT NULL, - PRIMARY KEY (`PROP_KEY`, `APPM_SUBSCRIPTION_ID`), - INDEX `FK_SUBSCRIPTION_PROPERTIES_SUBSCRIPTION` (`APPM_SUBSCRIPTION_ID` ASC), - CONSTRAINT `fk_APPM_SUBSCRIPTION_PROPERTIES_APPM_SUBSCRIPTION1` - FOREIGN KEY (`APPM_SUBSCRIPTION_ID`) - REFERENCES `APPM_SUBSCRIPTION` (`ID`) +CREATE TABLE IF NOT EXISTS `AP_USER_SUBSCRIPTION` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `TENANT_ID` VARCHAR(45) NOT NULL, + `USER_NAME` VARCHAR(100) NOT NULL, + `SUBSCRIBED_BY` VARCHAR(100) NOT NULL, + `SUBSCRIBED_TIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `UNSUBSCRIBED` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_BY` INT(11) NULL DEFAULT NULL, + `UNSUBSCRIBED_TIMESTAMP` TIMESTAMP NULL DEFAULT NULL, + `AP_APP_RELEASE_ID` INT(11) NOT NULL, + `AP_APP_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_AP_USER_SUBSCRIPTION_AP_APP_RELEASE1` + FOREIGN KEY (`AP_APP_RELEASE_ID` , `AP_APP_ID`) + REFERENCES `AP_APP_RELEASE` (`ID` , `AP_APP_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION) - ENGINE = InnoDB; + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; --- ----------------------------------------------------- --- Table `APPM_DEVICE_APPLICATION_MAPPING` --- ----------------------------------------------------- --- CREATE TABLE IF NOT EXISTS `APPM_DEVICE_APPLICATION_MAPPING` ( --- `ID` INT AUTO_INCREMENT NOT NULL, --- `DEVICE_IDENTIFIER` VARCHAR(255) NOT NULL, --- `APPLICATION_UUID` VARCHAR(100) NOT NULL, --- `INSTALLED` BOOLEAN NOT NULL, --- `SENT_AT` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, --- PRIMARY KEY (ID), --- CONSTRAINT `fk_appm_application` FOREIGN KEY (`APPLICATION_UUID`) REFERENCES --- APPM_APPLICATION (`UUID`) ON DELETE NO ACTION ON UPDATE NO ACTION, --- UNIQUE KEY `device_app_mapping` (`DEVICE_IDENTIFIER`, `APPLICATION_UUID`) --- ) ENGINE = InnoDB; +CREATE INDEX `fk_AP_USER_SUBSCRIPTION_AP_APP_RELEASE1_idx` ON `AP_USER_SUBSCRIPTION` (`AP_APP_RELEASE_ID` ASC, `AP_APP_ID` ASC); SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;