sync

Backup service to store encrypted wallet databases (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit a79a561cc4696ff166d77e74aa33ca8b3269e0a0
parent c402b024d864abc9d918cb1eb2ae3886963bcc8c
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Tue, 17 Jan 2023 10:59:04 +0100

use sync schema

Diffstat:
Msrc/syncdb/drop.sql | 13++-----------
Msrc/syncdb/plugin_syncdb_postgres.c | 14+++++++++++---
Msrc/syncdb/sync-0001.sql | 5+++++
3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/syncdb/drop.sql b/src/syncdb/drop.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2021 Taler Systems SA +-- Copyright (C) 2021, 2022 Taler Systems SA -- -- TALER 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,18 +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 payments CASCADE; -DROP TABLE IF EXISTS backups CASCADE; -DROP TABLE IF EXISTS accounts CASCADE; - -- Unregister patch (0001.sql) SELECT _v.unregister_patch('sync-0001'); +DROP SCHEMA sync CASCADE; -- And we're out of here... COMMIT; diff --git a/src/syncdb/plugin_syncdb_postgres.c b/src/syncdb/plugin_syncdb_postgres.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014--2021 Taler Systems SA + (C) 2014--2022 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -259,10 +259,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 sync;"), 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 sync;"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; #endif struct GNUNET_PQ_Context *db_conn; @@ -1258,11 +1262,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 sync;"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; conn = GNUNET_PQ_connect_with_cfg (pc->cfg, "syncdb-postgres", "sync-", - NULL, + es, NULL); if (NULL == conn) return GNUNET_SYSERR; diff --git a/src/syncdb/sync-0001.sql b/src/syncdb/sync-0001.sql @@ -20,6 +20,11 @@ BEGIN; -- Check patch versioning is in place. SELECT _v.register_patch('sync-0001', NULL, NULL); +CREATE SCHEMA sync; +COMMENT ON SCHEMA sync IS 'sync data'; + +SET search_path TO sync; + CREATE TABLE IF NOT EXISTS accounts (account_pub BYTEA PRIMARY KEY CHECK (length(account_pub)=32) ,expiration_date INT8 NOT NULL);