From a390df68eccdb9f683fb198cadaa031e53a32e80 Mon Sep 17 00:00:00 2001 From: pasinduj Date: Tue, 8 Dec 2015 11:42:04 +0530 Subject: [PATCH 1/7] modified dbscripts to remove foriegn key reference --- .../wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java | 4 ++-- .../src/main/resources/dbscripts/cdm/h2.sql | 4 ++-- .../src/main/resources/dbscripts/cdm/mysql.sql | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index f78feca333f..cd886a43689 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -1282,11 +1282,11 @@ public class PolicyDAOImpl implements PolicyDAO { stmt.setInt(1, policyId); stmt.executeUpdate(); - String deleteComplianceStatus ="DELETE FROM DM_POLICY_COMPLIANCE_STATUS WHERE POLICY_ID =?"; + /* String deleteComplianceStatus ="DELETE FROM DM_POLICY_COMPLIANCE_STATUS WHERE POLICY_ID =?"; stmt = conn.prepareStatement(deleteComplianceStatus); stmt.setInt(1, policyId); stmt.executeUpdate(); - + */ if (log.isDebugEnabled()) { log.debug("Policy (" + policyId + ") related configs deleted from database."); } 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 index 2ef6a292204..3c8b0cd88ed 100644 --- 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 @@ -309,9 +309,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, PRIMARY KEY (ID), - CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY + /*CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) + REFERENCES DM_POLICY (ID)*/ ON DELETE NO ACTION ON UPDATE NO ACTION ); 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 index e340450d4cf..32c2e9f7e62 100644 --- 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 @@ -297,9 +297,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, PRIMARY KEY (ID), - CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) + /* CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID)*/ ON DELETE NO ACTION ON UPDATE NO ACTION )ENGINE = InnoDB; From 3154582abecefef935f38dad37bba367ba67cafd Mon Sep 17 00:00:00 2001 From: pasinduj Date: Tue, 8 Dec 2015 13:26:51 +0530 Subject: [PATCH 2/7] remove policy id foriegn key from one table --- .../src/main/resources/dbscripts/cdm/h2.sql | 7 +------ .../src/main/resources/dbscripts/cdm/mysql.sql | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) 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 index 3c8b0cd88ed..87e8b135272 100644 --- 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 @@ -308,12 +308,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_REQUESTED_TIME TIMESTAMP NULL, LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, - PRIMARY KEY (ID), - /*CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID)*/ - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) ); 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 index 32c2e9f7e62..6a9d8eee71c 100644 --- 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 @@ -296,12 +296,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_REQUESTED_TIME TIMESTAMP NULL, LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, - PRIMARY KEY (ID), - /* CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID)*/ - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) )ENGINE = InnoDB; From f49f13501ff44592859def412510a622a9078162 Mon Sep 17 00:00:00 2001 From: pasinduj Date: Tue, 8 Dec 2015 15:35:01 +0530 Subject: [PATCH 3/7] modified dbscripts removing policy ID forigen key from one table --- .../wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java | 5 ----- .../src/main/resources/dbscripts/cdm/mysql.sql | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index cd886a43689..7fd9d04d75b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -1282,11 +1282,6 @@ public class PolicyDAOImpl implements PolicyDAO { stmt.setInt(1, policyId); stmt.executeUpdate(); - /* String deleteComplianceStatus ="DELETE FROM DM_POLICY_COMPLIANCE_STATUS WHERE POLICY_ID =?"; - stmt = conn.prepareStatement(deleteComplianceStatus); - stmt.setInt(1, policyId); - stmt.executeUpdate(); - */ if (log.isDebugEnabled()) { log.debug("Policy (" + policyId + ") related configs deleted from database."); } 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 index 6a9d8eee71c..3433d77867a 100644 --- 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 @@ -303,7 +303,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE_ID INT NOT NULL, + DEVICE_TYPE_ID INT NOT NULL TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) )ENGINE = InnoDB; From 1a7b888102baa243416be4dbbce983bbcd537835 Mon Sep 17 00:00:00 2001 From: pasinduj Date: Tue, 8 Dec 2015 16:13:35 +0530 Subject: [PATCH 4/7] modified dbscript added missing comma --- .../src/main/resources/dbscripts/cdm/mysql.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 3433d77867a..6a9d8eee71c 100644 --- 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 @@ -303,7 +303,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE_ID INT NOT NULL + DEVICE_TYPE_ID INT NOT NULL, TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) )ENGINE = InnoDB; From 6ed2710550f1298225251b2a01eb8131bf682e69 Mon Sep 17 00:00:00 2001 From: pasinduj Date: Wed, 9 Dec 2015 10:15:43 +0530 Subject: [PATCH 5/7] revert mysql edited lines --- .../src/main/resources/dbscripts/cdm/mysql.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 index 6a9d8eee71c..e340450d4cf 100644 --- 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 @@ -296,7 +296,12 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_REQUESTED_TIME TIMESTAMP NULL, LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION )ENGINE = InnoDB; From 4656a9eae7c13759bbefb415866416d94acdd62b Mon Sep 17 00:00:00 2001 From: pasinduj Date: Thu, 10 Dec 2015 11:43:44 +0530 Subject: [PATCH 6/7] modified all dbscripts removing a foriegn key --- .../src/main/resources/dbscripts/cdm/mssql.sql | 7 +------ .../src/main/resources/dbscripts/cdm/mysql.sql | 7 +------ .../src/main/resources/dbscripts/cdm/oracle.sql | 5 +---- .../src/main/resources/dbscripts/cdm/postgresql.sql | 7 +------ 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql index fc5639649fe..b2f954f69e9 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -311,12 +311,7 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( LAST_REQUESTED_TIME DATETIME2(0) NULL, LAST_FAILED_TIME DATETIME2(0) NULL, ATTEMPTS INT NULL, - PRIMARY KEY (ID), - CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) ); 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 index 2132a66d0ed..2c0fa846246 100644 --- 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 @@ -302,12 +302,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_REQUESTED_TIME TIMESTAMP NULL, LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, - PRIMARY KEY (ID), - CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) )ENGINE = InnoDB; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index dd6fa2c6217..ffe05d4acdf 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -503,10 +503,7 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( LAST_REQUESTED_TIME TIMESTAMP(0) NULL, LAST_FAILED_TIME TIMESTAMP(0) NULL, ATTEMPTS NUMBER(10) NULL, - CONSTRAINT PK_DM_POLICY_COMP_STATUS PRIMARY KEY (ID), - CONSTRAINT FK_POLICY_COMP_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) + CONSTRAINT PK_DM_POLICY_COMP_STATUS PRIMARY KEY (ID) ) / -- Generate ID using sequence and trigger diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql index f04cb691b7d..84ecfcf7b1b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -267,12 +267,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_SUCCESS_TIME TIMESTAMP NULL, LAST_REQUESTED_TIME TIMESTAMP NULL, LAST_FAILED_TIME TIMESTAMP NULL, - ATTEMPTS INTEGER NULL, - CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + ATTEMPTS INTEGER NULL ); CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( From bb010bde285b9d797627ca10f500b56efe2dc0dd Mon Sep 17 00:00:00 2001 From: pasinduj Date: Thu, 10 Dec 2015 16:59:03 +0530 Subject: [PATCH 7/7] modified oracle db script to remove a foriegn key --- .../src/main/resources/dbscripts/cdm/oracle.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index ffe05d4acdf..ef4d6de4006 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -397,10 +397,7 @@ CREATE TABLE DM_DEVICE_POLICY_APPLIED ( CONSTRAINT PK_DM_POLICY_DEV_APPLIED PRIMARY KEY (ID) , CONSTRAINT FK_DM_POLICY_DEV_APPLIED FOREIGN KEY (DEVICE_ID ) - REFERENCES DM_DEVICE (ID ), - CONSTRAINT FK_DM_POLICY_DEV_APPLY_POLICY - FOREIGN KEY (POLICY_ID ) - REFERENCES DM_POLICY (ID ) + REFERENCES DM_DEVICE (ID ) ) / -- Generate ID using sequence and trigger