From 7334cfc40995c98aa550fedc7b249d9c08100028 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 2 Jan 2021 20:40:11 +0100 Subject: fix DB initialization logic to avoid CREATE table attempts in taler-merchant-httpd --- src/merchant-tools/taler-merchant-dbinit.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/merchant-tools/taler-merchant-dbinit.c') diff --git a/src/merchant-tools/taler-merchant-dbinit.c b/src/merchant-tools/taler-merchant-dbinit.c index 938f7d30..73ec3519 100644 --- a/src/merchant-tools/taler-merchant-dbinit.c +++ b/src/merchant-tools/taler-merchant-dbinit.c @@ -54,8 +54,7 @@ run (void *cls, cfg = GNUNET_CONFIGURATION_dup (config); if (NULL == - (plugin = TALER_MERCHANTDB_plugin_load (cfg, - reset_db))) + (plugin = TALER_MERCHANTDB_plugin_load (cfg))) { fprintf (stderr, "Failed to initialize database plugin.\n"); @@ -63,6 +62,22 @@ run (void *cls, GNUNET_CONFIGURATION_destroy (cfg); return; } + if (reset_db) + { + if (GNUNET_OK != + plugin->drop_tables (plugin->cls)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failed to reset the database\n"); + } + } + if (GNUNET_OK != + plugin->create_tables (plugin->cls)) + { + global_ret = 1; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to initialize tables\n"); + } TALER_MERCHANTDB_plugin_unload (plugin); GNUNET_CONFIGURATION_destroy (cfg); } -- cgit v1.2.3