From 1fabb0eee328acfd5497bda8a0bafef80dba424f Mon Sep 17 00:00:00 2001 From: geethkokila Date: Tue, 7 Jun 2016 12:55:15 +0530 Subject: [PATCH] Fixing the database syncing issue --- .../src/test/resources/sql/CreateH2TestDB.sql | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index 7d6159a87f0..fe3d2de0426 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, CERTIFICATE BLOB DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + USERNAME VARCHAR(500) DEFAULT NULL, PRIMARY KEY (ID) ); @@ -31,6 +32,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( NAME VARCHAR(100) DEFAULT NULL, DEVICE_TYPE_ID INT(11) DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) @@ -111,6 +113,8 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ENROLMENT_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL, STATUS VARCHAR(50) NULL, + CREATED_TIMESTAMP INT NOT NULL, + UPDATED_TIMESTAMP INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device_operation_mapping_device FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -123,6 +127,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE ( ENROLMENT_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL, OPERATION_RESPONSE BLOB DEFAULT NULL, + RECEIVED_TIMESTAMP TIMESTAMP NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device_operation_response_enrollment FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -502,17 +507,20 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY - FOREIGN KEY (POLICY_ID , DEVICE_GROUP_ID) - REFERENCES DM_POLICY (ID , ID) + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- END OF POLICY AND DEVICE GROUP MAPPING -- -CREATE VIEW DEVICES_VIEW_1 AS +-- DASHBOARD RELATED VIEWS -- + +CREATE VIEW POLICY_COMPLIANCE_INFO AS SELECT DEVICE_INFO.DEVICE_ID, +DEVICE_INFO.DEVICE_IDENTIFICATION, DEVICE_INFO.PLATFORM, DEVICE_INFO.OWNERSHIP, DEVICE_INFO.CONNECTIVITY_STATUS, @@ -522,10 +530,11 @@ DEVICE_INFO.TENANT_ID FROM (SELECT DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, DM_DEVICE_TYPE.NAME AS PLATFORM, -DM_ENROLMENT.OWNERSHIP AS OWNERSHIP, +DM_ENROLMENT.OWNERSHIP, DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, -DM_DEVICE.TENANT_ID AS TENANT_ID +DM_DEVICE.TENANT_ID FROM DM_DEVICE, DM_DEVICE_TYPE, DM_ENROLMENT WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID) DEVICE_INFO LEFT JOIN @@ -533,7 +542,33 @@ LEFT JOIN DEVICE_ID, POLICY_ID, STATUS AS IS_COMPLIANT -FROM -DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO +FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID ORDER BY DEVICE_INFO.DEVICE_ID; + +CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS +SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, +DM_DEVICE_DETAIL.DEVICE_MODEL, +DM_DEVICE_DETAIL.VENDOR, +DM_DEVICE_DETAIL.OS_VERSION, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.OWNER, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_POLICY_COMPLIANCE_STATUS.POLICY_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_POLICY_COMPLIANCE_FEATURES.FEATURE_CODE, +DM_POLICY_COMPLIANCE_FEATURES.STATUS AS IS_COMPLAINT, +DM_DEVICE.TENANT_ID +FROM +DM_POLICY_COMPLIANCE_FEATURES, DM_POLICY_COMPLIANCE_STATUS, DM_ENROLMENT, DM_DEVICE, DM_DEVICE_TYPE, DM_DEVICE_DETAIL +WHERE +DM_POLICY_COMPLIANCE_FEATURES.COMPLIANCE_STATUS_ID = DM_POLICY_COMPLIANCE_STATUS.ID AND +DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = DM_ENROLMENT.ID AND +DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND +DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND +DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID +ORDER BY TENANT_ID, DEVICE_ID; + +-- END OF DASHBOARD RELATED VIEWS --