From d5d8c276d4d9308a67102c7d286116214821d07a Mon Sep 17 00:00:00 2001 From: Toby Hede Date: Tue, 8 Jul 2025 17:21:20 +1000 Subject: [PATCH] fix: drop eql schema on install --- src/schema.sql | 3 ++- tasks/test.sh | 10 +--------- tasks/uninstall.sql | 8 +++++--- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/schema.sql b/src/schema.sql index 3fc1284..dd9386a 100644 --- a/src/schema.sql +++ b/src/schema.sql @@ -1 +1,2 @@ -CREATE SCHEMA IF NOT EXISTS eql_v2; +DROP SCHEMA IF EXISTS eql_v2 CASCADE; +CREATE SCHEMA eql_v2; diff --git a/tasks/test.sh b/tasks/test.sh index 1db94ac..0611e5a 100755 --- a/tasks/test.sh +++ b/tasks/test.sh @@ -46,21 +46,13 @@ echo # Install cat release/cipherstash-encrypt.sql | docker exec -i ${container_name} psql ${connection_url} -f- -# if cat release/cipherstash-encrypt.sql | docker exec -i ${container_name} psql ${connection_url} -f- | grep -q "ERROR"; then -# echo -# echo '******************************************************' -# echo '* ❌ ERROR installing release/cipherstash-encrypt.sql' -# echo '******************************************************' -# echo - -# exit 1 -# fi cat tests/test_helpers.sql | docker exec -i ${container_name} psql ${connection_url} -f- cat tests/ore.sql | docker exec -i ${container_name} psql ${connection_url} -f- cat tests/ste_vec.sql | docker exec -i ${container_name} psql ${connection_url} -f- + if [ $usage_test = "false" ]; then find src -type f -path "*_test.sql" | while read -r sql_file; do echo $sql_file diff --git a/tasks/uninstall.sql b/tasks/uninstall.sql index 2ab226e..d777787 100644 --- a/tasks/uninstall.sql +++ b/tasks/uninstall.sql @@ -1,10 +1,12 @@ DO $$ BEGIN - EXECUTE format('ALTER TABLE IF EXISTS %I RENAME TO %I_%s', 'eql_v2_configuration','eql_v2_configuration_', to_char(current_date,'YYYYMMDD')::TEXT); + ALTER TABLE IF EXISTS public.eql_v2_configuration DROP CONSTRAINT IF EXISTS eql_v2_configuration_data_check; + + EXECUTE format('ALTER TABLE IF EXISTS %I RENAME TO %I_%s', 'eql_v2_configuration','eql_v2_configuration_', to_char(current_date,'YYYYMMDD')::TEXT); + + RAISE NOTICE 'EQL configuration archived as %_%','eql_v2_configuration_', to_char(current_date,'YYYYMMDD')::TEXT; END $$; -ALTER TABLE public.eql_v2_configuration DROP CONSTRAINT IF EXISTS eql_v2_configuration_data_check; - DROP SCHEMA IF EXISTS eql_v2 CASCADE;