diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-01-02 20:40:11 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-01-02 20:40:11 +0100 |
commit | 7334cfc40995c98aa550fedc7b249d9c08100028 (patch) | |
tree | 27ee7cc6ed6fe18615fff32f67b3839de84c7805 /src/merchant-tools | |
parent | feb6c3c694f6f083d7b8d09a35f2074d5c3d44f4 (diff) |
fix DB initialization logic to avoid CREATE table attempts in taler-merchant-httpd
Diffstat (limited to 'src/merchant-tools')
-rw-r--r-- | src/merchant-tools/taler-merchant-dbinit.c | 19 |
1 files changed, 17 insertions, 2 deletions
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); } |