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 b17cf533908..95b23b9d4ef 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 @@ -2,16 +2,16 @@ -- Table AP_APP -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP( - ID int NOT NULL AUTO_INCREMENT, - NAME varchar(45) NOT NULL, - DESCRIPTION clob NULL, - TYPE varchar(200) NOT NULL, - TENANT_ID varchar(45) NOT NULL, - STATUS varchar(45) NOT NULL DEFAULT 'ACTIVE', - SUB_TYPE varchar(45) NOT NULL, - CURRENCY varchar(45) NULL DEFAULT '$', - RATING int NULL, - DEVICE_TYPE_ID int NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(45) NOT NULL, + DESCRIPTION CLOB NULL, + TYPE VARCHAR(200) NOT NULL, + TENANT_ID VARCHAR(45) NOT NULL, + STATUS VARCHAR(45) NOT NULL DEFAULT 'ACTIVE', + SUB_TYPE VARCHAR(45) NOT NULL, + CURRENCY VARCHAR(45) NULL DEFAULT '$', + RATING INT(11) NULL, + DEVICE_TYPE_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -19,49 +19,47 @@ CREATE TABLE IF NOT EXISTS AP_APP( -- Table AP_APP_RELEASE -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP_RELEASE( - ID int NOT NULL AUTO_INCREMENT, - DESCRIPTION clob NOT NULL, - VERSION varchar(10) NOT NULL, - TENANT_ID varchar(45) NOT NULL, - UUID varchar(200) NOT NULL, - RELEASE_TYPE varchar(45) NOT NULL, - PACKAGE_NAME varchar(45) NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + DESCRIPTION CLOB NOT NULL, + VERSION VARCHAR(10) NOT NULL, + TENANT_ID VARCHAR(45) NOT NULL, + UUID VARCHAR(200) NOT NULL, + RELEASE_TYPE VARCHAR(45) NOT NULL, + PACKAGE_NAME VARCHAR(45) NOT NULL, APP_PRICE decimal(6, 2) NULL DEFAULT NULL, - INSTALLER_LOCATION varchar(100) NOT NULL, - ICON_LOCATION varchar(100) NOT NULL, - BANNER_LOCATION varchar(100) NOT NULL, - SC_1_LOCATION varchar(100) NOT NULL, - SC_2_LOCATION varchar(100) NULL DEFAULT NULL, - SC_3_LOCATION varchar(100) NULL DEFAULT NULL, - APP_HASH_VALUE varchar(1000) NOT NULL, - SHARED_WITH_ALL_TENANTS tinyint NOT NULL, - APP_META_INFO clob NULL DEFAULT NULL, - SUPPORTED_OS_VERSIONS varchar(45) NOT NULL, - RATING double NULL DEFAULT NULL, - CURRENT_STATE varchar(45) NOT NULL, - RATED_USERS int NULL, - AP_APP_ID int NOT NULL, + INSTALLER_LOCATION VARCHAR(100) NOT NULL, + ICON_LOCATION VARCHAR(100) NOT NULL, + BANNER_LOCATION VARCHAR(100) NOT NULL, + SC_1_LOCATION VARCHAR(100) NOT NULL, + SC_2_LOCATION VARCHAR(100) NULL DEFAULT NULL, + SC_3_LOCATION VARCHAR(100) NULL DEFAULT NULL, + APP_HASH_VALUE VARCHAR(1000) NOT NULL, + SHARED_WITH_ALL_TENANTS tinyINT NOT NULL, + APP_META_INFO CLOB NULL DEFAULT NULL, + SUPPORTED_OS_VERSIONS VARCHAR(45) NOT NULL, + RATING DOUBLE NULL DEFAULT NULL, + CURRENT_STATE VARCHAR(45) NOT NULL, + RATED_USERS INT(11) NULL, + AP_APP_ID INT(11) NOT NULL, PRIMARY KEY (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 -); -CREATE INDEX fk_AP_APP_RELEASE_AP_APP1_idx ON AP_APP_RELEASE (AP_APP_ID ASC); + REFERENCES AP_APP (ID)); -- ----------------------------------------------------- -- Table AP_APP_REVIEW -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP_REVIEW( - ID int 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(), - MODIFIED_AT timestamp NOT NULL DEFAULT current_timestamp(), - RATING int NULL, - USERNAME varchar(45) NOT NULL, - AP_APP_RELEASE_ID int NOT NULL, - AP_APP_ID int NOT NULL, + 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, + MODIFIED_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 NOT NULL, + AP_APP_ID INT(11) NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_AP_APP_COMMENT_AP_APP_RELEASE1 FOREIGN KEY ( @@ -71,22 +69,20 @@ CREATE TABLE IF NOT EXISTS AP_APP_REVIEW( REFERENCES AP_APP_RELEASE ( ID, AP_APP_ID - ) ON DELETE NO ACTION ON UPDATE NO ACTION -); -CREATE INDEX fk_AP_APP_COMMENT_AP_APP_RELEASE1_idx ON AP_APP_REVIEW (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); + ) ); -- ----------------------------------------------------- -- Table AP_APP_LIFECYCLE_STATE -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP_LIFECYCLE_STATE( - ID int 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(), - AP_APP_RELEASE_ID int NOT NULL, - AP_APP_ID int NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + CURRENT_STATE VARCHAR(45) NOT NULL, + PREVIOUS_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 NOT NULL, + AP_APP_ID INT(11) NOT NULL, PRIMARY KEY ( ID, AP_APP_RELEASE_ID, @@ -100,17 +96,15 @@ CREATE TABLE IF NOT EXISTS AP_APP_LIFECYCLE_STATE( REFERENCES AP_APP_RELEASE ( ID, AP_APP_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); + ) ); -- ----------------------------------------------------- -- Table AP_APP_TAG -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP_TAG( - ID int NOT NULL AUTO_INCREMENT, - TENANT_ID varchar(45) NOT NULL, - TAG varchar(45) NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + TAG VARCHAR(45) NOT NULL, PRIMARY KEY (ID) ); @@ -118,17 +112,17 @@ CREATE TABLE IF NOT EXISTS AP_APP_TAG( -- Table AP_DEVICE_SUBSCRIPTION -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_DEVICE_SUBSCRIPTION( - ID int NOT NULL AUTO_INCREMENT, - TENANT_ID varchar(45) NOT NULL, - SUBSCRIBED_BY varchar(100) NOT NULL, - SUBSCRIBED_TIMESTAMP timestamp NOT NULL DEFAULT current_timestamp(), - UNSUBSCRIBED int NULL DEFAULT NULL, - UNSUBSCRIBED_BY int NULL DEFAULT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + SUBSCRIBED_BY VARCHAR(100) NOT NULL, + SUBSCRIBED_TIMESTAMP timestamp NOT NULL, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, UNSUBSCRIBED_TIMESTAMP timestamp NULL DEFAULT NULL, - SUBSCRIBED_FROM varchar(45) NULL, - DM_DEVICE_ID int NOT NULL, - AP_APP_RELEASE_ID int NOT NULL, - AP_APP_ID int NOT NULL, + SUBSCRIBED_FROM VARCHAR(45) NULL, + DM_DEVICE_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 ( @@ -138,24 +132,22 @@ CREATE TABLE IF NOT EXISTS AP_DEVICE_SUBSCRIPTION( REFERENCES AP_APP_RELEASE ( ID, AP_APP_ID - ) ON DELETE NO ACTION ON UPDATE NO ACTION -); -CREATE INDEX fk_AP_DEVICE_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_DEVICE_SUBSCRIPTION (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); + ) ); -- ----------------------------------------------------- -- Table AP_GROUP_SUBSCRIPTION -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_GROUP_SUBSCRIPTION( - ID int NOT NULL AUTO_INCREMENT, - TENANT_ID varchar(45) NOT NULL, - SUBSCRIBED_BY varchar(100) NOT NULL, - SUBSCRIBED_TIMESTAMP timestamp NOT NULL DEFAULT current_timestamp(), - UNSUBSCRIBED int NULL DEFAULT NULL, - UNSUBSCRIBED_BY int NULL DEFAULT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + SUBSCRIBED_BY VARCHAR(100) NOT NULL, + SUBSCRIBED_TIMESTAMP timestamp NOT NULL, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, UNSUBSCRIBED_TIMESTAMP timestamp NULL DEFAULT NULL, - DM_GROUP_ID int NOT NULL, - AP_APP_RELEASE_ID int NOT NULL, - AP_APP_ID int NOT 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 ( @@ -165,24 +157,22 @@ CREATE TABLE IF NOT EXISTS AP_GROUP_SUBSCRIPTION( REFERENCES AP_APP_RELEASE ( ID, AP_APP_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); + ) ); -- ----------------------------------------------------- -- Table AP_ROLE_SUBSCRIPTION -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_ROLE_SUBSCRIPTION( - ID int 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(), - UNSUBSCRIBED int NULL DEFAULT NULL, - UNSUBSCRIBED_BY int NULL DEFAULT NULL, + 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, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, UNSUBSCRIBED_TIMESTAMP timestamp NULL DEFAULT NULL, - AP_APP_RELEASE_ID int NOT NULL, - AP_APP_ID int NOT 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 ( @@ -192,39 +182,35 @@ CREATE TABLE IF NOT EXISTS AP_ROLE_SUBSCRIPTION( REFERENCES AP_APP_RELEASE ( ID, AP_APP_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); + ) ); -- ----------------------------------------------------- -- Table AP_UNRESTRICTED_ROLE -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_UNRESTRICTED_ROLE( - ID int NOT NULL AUTO_INCREMENT, - TENANT_ID varchar(45) NOT NULL, - ROLE varchar(45) NOT NULL, - AP_APP_ID int NOT NULL, + 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_AP_APP_VISIBILITY_AP_APP1 FOREIGN KEY (AP_APP_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); + REFERENCES AP_APP (ID) ); -- ----------------------------------------------------- -- Table AP_USER_SUBSCRIPTION -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_USER_SUBSCRIPTION( - ID int 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(), - UNSUBSCRIBED int NULL DEFAULT NULL, - UNSUBSCRIBED_BY int NULL DEFAULT NULL, + 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, + UNSUBSCRIBED INT(11) NULL DEFAULT NULL, + UNSUBSCRIBED_BY INT(11) NULL DEFAULT NULL, UNSUBSCRIBED_TIMESTAMP timestamp NULL DEFAULT NULL, - AP_APP_RELEASE_ID int NOT NULL, - AP_APP_ID int NOT 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 ( @@ -234,18 +220,16 @@ CREATE TABLE IF NOT EXISTS AP_USER_SUBSCRIPTION( REFERENCES AP_APP_RELEASE ( ID, AP_APP_ID - ) ON DELETE NO ACTION ON UPDATE NO ACTION -); -CREATE INDEX fk_AP_USER_SUBSCRIPTION_AP_APP_RELEASE1_idx ON AP_USER_SUBSCRIPTION (AP_APP_RELEASE_ID ASC, AP_APP_ID ASC); + ) ); -- ----------------------------------------------------- -- Table AP_APP_CATEGORY -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP_CATEGORY( - ID int NOT NULL AUTO_INCREMENT, - TENANT_ID varchar(45) NOT NULL, - CATEGORY varchar(45) NOT NULL, - CATEGORY_ICON varchar(45) NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + TENANT_ID VARCHAR(45) NOT NULL, + CATEGORY VARCHAR(45) NOT NULL, + CATEGORY_ICON VARCHAR(45) NULL, PRIMARY KEY (ID) ); @@ -253,34 +237,28 @@ CREATE TABLE IF NOT EXISTS AP_APP_CATEGORY( -- Table AP_APP_TAG_MAPPING -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP_TAG_MAPPING( - ID int NOT NULL AUTO_INCREMENT, - AP_APP_TAG_ID int NOT NULL, - AP_APP_ID int NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + AP_APP_TAG_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_AP_APP_TAG_copy1_AP_APP_TAG1 FOREIGN KEY (AP_APP_TAG_ID) - REFERENCES AP_APP_TAG (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + REFERENCES AP_APP_TAG (ID), CONSTRAINT fk_AP_APP_TAG_copy1_AP_APP1 FOREIGN KEY (AP_APP_ID) - REFERENCES AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION -); -CREATE INDEX fk_AP_APP_TAG_copy1_AP_APP_TAG1_idx ON AP_APP_TAG_MAPPING (AP_APP_TAG_ID ASC); -CREATE INDEX fk_AP_APP_TAG_copy1_AP_APP1_idx ON AP_APP_TAG_MAPPING (AP_APP_ID ASC); + REFERENCES AP_APP (ID) ); -- ----------------------------------------------------- -- Table AP_APP_CATEGORY_MAPPING -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AP_APP_CATEGORY_MAPPING( - ID int NOT NULL AUTO_INCREMENT, - AP_APP_CATEGORY_ID int NOT NULL, - AP_APP_ID int NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + AP_APP_CATEGORY_ID INT(11) NOT NULL, + AP_APP_ID INT(11) NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_AP_APP_CATEGORY_copy1_AP_APP_CATEGORY1 FOREIGN KEY (AP_APP_CATEGORY_ID) - REFERENCES AP_APP_CATEGORY (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + REFERENCES AP_APP_CATEGORY (ID), CONSTRAINT fk_AP_APP_CATEGORY_copy1_AP_APP1 FOREIGN KEY (AP_APP_ID) - REFERENCES AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION -); -CREATE INDEX fk_AP_APP_CATEGORY_copy1_AP_APP_CATEGORY1_idx ON AP_APP_CATEGORY_MAPPING (AP_APP_CATEGORY_ID ASC); -CREATE INDEX fk_AP_APP_CATEGORY_copy1_AP_APP1_idx ON AP_APP_CATEGORY_MAPPING (AP_APP_ID ASC); + REFERENCES AP_APP (ID) );