create_tables.c (2172B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2024 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file src/donaudb/create_tables.c 18 * @brief Implementation of the create_tables function for Postgres 19 * @author Johannes Casaburi 20 */ 21 #include <donau_config.h> 22 #include <taler/taler_error_codes.h> 23 #include <taler/taler_dbevents.h> 24 #include <taler/taler_pq_lib.h> 25 #include "create_tables.h" 26 #include "helper.h" 27 28 29 enum GNUNET_GenericReturnValue 30 DONAUDB_create_tables (struct DONAUDB_PostgresContext *ctx) 31 { 32 struct GNUNET_PQ_QueryParam params[] = { 33 GNUNET_PQ_query_param_end 34 }; 35 36 if (GNUNET_SYSERR == 37 GNUNET_PQ_load_versioning (ctx->conn)) 38 { 39 GNUNET_break (0); 40 return GNUNET_SYSERR; 41 } 42 if (GNUNET_OK != 43 GNUNET_PQ_run_sql (ctx->conn, 44 "donau-")) 45 { 46 GNUNET_break (0); 47 return GNUNET_SYSERR; 48 } 49 if (GNUNET_OK != 50 GNUNET_PQ_exec_sql (ctx->conn, 51 "procedures")) 52 { 53 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 54 "Failed to load stored procedures\n"); 55 return GNUNET_SYSERR; 56 } 57 if (GNUNET_OK != 58 GNUNET_PQ_prepare_anon (ctx->conn, 59 "CALL donau.do_create_tables();")) 60 { 61 GNUNET_break (0); 62 return GNUNET_SYSERR; 63 } 64 if (0 > 65 GNUNET_PQ_eval_prepared_non_select (ctx->conn, 66 "", 67 params)) 68 { 69 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 70 "Failed to create tables\n"); 71 return GNUNET_SYSERR; 72 } 73 return GNUNET_OK; 74 }