From 3c425ab0ebc07044cd92e27e412f18d9768d9c09 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 19 Jan 2015 00:46:04 +0530 Subject: [PATCH] Configuring device management related schemas to be copied to dbscripts directory during the feature installation --- .../src/main/resources/dbscripts/cdm/h2.sql | 26 ++++++++++++++ .../main/resources/dbscripts/cdm/mysql.sql | 35 +++++++++++++++++++ .../src/main/resources/p2.inf | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql new file mode 100644 index 00000000000..783acaa8de7 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -0,0 +1,26 @@ +CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE +( + ID INT(11) auto_increment NOT NULL, + NAME VARCHAR(300) NULL DEFAULT NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE +( + ID INT auto_increment NOT NULL, + DESCRIPTION TEXT NULL DEFAULT NULL, + NAME VARCHAR(100) NULL DEFAULT NULL, + DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL, + DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL, + OWNERSHIP VARCHAR(45) NULL DEFAULT NULL, + STATUS VARCHAR(15) NULL DEFAULT NULL, + DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL, + OWNER VARCHAR(45) NULL DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) + REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION +); +-- TO:DO - Remove this INSERT sql statement. +Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android'); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql new file mode 100644 index 00000000000..bc04de8732b --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -0,0 +1,35 @@ +-- ----------------------------------------------------- +-- Table `DM_DEVICE_TYPE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` ( + `ID` INT(11) NOT NULL , + `NAME` VARCHAR(300) NULL DEFAULT NULL , + PRIMARY KEY (`ID`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `DM_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DM_DEVICE` ( + `ID` VARCHAR(20) NOT NULL , + `DESCRIPTION` TEXT NULL DEFAULT NULL , + `NAME` VARCHAR(100) NULL DEFAULT NULL , + `DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL , + `DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL , + `OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL , + `STATUS` VARCHAR(15) NULL DEFAULT NULL , + `DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL , + `DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL , + `OWNER` VARCHAR(45) NULL DEFAULT NULL , + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (`ID`) , + INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) , + CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2` + FOREIGN KEY (`DEVICE_TYPE_ID` ) + REFERENCES `DM_DEVICE_TYPE` (`ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf index b5222094b32..eabcf094d8d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/p2.inf @@ -1,3 +1,3 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\ - +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\