From b5d7276460eccf6b05daba9ab77743819ed22859 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 26 Jul 2022 00:52:33 +0200 Subject: move anastasis DB into schema anastasis --- src/stasis/drop.sql | 17 ++--------------- src/stasis/plugin_anastasis_postgres.c | 12 ++++++++++-- src/stasis/stasis-0001.sql | 5 +++++ 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/stasis/drop.sql b/src/stasis/drop.sql index c7697c0..67aa4a1 100644 --- a/src/stasis/drop.sql +++ b/src/stasis/drop.sql @@ -1,6 +1,6 @@ -- -- This file is part of ANASTASIS --- Copyright (C) 2014--2020 Anastasis Systems SA +-- Copyright (C) 2014--2022 Anastasis Systems SA -- -- ANASTASIS is free software; you can redistribute it and/or modify it under the -- terms of the GNU General Public License as published by the Free Software @@ -17,22 +17,9 @@ -- Everything in one big transaction BEGIN; --- This script DROPs all of the tables we create. --- --- Unlike the other SQL files, it SHOULD be updated to reflect the --- latest requirements for dropping tables. - --- Drops for 0001.sql -DROP TABLE IF EXISTS anastasis_truth CASCADE; -DROP TABLE IF EXISTS anastasis_user CASCADE; -DROP TABLE IF EXISTS anastasis_recdoc_payment; -DROP TABLE IF EXISTS anastasis_recoverydocument; -DROP TABLE IF EXISTS anastasis_challengecode; -DROP TABLE IF EXISTS anastasis_challenge_payment; -DROP TABLE IF EXISTS anastasis_auth_iban_in; - -- Unregister patch (0001.sql) SELECT _v.unregister_patch('stasis-0001'); +DROP SCHEMA anastasis CASCADE; -- And we're out of here... COMMIT; diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c index 7ba6b73..566b81a 100644 --- a/src/stasis/plugin_anastasis_postgres.c +++ b/src/stasis/plugin_anastasis_postgres.c @@ -110,11 +110,15 @@ postgres_create_tables (void *cls) { struct PostgresClosure *pc = cls; struct GNUNET_PQ_Context *conn; + struct GNUNET_PQ_ExecuteStatement es[] = { + GNUNET_PQ_make_execute ("SET search_path TO anastasis;"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; conn = GNUNET_PQ_connect_with_cfg (pc->cfg, "stasis-postgres", "stasis-", - NULL, + es, NULL); if (NULL == conn) return GNUNET_SYSERR; @@ -562,10 +566,14 @@ internal_setup (struct PostgresClosure *pg, "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), + GNUNET_PQ_make_execute ("SET search_path TO anastasis;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; #else - struct GNUNET_PQ_ExecuteStatement *es = NULL; + struct GNUNET_PQ_ExecuteStatement es[] = { + GNUNET_PQ_make_execute ("SET search_path TO anastasis;"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; #endif struct GNUNET_PQ_Context *db_conn; diff --git a/src/stasis/stasis-0001.sql b/src/stasis/stasis-0001.sql index fe0ab63..cca8245 100644 --- a/src/stasis/stasis-0001.sql +++ b/src/stasis/stasis-0001.sql @@ -20,6 +20,11 @@ BEGIN; -- Check patch versioning is in place. SELECT _v.register_patch('stasis-0001', NULL, NULL); +CREATE SCHEMA anastasis; +COMMENT ON SCHEMA anastasis IS 'anastasis backend data'; + +SET search_path TO anastasis; + CREATE TABLE IF NOT EXISTS anastasis_truth_payment (truth_uuid BYTEA PRIMARY KEY CHECK(LENGTH(truth_uuid)=32), -- cgit v1.2.3