From a198191a8ad8b8cee8f737b96ecdb50a16118669 Mon Sep 17 00:00:00 2001 From: Thashmi-nil Date: Thu, 27 Apr 2023 09:47:37 +0530 Subject: [PATCH] add DB table scripts --- .../org.wso2.carbon.device.mgt.core/pom.xml | 12 +++++++++++ .../src/main/resources/dbscripts/cdm/h2.sql | 8 ++++++++ .../main/resources/dbscripts/cdm/mssql.sql | 9 +++++++++ .../main/resources/dbscripts/cdm/mysql.sql | 8 ++++++++ .../main/resources/dbscripts/cdm/oracle.sql | 20 +++++++++++++++++++ .../resources/dbscripts/cdm/postgresql.sql | 11 ++++++++++ 6 files changed, 68 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 1265503f18..02013d36b5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -358,6 +358,18 @@ org.wso2.carbon.devicemgt io.entgra.notification.logger + + org.wso2.orbit.javax.xml.bind + jaxb-api + 2.3.1.wso2v1 + compile + + + org.wso2.orbit.javax.xml.bind + jaxb-api + 2.3.1.wso2v1 + compile + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 960fedcc20..5a7881793a 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -417,6 +417,14 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + PRIMARY KEY (ID) +); + -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index d43294bd34..b12f586bcf 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -446,6 +446,15 @@ CREATE INDEX IDX_DM_APPLICATION ON DM_APPLICATION(DEVICE_ID, ENROLMENT_ID, TENAN -- POLICY RELATED TABLES FINISHED -- +IF NOT EXISTS (SELECT * SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_APP_ICONS]') AND TYPE IN (N'U')) +CREATE TABLE DM_APP_ICONS ( + ID INTEGER IDENTITY(1,1) NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + PRIMARY KEY (ID) +); + -- POLICY AND DEVICE GROUP MAPPING -- IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_GROUP_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_GROUP_POLICY ( diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 4981e15870..001d9eb5db 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -458,6 +458,14 @@ CREATE INDEX IDX_DM_APPLICATION ON DM_APPLICATION(DEVICE_ID, ENROLMENT_ID, TENAN -- END OF POLICY RELATED TABLES -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + PRIMARY KEY (ID) +)ENGINE = InnoDB; + -- POLICY AND DEVICE GROUP MAPPING -- CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 10554077ab..8b0307011c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -748,6 +748,26 @@ WHEN (NEW.ID IS NULL) -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE DM_APP_ICONS ( + ID NUMBER(10) NOT NULL, + ICON_PATH VARCHAR2(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR2(150) NOT NULL, + VERSION VARCHAR2(50) DEFAULT '1.1.0', + PRIMARY KEY (ID) +) +/ + +-- Generate ID using sequence and trigger +CREATE SEQUENCE DM_APP_ICONS_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_APP_ICONS_seq_tr +BEFORE INSERT ON DM_APP_ICONS FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_APP_ICONS_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; +/ + -- NOTIFICATION TABLE -- CREATE TABLE DM_NOTIFICATION ( NOTIFICATION_ID NUMBER(10) NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index dca570ebf0..5bde66fc30 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -490,6 +490,17 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- END OF POLICY RELATED TABLES -- +CREATE SEQUENCE DM_APP_ICONS_seq; + +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER DEFAULT NEXTVAL ('DM_APP_ICONS_seq') NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + PRIMARY KEY (ID) +) +; + -- POLICY AND DEVICE GROUP MAPPING -- CREATE SEQUENCE DM_DEVICE_GROUP_POLICY_seq;