From b9b2c97841e2e8ca8875c6cccaa54b6c8de155bd Mon Sep 17 00:00:00 2001 From: nishan Date: Wed, 18 Oct 2023 07:08:39 +0530 Subject: [PATCH] Added query for set foreign key --- .../src/test/resources/sql/h2.sql | 4 +++- .../src/main/resources/dbscripts/cdm/h2.sql | 5 ++++- .../src/main/resources/dbscripts/cdm/mssql.sql | 4 +++- .../src/main/resources/dbscripts/cdm/mysql.sql | 4 +++- .../src/main/resources/dbscripts/cdm/oracle.sql | 4 +++- .../src/main/resources/dbscripts/cdm/postgresql.sql | 4 +++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql index 0fb769e406..952fe1a099 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql @@ -39,5 +39,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ON DELETE NO ACTION ON UPDATE NO ACTION ); \ No newline at end of file diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index b1f68e0570..0547f9ca79 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -15,7 +15,10 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) + ); CREATE TABLE IF NOT EXISTS DM_GROUP ( diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 7090ca20ff..a00068c5f9 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -25,7 +25,9 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, -PRIMARY KEY (ID) +PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ); IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DEVICE_TYPE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_TYPE')) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 5e33d6b2b4..8107b71583 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -19,7 +19,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) )ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS DM_GROUP ( diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 035f31d31d..043663a706 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -30,7 +30,9 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID NUMBER(10) DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR2(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ) / diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 1b9393885c..3bad8667e2 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -843,6 +843,8 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID NUMBER(10) DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR2(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) )