From 13abbdcd412dcf87658bb85fcd3efd92284ddec8 Mon Sep 17 00:00:00 2001 From: njorocs Date: Thu, 12 Sep 2024 07:47:52 +0300 Subject: [PATCH] Disabling foreign key checks to allow dropping of etl databases and re-enabling them back --- omod/src/main/resources/sql/DDL.sql | 2 ++ omod/src/main/resources/sql/dwapi/DDL.sql | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/omod/src/main/resources/sql/DDL.sql b/omod/src/main/resources/sql/DDL.sql index e69a789c..559a7bc7 100644 --- a/omod/src/main/resources/sql/DDL.sql +++ b/omod/src/main/resources/sql/DDL.sql @@ -4,7 +4,9 @@ BEGIN DECLARE script_id INT(11); -- create/recreate database kenyaemr_etl +SET FOREIGN_KEY_CHECKS = 0; drop database if exists kenyaemr_etl; +SET FOREIGN_KEY_CHECKS = 1; create database kenyaemr_etl DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; drop database if exists kenyaemr_datatools; diff --git a/omod/src/main/resources/sql/dwapi/DDL.sql b/omod/src/main/resources/sql/dwapi/DDL.sql index d1a11991..99d2e944 100644 --- a/omod/src/main/resources/sql/dwapi/DDL.sql +++ b/omod/src/main/resources/sql/dwapi/DDL.sql @@ -4,11 +4,11 @@ BEGIN DECLARE script_id INT(11); -- create/recreate database dwapi_etl +SET FOREIGN_KEY_CHECKS = 0; drop database if exists dwapi_etl; +SET FOREIGN_KEY_CHECKS = 1; create database dwapi_etl DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; - - -- Log start time INSERT INTO kenyaemr_etl.etl_script_status(script_name, start_time) VALUES('initial_creation_of_dwapi_tables', NOW()); SET script_id = LAST_INSERT_ID();