From 30038527ba1bb55060ca2f3c9ffcbc862b682baa Mon Sep 17 00:00:00 2001 From: Cedric CAFFY <cedric.caffy@cern.ch> Date: Thu, 5 Mar 2020 13:46:49 +0100 Subject: [PATCH] Added database purge in the init.sh script of the init pod --- .../cc7/config/init/purge_database.ext | 55 +++++++++++++++++++ .../ctafrontend/cc7/opt/run/bin/init.sh | 1 + 2 files changed, 56 insertions(+) create mode 100644 continuousintegration/docker/ctafrontend/cc7/config/init/purge_database.ext diff --git a/continuousintegration/docker/ctafrontend/cc7/config/init/purge_database.ext b/continuousintegration/docker/ctafrontend/cc7/config/init/purge_database.ext new file mode 100644 index 0000000000..50ce0780aa --- /dev/null +++ b/continuousintegration/docker/ctafrontend/cc7/config/init/purge_database.ext @@ -0,0 +1,55 @@ +set LINESIZE 1000 +set pages 1000 +set serveroutput on size 30000; + +BEGIN + FOR cur_rec IN (SELECT object_name, object_type + FROM user_objects + WHERE object_type IN + ('TABLE', + 'VIEW', + 'MATERIALIZED VIEW', + 'PACKAGE', + 'PROCEDURE', + 'FUNCTION', + 'SEQUENCE', + 'SYNONYM', + 'PACKAGE BODY' + )) + LOOP + BEGIN + IF cur_rec.object_type = 'TABLE' + THEN + EXECUTE IMMEDIATE 'DROP ' + || cur_rec.object_type + || ' "' + || cur_rec.object_name + || '" CASCADE CONSTRAINTS'; + ELSE + EXECUTE IMMEDIATE 'DROP ' + || cur_rec.object_type + || ' "' + || cur_rec.object_name + || '"'; + END IF; + DBMS_OUTPUT.put_line ('WARNING: remaining ' + || cur_rec.object_type + || ' "' + || cur_rec.object_name + || '" just dropped' + ); + EXCEPTION + WHEN OTHERS + THEN + DBMS_OUTPUT.put_line ('FAILED: DROP ' + || cur_rec.object_type + || ' "' + || cur_rec.object_name + || '"' + ); + END; + END LOOP; +END; +/ + +quit; \ No newline at end of file diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh index c7497f1bdb..b09d126c46 100755 --- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh +++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh @@ -67,6 +67,7 @@ if [ "$KEEP_DATABASE" == "0" ]; then echo "Purging Oracle recycle bin" test -f ${ORACLE_SQLPLUS} || echo "ERROR: ORACLE SQLPLUS client is not present, cannot purge recycle bin: ${ORACLE_SQLPLUS}" LD_LIBRARY_PATH=$(readlink ${ORACLE_SQLPLUS} | sed -e 's;/bin/[^/]\+;/lib;') ${ORACLE_SQLPLUS} $(echo $DATABASEURL | sed -e 's/oracle://') @/opt/ci/init/purge_recyclebin.ext + LD_LIBRARY_PATH=$(readlink ${ORACLE_SQLPLUS} | sed -e 's;/bin/[^/]\+;/lib;') ${ORACLE_SQLPLUS} $(echo $DATABASEURL | sed -e 's/oracle://') @/opt/ci/init/purge_database.ext cta-catalogue-schema-create /etc/cta/cta-catalogue.conf || die "ERROR: Could not create database schema. cta-catalogue-schema-create /etc/cta/cta-catalogue.conf FAILED" elif [ "$DATABASETYPE" == "postgres" ]; then cta-catalogue-schema-create /etc/cta/cta-catalogue.conf || die "ERROR: Could not create database schema. cta-catalogue-schema-create /etc/cta/cta-catalogue.conf FAILED" -- GitLab