From e600627f78c0aff2a55aa6d50ddec407fe7cd9a1 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Thu, 29 Oct 2015 10:17:32 +0530 Subject: [PATCH] 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,