forked from community/device-mgt-core
Merge branch 'application-mgt-new' of https://github.com/lasanthaDLPDS/carbon-device-mgt into application-mgt-new
commit
421dc5edf1
@ -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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,350 +1,206 @@
|
|||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
-- Schema WSO2DM_APPM_DB
|
-- Table AP_APP
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS AP_APP (
|
||||||
-- -----------------------------------------------------
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
-- Table APPM_PLATFORM
|
NAME VARCHAR(45) NOT NULL,
|
||||||
-- -----------------------------------------------------
|
TYPE VARCHAR(200) NOT NULL,
|
||||||
CREATE TABLE IF NOT EXISTS APPM_PLATFORM (
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
ID INT NOT NULL AUTO_INCREMENT UNIQUE,
|
APP_CATEGORY VARCHAR(45) NULL DEFAULT NULL,
|
||||||
IDENTIFIER VARCHAR (100) NOT NULL,
|
RESTRICTED INT(11) NOT NULL,
|
||||||
TENANT_ID INT NOT NULL ,
|
STATUS VARCHAR(45) NOT NULL DEFAULT 'ACTIVE',
|
||||||
NAME VARCHAR (255),
|
SUB_TYPE VARCHAR(45) NOT NULL,
|
||||||
FILE_BASED BOOLEAN,
|
CURRENCY VARCHAR(45) NULL DEFAULT '$',
|
||||||
DESCRIPTION LONGVARCHAR,
|
DM_DEVICE_TYPE_ID INT(11) NOT NULL,
|
||||||
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,
|
|
||||||
PRIMARY KEY (ID));
|
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`
|
-- Table AP_APP_RELEASE
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE (
|
CREATE TABLE IF NOT EXISTS AP_APP_RELEASE (
|
||||||
ID INT NOT NULL AUTO_INCREMENT UNIQUE,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
NAME VARCHAR(100) NOT NULL,
|
VERSION VARCHAR(10) NOT NULL,
|
||||||
IDENTIFIER VARCHAR(100) NOT NULL,
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
DESCRIPTION TEXT 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),
|
PRIMARY KEY (ID),
|
||||||
UNIQUE INDEX APPM_LIFECYCLE_STATE_IDENTIFIER_UNIQUE (IDENTIFIER ASC));
|
CONSTRAINT fk_AP_APP_COMMENT_AP_APP_RELEASE1
|
||||||
|
FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID)
|
||||||
INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('CREATED', 'CREATED', 'Application creation
|
REFERENCES AP_APP_RELEASE (ID , AP_APP_ID));
|
||||||
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 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` (
|
CREATE TABLE IF NOT EXISTS AP_APP_LIFECYCLE_STATE (
|
||||||
`ID` INT NOT NULL AUTO_INCREMENT,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
`UUID` VARCHAR(100) NOT NULL,
|
CURRENT_STATE VARCHAR(45) NOT NULL,
|
||||||
`NAME` VARCHAR(100) NOT NULL,
|
PREVIOUSE_STATE VARCHAR(45) NOT NULL,
|
||||||
`SHORT_DESCRIPTION` VARCHAR(255) NULL,
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
`DESCRIPTION` TEXT NULL,
|
UPDATED_BY VARCHAR(100) NOT NULL,
|
||||||
`SCREEN_SHOT_COUNT` INT DEFAULT 0,
|
UPDATED_AT TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
`VIDEO_NAME` VARCHAR(100) NULL,
|
AP_APP_RELEASE_ID INT(11) NOT NULL,
|
||||||
`CREATED_BY` VARCHAR(255) NULL,
|
AP_APP_ID INT(11) NOT NULL,
|
||||||
`CREATED_AT` DATETIME NOT NULL,
|
PRIMARY KEY (ID, AP_APP_RELEASE_ID, AP_APP_ID),
|
||||||
`MODIFIED_AT` DATETIME NULL,
|
CONSTRAINT fk_AP_APP_LIFECYCLE_STATE_AP_APP_RELEASE1
|
||||||
`IS_FREE` TINYINT(1) NULL,
|
FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID)
|
||||||
`PAYMENT_CURRENCY` VARCHAR(45) NULL,
|
REFERENCES AP_APP_RELEASE (ID , AP_APP_ID));
|
||||||
`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 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_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_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 (
|
CREATE TABLE IF NOT EXISTS AP_APP_TAG (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
VERSION_NAME VARCHAR(100) NOT NULL,
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
RELEASE_RESOURCE TEXT NULL,
|
TAG VARCHAR(45) NOT NULL,
|
||||||
RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA',
|
AP_APP_ID INT(11) NOT NULL,
|
||||||
RELEASE_DETAILS TEXT NULL,
|
PRIMARY KEY (ID),
|
||||||
CREATED_AT DATETIME NOT NULL,
|
CONSTRAINT fk_AP_APP_TAGS_AP_APP1
|
||||||
APPM_APPLICATION_ID INT NOT NULL,
|
FOREIGN KEY (AP_APP_ID)
|
||||||
IS_DEFAULT TINYINT NULL,
|
REFERENCES AP_APP (ID));
|
||||||
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 INDEX fk_AP_APP_TAGS_AP_APP1_idx ON AP_APP_TAG (AP_APP_ID ASC);
|
||||||
-- 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_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 (
|
CREATE TABLE IF NOT EXISTS AP_DEVICE_SUBSCRIPTION (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
NAME VARCHAR(45) NULL,
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
DESCRIPTION TEXT NULL,
|
SUBSCRIBED_BY VARCHAR(100) NOT NULL,
|
||||||
PRIMARY KEY (ID));
|
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');
|
CREATE INDEX fk_AP_DEVICE_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_DEVICE_SUBSCRIPTION (AP_APP_ID ASC, AP_APP_RELEASE_ID ASC);
|
||||||
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');
|
|
||||||
|
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
-- Table APPM_SUBSCRIPTION
|
-- Table AP_GROUP_SUBSCRIPTION
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS APPM_SUBSCRIPTION (
|
CREATE TABLE IF NOT EXISTS AP_GROUP_SUBSCRIPTION (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
VALUE VARCHAR(255) NOT NULL,
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
CREATED_AT DATETIME NOT NULL,
|
SUBSCRIBED_BY VARCHAR(100) NOT NULL,
|
||||||
RESOURCE_TYPE_ID INT NOT NULL,
|
SUBSCRIBED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
APPLICATION_ID INT NOT NULL,
|
UNSUBSCRIBED INT(11) NULL DEFAULT NULL,
|
||||||
APPLICATION_RELEASE_ID INT NULL,
|
UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (ID, APPLICATION_ID, RESOURCE_TYPE_ID),
|
UNSUBSCRIBED_TIMESTAMP TIMESTAMP NULL DEFAULT NULL,
|
||||||
CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_RESOURCE_TYPE1
|
DM_GROUP_ID INT(11) NOT NULL,
|
||||||
FOREIGN KEY (RESOURCE_TYPE_ID)
|
AP_APP_RELEASE_ID INT(11) NOT NULL,
|
||||||
REFERENCES APPM_RESOURCE_TYPE (ID)
|
AP_APP_ID INT(11) NOT NULL,
|
||||||
ON DELETE NO ACTION
|
PRIMARY KEY (ID),
|
||||||
ON UPDATE NO ACTION,
|
CONSTRAINT fk_AP_GROUP_SUBSCRIPTION_AP_APP_RELEASE1
|
||||||
CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_APPLICATION1
|
FOREIGN KEY (AP_APP_RELEASE_ID , AP_APP_ID)
|
||||||
FOREIGN KEY (APPLICATION_ID)
|
REFERENCES AP_APP_RELEASE (ID , AP_APP_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 INDEX fk_AP_GROUP_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_GROUP_SUBSCRIPTION (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC);
|
||||||
-- 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_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 (
|
CREATE TABLE IF NOT EXISTS AP_ROLE_SUBSCRIPTION (
|
||||||
NAME VARCHAR(100) NOT NULL,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
PLATFORM_ID INT NOT NULL,
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
PRIMARY KEY (PLATFORM_ID, name),
|
ROLE_NAME VARCHAR(100) NOT NULL,
|
||||||
CONSTRAINT fk_APPM_SUPPORTED_PLATFORM_TAGS_APPM_SUPPORTED_PLATFORM1
|
SUBSCRIBED_BY VARCHAR(100) NOT NULL,
|
||||||
FOREIGN KEY (PLATFORM_ID)
|
SUBSCRIBED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
REFERENCES APPM_PLATFORM (ID)
|
UNSUBSCRIBED INT(11) NULL DEFAULT NULL,
|
||||||
ON DELETE CASCADE
|
UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL,
|
||||||
ON UPDATE CASCADE);
|
UNSUBSCRIBED_TIMESTAMP TIMESTAMP NULL DEFAULT NULL,
|
||||||
|
AP_APP_RELEASE_ID INT(11) NOT NULL,
|
||||||
CREATE INDEX FK_PLATFORM_TAGS_PLATFORM ON APPM_PLATFORM_TAG(PLATFORM_ID ASC);
|
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));
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
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_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_APPLICATION_TAG_APPLICATION ON APPM_APPLICATION_TAG(APPLICATION_ID ASC);
|
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
-- Table APPM_VISIBILITY
|
-- Table AP_UNRESTRICTED_ROLE
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS APPM_VISIBILITY (
|
CREATE TABLE IF NOT EXISTS AP_UNRESTRICTED_ROLE (
|
||||||
ID INT NOT NULL AUTO_INCREMENT,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
VALUE VARCHAR(255),
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
RESOURCE_TYPE_ID INT NOT NULL,
|
ROLE VARCHAR(45) NOT NULL,
|
||||||
APPLICATION_ID INT NULL,
|
AP_APP_ID INT(11) NOT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT fk_APPM_VISIBILITY_APPM_RESOURCE_TYPE1
|
CONSTRAINT fk_AP_APP_VISIBILITY_AP_APP1
|
||||||
FOREIGN KEY (RESOURCE_TYPE_ID)
|
FOREIGN KEY (AP_APP_ID)
|
||||||
REFERENCES APPM_RESOURCE_TYPE (ID)
|
REFERENCES AP_APP (ID));
|
||||||
ON DELETE NO ACTION
|
|
||||||
ON UPDATE NO ACTION,
|
CREATE INDEX fk_AP_APP_VISIBILITY_AP_APP1_idx ON AP_UNRESTRICTED_ROLE (AP_APP_ID ASC);
|
||||||
CONSTRAINT fk_APPM_VISIBILITY_APPM_APPLICATION1
|
|
||||||
FOREIGN KEY (APPLICATION_ID)
|
|
||||||
REFERENCES APPM_APPLICATION (ID)
|
|
||||||
ON DELETE CASCADE
|
|
||||||
ON UPDATE CASCADE);
|
|
||||||
|
|
||||||
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 (
|
CREATE TABLE IF NOT EXISTS AP_USER_SUBSCRIPTION (
|
||||||
PROP_KEY VARCHAR(500) NOT NULL,
|
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
PROP_VALUE VARCHAR(500) NULL,
|
TENANT_ID VARCHAR(45) NOT NULL,
|
||||||
APPM_SUBSCRIPTION_ID INT NOT NULL,
|
USER_NAME VARCHAR(100) NOT NULL,
|
||||||
PRIMARY KEY (PROP_KEY, APPM_SUBSCRIPTION_ID),
|
SUBSCRIBED_BY VARCHAR(100) NOT NULL,
|
||||||
CONSTRAINT fk_APPM_SUBSCRIPTION_PROPERTIES_APPM_SUBSCRIPTION1
|
SUBSCRIBED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
FOREIGN KEY (APPM_SUBSCRIPTION_ID)
|
UNSUBSCRIBED INT(11) NULL DEFAULT NULL,
|
||||||
REFERENCES APPM_SUBSCRIPTION (ID)
|
UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL,
|
||||||
ON DELETE NO ACTION
|
UNSUBSCRIBED_TIMESTAMP TIMESTAMP NULL DEFAULT NULL,
|
||||||
ON UPDATE NO ACTION);
|
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);
|
CREATE INDEX fk_AP_USER_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_USER_SUBSCRIPTION (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC);
|
||||||
|
Loading…
Reference in new issue