From e600627f78c0aff2a55aa6d50ddec407fe7cd9a1 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Thu, 29 Oct 2015 10:17:32 +0530 Subject: [PATCH 1/8] Refactored postgresql DB Scripts --- .../dbscripts/plugins/android/postgresql.sql | 11 +++---- .../dbscripts/plugins/android/postgresql.sql~ | 30 +++++++++++++++++++ .../dbscripts/plugins/ios/postgresql.sql | 4 ++- .../dbscripts/plugins/windows/postgresql.sql | 6 ++-- 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql index 8c3f0591b..e169deab7 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql @@ -1,7 +1,8 @@ -- ----------------------------------------------------- -- Table AD_DEVICE -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS AD_DEVICE ( +DROP TABLE IF EXISTS AD_DEVICE; +CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , DEVICE_INFO VARCHAR(500) NULL DEFAULT NULL, GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, @@ -21,10 +22,10 @@ CREATE TABLE IF NOT EXISTS AD_DEVICE ( -- ----------------------------------------------------- -- Table AD_FEATURE -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS AD_FEATURE ( - ID INT NOT NULL AUTO_INCREMENT, +DROP TABLE IF EXISTS AD_FEATURE; +CREATE TABLE AD_FEATURE ( + ID BIGSERIAL NOT NULL PRIMARY KEY, CODE VARCHAR(45) NOT NULL, NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) + DESCRIPTION VARCHAR(200) NULL ); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ new file mode 100644 index 000000000..8c3f0591b --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ @@ -0,0 +1,30 @@ +-- ----------------------------------------------------- +-- Table AD_DEVICE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL , + DEVICE_INFO VARCHAR(500) NULL DEFAULT NULL, + GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, + IMEI VARCHAR(45) NULL DEFAULT NULL, + IMSI VARCHAR(45) NULL DEFAULT NULL, + OS_VERSION VARCHAR(45) NULL DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, + VENDOR VARCHAR(45) NULL DEFAULT NULL, + LATITUDE VARCHAR(45) NULL DEFAULT NULL, + LONGITUDE VARCHAR(45) NULL DEFAULT NULL, + SERIAL VARCHAR(45) NULL DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, + DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, + PRIMARY KEY (DEVICE_ID) + ); + +-- ----------------------------------------------------- +-- Table AD_FEATURE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AD_FEATURE ( + ID INT NOT NULL AUTO_INCREMENT, + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NULL, + DESCRIPTION VARCHAR(200) NULL, + PRIMARY KEY (ID) +); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql index 79b342ca3..08fb28def 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql @@ -1,7 +1,8 @@ -- ----------------------------------------------------- -- Table IOS_FEATURE -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS IOS_FEATURE ( +DROP TABLE IF EXISTS IOS_FEATURE; +CREATE TABLE IOS_FEATURE ( ID SERIAL NOT NULL, CODE VARCHAR(45) NOT NULL, NAME VARCHAR(100) NULL, @@ -12,6 +13,7 @@ CREATE TABLE IF NOT EXISTS IOS_FEATURE ( -- ----------------------------------------------------- -- Table IOS_DEVICE -- ----------------------------------------------------- +DROP TABLE IF EXISTS IOS_DEVICE; CREATE TABLE IF NOT EXISTS IOS_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL, APNS_PUSH_TOKEN VARCHAR(100) NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql index 45754d06f..0f886bfb5 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql @@ -1,7 +1,8 @@ -- ----------------------------------------------------- -- Table WIN_DEVICE -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS WIN_DEVICE ( +DROP TABLE IF EXISTS WIN_DEVICE; +CREATE TABLE WIN_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL, PUSH_TOKEN VARCHAR(45) NULL DEFAULT NULL, IMEI VARCHAR(45) NULL DEFAULT NULL, @@ -21,7 +22,8 @@ CREATE TABLE IF NOT EXISTS WIN_DEVICE ( -- ----------------------------------------------------- -- Table WIN_FEATURE -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS WIN_FEATURE ( +DROP TABLE IF EXISTS WIN_FEATURE; +CREATE TABLE WIN_FEATURE ( ID SERIAL NOT NULL, DEVICE_TYPE VARCHAR(45) NOT NULL, CODE VARCHAR(45) NULL, From 53b0737632bb03d0ae9b70c5a0ea2892123cb2ae Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Thu, 29 Oct 2015 11:52:31 +0530 Subject: [PATCH 2/8] Refactored postgresql Db scripts --- .../main/resources/dbscripts/plugins/android/postgresql.sql | 6 ++---- .../src/main/resources/dbscripts/plugins/ios/postgresql.sql | 6 ++---- .../main/resources/dbscripts/plugins/windows/postgresql.sql | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql index e169deab7..2b3057de3 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql @@ -1,8 +1,7 @@ -- ----------------------------------------------------- -- Table AD_DEVICE -- ----------------------------------------------------- -DROP TABLE IF EXISTS AD_DEVICE; -CREATE TABLE AD_DEVICE ( +CREATE TABLE IF NOT EXISTS AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , DEVICE_INFO VARCHAR(500) NULL DEFAULT NULL, GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, @@ -22,8 +21,7 @@ CREATE TABLE AD_DEVICE ( -- ----------------------------------------------------- -- Table AD_FEATURE -- ----------------------------------------------------- -DROP TABLE IF EXISTS AD_FEATURE; -CREATE TABLE AD_FEATURE ( +CREATE TABLE IF NOT EXISTS AD_FEATURE ( ID BIGSERIAL NOT NULL PRIMARY KEY, CODE VARCHAR(45) NOT NULL, NAME VARCHAR(100) NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql index 08fb28def..564e1c3a8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql @@ -1,8 +1,7 @@ -- ----------------------------------------------------- -- Table IOS_FEATURE -- ----------------------------------------------------- -DROP TABLE IF EXISTS IOS_FEATURE; -CREATE TABLE IOS_FEATURE ( +CREATE TABLE IF NOT EXISTS IOS_FEATURE ( ID SERIAL NOT NULL, CODE VARCHAR(45) NOT NULL, NAME VARCHAR(100) NULL, @@ -13,8 +12,7 @@ CREATE TABLE IOS_FEATURE ( -- ----------------------------------------------------- -- Table IOS_DEVICE -- ----------------------------------------------------- -DROP TABLE IF EXISTS IOS_DEVICE; -CREATE TABLE IF NOT EXISTS IOS_DEVICE ( +CREATE TABLE IF NOT EXISTS IOS_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL, APNS_PUSH_TOKEN VARCHAR(100) NULL DEFAULT NULL, MAGIC_TOKEN VARCHAR(100) NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql index 0f886bfb5..45754d06f 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql @@ -1,8 +1,7 @@ -- ----------------------------------------------------- -- Table WIN_DEVICE -- ----------------------------------------------------- -DROP TABLE IF EXISTS WIN_DEVICE; -CREATE TABLE WIN_DEVICE ( +CREATE TABLE IF NOT EXISTS WIN_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL, PUSH_TOKEN VARCHAR(45) NULL DEFAULT NULL, IMEI VARCHAR(45) NULL DEFAULT NULL, @@ -22,8 +21,7 @@ CREATE TABLE WIN_DEVICE ( -- ----------------------------------------------------- -- Table WIN_FEATURE -- ----------------------------------------------------- -DROP TABLE IF EXISTS WIN_FEATURE; -CREATE TABLE WIN_FEATURE ( +CREATE TABLE IF NOT EXISTS WIN_FEATURE ( ID SERIAL NOT NULL, DEVICE_TYPE VARCHAR(45) NOT NULL, CODE VARCHAR(45) NULL, From b92ceeaf76e8687acb97f872120079c5b076d3d1 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Thu, 29 Oct 2015 15:49:57 +0530 Subject: [PATCH 3/8] Refactored Android postgresql DB script --- .../src/main/resources/dbscripts/plugins/android/postgresql.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql index 2b3057de3..18d67c43d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(500) NULL DEFAULT NULL, + DEVICE_INFO TEXT NULL DEFAULT NULL, GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, IMEI VARCHAR(45) NULL DEFAULT NULL, IMSI VARCHAR(45) NULL DEFAULT NULL, From 84f6ccd7edbe0358de8caf5f0a0e171bedb18354 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 3 Nov 2015 10:28:09 +0530 Subject: [PATCH 4/8] Refactored DB scripts --- .../mgt/mobile/impl/windows/util/WindowsPluginConstants.java | 2 +- .../src/main/resources/dbscripts/plugins/windows/mysql.sql | 1 - .../src/main/resources/dbscripts/plugins/windows/oracle.sql | 1 - .../src/main/resources/dbscripts/plugins/windows/postgresql.sql | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java index e13b4642d..edae380d4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java @@ -39,7 +39,7 @@ public class WindowsPluginConstants { public static final String DEVICE_NAME = "DEVICE_NAME"; //Properties related to WIN_FEATURE table - public static final String WINDOWS_FEATURE_ID = "FEATURE_ID"; + public static final String WINDOWS_FEATURE_ID = "ID"; public static final String WINDOWS_FEATURE_CODE = "CODE"; public static final String WINDOWS_FEATURE_NAME = "NAME"; public static final String WINDOWS_FEATURE_DESCRIPTION = "DESCRIPTION"; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql index 347f1ad2e..a942795b9 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql @@ -24,7 +24,6 @@ ENGINE = InnoDB; -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `WIN_FEATURE` ( `FEATURE_ID` INT NOT NULL AUTO_INCREMENT, - `DEVICE_TYPE` VARCHAR(45) NOT NULL, `CODE` VARCHAR(45) NULL, `NAME` VARCHAR(100) NULL, `DESCRIPTION` VARCHAR(200) NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql index 8a96b7947..7fc3f38d4 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql @@ -24,7 +24,6 @@ CREATE TABLE WIN_DEVICE ( -- ----------------------------------------------------- CREATE TABLE WIN_FEATURE ( ID INT NOT NULL, - DEVICE_TYPE VARCHAR(45) NOT NULL, CODE VARCHAR(45) NOT NULL, NAME VARCHAR(100) NOT NULL, DESCRIPTION VARCHAR(200) NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql index 865f30682..ae9ddb615 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql @@ -23,7 +23,6 @@ CREATE TABLE IF NOT EXISTS WIN_DEVICE ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS WIN_FEATURE ( ID SERIAL NOT NULL, - DEVICE_TYPE VARCHAR(45) NOT NULL, CODE VARCHAR(45) NULL, NAME VARCHAR(100) NULL, DESCRIPTION VARCHAR(200) NULL, From a9a0e029322fd5e6dc7e4443c43341517224caee Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 3 Nov 2015 13:57:22 +0530 Subject: [PATCH 5/8] Refactored oracle DB scripts --- .../dbscripts/plugins/android/oracle.sql | 68 ++++++++++++++++--- .../dbscripts/plugins/ios/oracle.sql | 20 +++--- .../dbscripts/plugins/windows/oracle.sql | 16 +++-- 3 files changed, 79 insertions(+), 25 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql index b8a522b90..08fa92f45 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql @@ -15,8 +15,8 @@ CREATE TABLE AD_DEVICE ( SERIAL VARCHAR(45) DEFAULT NULL, MAC_ADDRESS VARCHAR(45) DEFAULT NULL, DEVICE_NAME VARCHAR(100) DEFAULT NULL, - PRIMARY KEY (DEVICE_ID) -); + CONSTRAINT PK_AD_DEVICE PRIMARY KEY (DEVICE_ID) +) / -- ----------------------------------------------------- @@ -27,23 +27,73 @@ CREATE TABLE AD_FEATURE ( CODE VARCHAR(45) NOT NULL, NAME VARCHAR(100) NOT NULL, DESCRIPTION VARCHAR(200) DEFAULT NULL, - PRIMARY KEY (ID) -); + CONSTRAINT AD_FEATURE PRIMARY KEY (ID) +) / -- ----------------------------------------------------- -- Sequence `AD_FEATURE_ID_INC_SEQ` -- ----------------------------------------------------- -CREATE SEQUENCE AD_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE; +CREATE SEQUENCE AD_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE / - -- ----------------------------------------------------- -- Trigger `AD_FEATURE_ID_INC_TRIG` -- ----------------------------------------------------- CREATE OR REPLACE TRIGGER AD_FEATURE_ID_INC_TRIG -BEFORE INSERT ON AD_FEATURE +BEFORE INSERT +ON AD_FEATURE +REFERENCING NEW AS NEW FOR EACH ROW -BEGIN + BEGIN SELECT AD_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; -END; + END; +/-- ----------------------------------------------------- +-- Table `AD_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE AD_DEVICE ( + DEVICE_ID VARCHAR(45) NOT NULL , + DEVICE_INFO VARCHAR(500) DEFAULT NULL, + GCM_TOKEN VARCHAR(45) DEFAULT NULL, + IMEI VARCHAR(45) DEFAULT NULL, + IMSI VARCHAR(45) DEFAULT NULL, + OS_VERSION VARCHAR(45) DEFAULT NULL, + DEVICE_MODEL VARCHAR(45) DEFAULT NULL, + VENDOR VARCHAR(45) DEFAULT NULL, + LATITUDE VARCHAR(45) DEFAULT NULL, + LONGITUDE VARCHAR(45) DEFAULT NULL, + SERIAL VARCHAR(45) DEFAULT NULL, + MAC_ADDRESS VARCHAR(45) DEFAULT NULL, + DEVICE_NAME VARCHAR(100) DEFAULT NULL, + CONSTRAINT PK_AD_DEVICE PRIMARY KEY (DEVICE_ID) +) +/ + +-- ----------------------------------------------------- +-- Table `AD_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE AD_FEATURE ( + ID INT NOT NULL, + CODE VARCHAR(45) NOT NULL, + NAME VARCHAR(100) NOT NULL, + DESCRIPTION VARCHAR(200) DEFAULT NULL, + CONSTRAINT AD_FEATURE PRIMARY KEY (ID) +) / + +-- ----------------------------------------------------- +-- Sequence `AD_FEATURE_ID_INC_SEQ` +-- ----------------------------------------------------- +CREATE SEQUENCE AD_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +-- ----------------------------------------------------- +-- Trigger `AD_FEATURE_ID_INC_TRIG` +-- ----------------------------------------------------- +CREATE OR REPLACE TRIGGER AD_FEATURE_ID_INC_TRIG +BEFORE INSERT +ON AD_FEATURE +REFERENCING NEW AS NEW +FOR EACH ROW + BEGIN + SELECT AD_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; + END; +/ \ No newline at end of file diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql index 3e129477f..315402e18 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql @@ -1,7 +1,7 @@ -- ----------------------------------------------------- -- Table `IOS_DEVICE` -- ----------------------------------------------------- - CREATE TABLE IOS_DEVICE ( +CREATE TABLE IOS_DEVICE ( MOBILE_DEVICE_ID VARCHAR(45) NOT NULL, APNS_PUSH_TOKEN VARCHAR(100) DEFAULT NULL, MAGIC_TOKEN VARCHAR(100) DEFAULT NULL, @@ -18,8 +18,8 @@ ICCID VARCHAR(45) DEFAULT NULL, LATITUDE VARCHAR(45) DEFAULT NULL, LONGITUDE VARCHAR(45) DEFAULT NULL, - PRIMARY KEY (MOBILE_DEVICE_ID) -); + CONSTRAINT PK_IOS_DEVICE PRIMARY KEY (MOBILE_DEVICE_ID) +) / -- ----------------------------------------------------- @@ -30,8 +30,8 @@ CREATE TABLE IOS_FEATURE ( CODE VARCHAR(45) NOT NULL, NAME VARCHAR(100) NOT NULL, DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) -); + CONSTRAINT PK_IOS_FEATURE PRIMARY KEY (ID) +) / -- Sequence `IOS_FEATURE_ID_INC_SEQ` @@ -43,9 +43,11 @@ CREATE SEQUENCE IOS_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE; -- Trigger `IOS_FEATURE_ID_INC_TRIG` -- ----------------------------------------------------- CREATE OR REPLACE TRIGGER IOS_FEATURE_ID_INC_TRIG -BEFORE INSERT ON IOS_FEATURE +BEFORE INSERT +ON IOS_FEATURE +REFERENCING NEW AS NEW FOR EACH ROW -BEGIN + BEGIN SELECT IOS_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; -END; -/ + END; +/ \ No newline at end of file diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql index 7fc3f38d4..fee14fe86 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql @@ -16,7 +16,7 @@ CREATE TABLE WIN_DEVICE ( UNLOCK_TOKEN VARCHAR(2000) DEFAULT NULL, SERIAL VARCHAR(45) DEFAULT NULL, PRIMARY KEY (DEVICE_ID) -); +) / -- ----------------------------------------------------- @@ -28,22 +28,24 @@ CREATE TABLE WIN_FEATURE ( NAME VARCHAR(100) NOT NULL, DESCRIPTION VARCHAR(200) NULL, PRIMARY KEY (ID) -); +) / -- ----------------------------------------------------- -- Sequence `WIN_FEATURE_ID_INC_SEQ` -- ----------------------------------------------------- -CREATE SEQUENCE WIN_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE; +CREATE SEQUENCE WIN_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE / -- ----------------------------------------------------- -- Trigger `WIN_FEATURE_ID_INC_TRIG` -- ----------------------------------------------------- CREATE OR REPLACE TRIGGER WIN_FEATURE_ID_INC_TRIG -BEFORE INSERT ON WIN_FEATURE +BEFORE INSERT +ON WIN_FEATURE +REFERENCING NEW AS NEW FOR EACH ROW -BEGIN + BEGIN SELECT WIN_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; -END; -/ + END; +/ \ No newline at end of file From db640b7cef0f2cf8a933c5e08ab553970c497753 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 3 Nov 2015 14:00:58 +0530 Subject: [PATCH 6/8] Refactored Android oracle DB script --- .../dbscripts/plugins/android/oracle.sql | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql index 08fa92f45..1a23b7cc4 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql @@ -31,55 +31,6 @@ CREATE TABLE AD_FEATURE ( ) / --- ----------------------------------------------------- --- Sequence `AD_FEATURE_ID_INC_SEQ` --- ----------------------------------------------------- -CREATE SEQUENCE AD_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE -/ --- ----------------------------------------------------- --- Trigger `AD_FEATURE_ID_INC_TRIG` --- ----------------------------------------------------- -CREATE OR REPLACE TRIGGER AD_FEATURE_ID_INC_TRIG -BEFORE INSERT -ON AD_FEATURE -REFERENCING NEW AS NEW -FOR EACH ROW - BEGIN - SELECT AD_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - END; -/-- ----------------------------------------------------- --- Table `AD_DEVICE` --- ----------------------------------------------------- -CREATE TABLE AD_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(500) DEFAULT NULL, - GCM_TOKEN VARCHAR(45) DEFAULT NULL, - IMEI VARCHAR(45) DEFAULT NULL, - IMSI VARCHAR(45) DEFAULT NULL, - OS_VERSION VARCHAR(45) DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) DEFAULT NULL, - VENDOR VARCHAR(45) DEFAULT NULL, - LATITUDE VARCHAR(45) DEFAULT NULL, - LONGITUDE VARCHAR(45) DEFAULT NULL, - SERIAL VARCHAR(45) DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) DEFAULT NULL, - DEVICE_NAME VARCHAR(100) DEFAULT NULL, - CONSTRAINT PK_AD_DEVICE PRIMARY KEY (DEVICE_ID) -) -/ - --- ----------------------------------------------------- --- Table `AD_FEATURE` --- ----------------------------------------------------- -CREATE TABLE AD_FEATURE ( - ID INT NOT NULL, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NOT NULL, - DESCRIPTION VARCHAR(200) DEFAULT NULL, - CONSTRAINT AD_FEATURE PRIMARY KEY (ID) -) -/ - -- ----------------------------------------------------- -- Sequence `AD_FEATURE_ID_INC_SEQ` -- ----------------------------------------------------- From 71e705598eb9e82c25b13eff12271e7253f80c83 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 3 Nov 2015 14:30:28 +0530 Subject: [PATCH 7/8] Deleted Temporary DB script files --- .../dbscripts/plugins/android/postgresql.sql~ | 30 --------------- .../dbscripts/plugins/ios/postgresql.sql~ | 38 ------------------- .../dbscripts/plugins/windows/mysql.sql~ | 38 ------------------- 3 files changed, 106 deletions(-) delete mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ delete mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql~ delete mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql~ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ deleted file mode 100644 index 8c3f0591b..000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql~ +++ /dev/null @@ -1,30 +0,0 @@ --- ----------------------------------------------------- --- Table AD_DEVICE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS AD_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(500) NULL DEFAULT NULL, - GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - IMSI VARCHAR(45) NULL DEFAULT NULL, - OS_VERSION VARCHAR(45) NULL DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, - VENDOR VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (DEVICE_ID) - ); - --- ----------------------------------------------------- --- Table AD_FEATURE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS AD_FEATURE ( - ID INT NOT NULL AUTO_INCREMENT, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) -); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql~ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql~ deleted file mode 100644 index 4fcb2873b..000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql~ +++ /dev/null @@ -1,38 +0,0 @@ --- ----------------------------------------------------- --- Table IOS_FEATURE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS IOS_FEATURE ( - ID SERIAL NOT NULL, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) -); - --- ----------------------------------------------------- --- Table IOS_DEVICE --- ----------------------------------------------------- -<<<<<<< HEAD -CREATE TABLE IF NOT EXISTS IOS_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL, -======= -CREATE TABLE IF NOT EXISTS IOS_DEVICE ( - MOBILE_DEVICE_ID VARCHAR(45) NOT NULL, ->>>>>>> bc22647a04f3297da94eb0e767d722d3b738144c - APNS_PUSH_TOKEN VARCHAR(100) NULL DEFAULT NULL, - MAGIC_TOKEN VARCHAR(100) NULL DEFAULT NULL, - MDM_TOKEN VARCHAR(100) NULL DEFAULT NULL, - UNLOCK_TOKEN VARCHAR(2000) NULL DEFAULT NULL, - CHALLENGE_TOKEN VARCHAR(45) NULL DEFAULT NULL, - DEVICE_INFO VARCHAR(8000) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - PRODUCT VARCHAR(45) NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - VERSION VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - ICCID VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (MOBILE_DEVICE_ID) - ); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql~ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql~ deleted file mode 100644 index a67e3b7e1..000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql~ +++ /dev/null @@ -1,38 +0,0 @@ --- ----------------------------------------------------- --- Table `WIN_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `WIN_DEVICE` ( - `DEVICE_ID` VARCHAR(45) NOT NULL, - `PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL, - `IMEI` VARCHAR(45) NULL DEFAULT NULL, - `IMSI` VARCHAR(45) NULL DEFAULT NULL, - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, - `VENDOR` VARCHAR(45) NULL DEFAULT NULL, - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `CHALLENGE` VARCHAR(45) NULL DEFAULT NULL, - `TOKEN` VARCHAR(50) NULL DEFAULT NULL, - `UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (`DEVICE_ID`)) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `WIN_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `WIN_FEATURE` ( -<<<<<<< HEAD - `FEATURE_ID` INT NOT NULL AUTO_INCREMENT, -======= - `ID` INT NOT NULL AUTO_INCREMENT, ->>>>>>> b33be7d49d6c06bc8f1068bd6600b674bff470a8 - `CODE` VARCHAR(45) NULL, - `NAME` VARCHAR(100) NULL, - `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`ID`)) -ENGINE = InnoDB; - - - From a882cd2fb052b99c8515a5d67f3cc4fe6f20f3f6 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 3 Nov 2015 16:01:10 +0530 Subject: [PATCH 8/8] Refactored Android oracle DB script --- .../src/main/resources/dbscripts/plugins/android/oracle.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql index 1a23b7cc4..7e3007ee6 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(500) DEFAULT NULL, + DEVICE_INFO VARCHAR(1000) DEFAULT NULL, GCM_TOKEN VARCHAR(45) DEFAULT NULL, IMEI VARCHAR(45) DEFAULT NULL, IMSI VARCHAR(45) DEFAULT NULL,