merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit d680ec4d9bdfd434ee4a95d2c71b9c19d5aa123c
parent b4e235730522c1109e4b2291918b874bee1a6c5f
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 14 Jun 2026 01:31:43 +0200

re-add check to refuse to start if schema is not current

Diffstat:
Msrc/backenddb/pg.c | 42+++++++++++++++++++++++++++++++++++++++---
Msrc/include/merchantdb_lib.h | 14+++++++++++++-
Msrc/merchant-tools/taler-merchant-dbinit.c | 2+-
3 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/src/backenddb/pg.c b/src/backenddb/pg.c @@ -63,9 +63,17 @@ reconnect_cb (struct TALER_MERCHANTDB_PostgresContext *pg, } -struct TALER_MERCHANTDB_PostgresContext * -TALER_MERCHANTDB_connect ( - const struct GNUNET_CONFIGURATION_Handle *cfg) +/** + * Initialize the database connection. + * + * @param cfg configuration to use + * @param check_current true to check if the database schema is current + * @return NULL on failure + */ +static struct TALER_MERCHANTDB_PostgresContext * +do_connect ( + const struct GNUNET_CONFIGURATION_Handle *cfg, + bool check_current) { struct TALER_MERCHANTDB_PostgresContext *pg; @@ -80,10 +88,38 @@ TALER_MERCHANTDB_connect ( TALER_MERCHANTDB_disconnect (pg); return NULL; } + if (check_current && + (GNUNET_OK != + GNUNET_PQ_check_current (pg->conn, + "merchant-")) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Database schema is not up-to-date. Try running taler-merchant-dbinit or taler-merchant-dbconfig!\n"); + TALER_MERCHANTDB_disconnect (pg); + return NULL; + } return pg; } +struct TALER_MERCHANTDB_PostgresContext * +TALER_MERCHANTDB_connect ( + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + return do_connect (cfg, + true); +} + + +struct TALER_MERCHANTDB_PostgresContext * +TALER_MERCHANTDB_connect_admin ( + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + return do_connect (cfg, + false); +} + + void TALER_MERCHANTDB_disconnect ( struct TALER_MERCHANTDB_PostgresContext *pg) diff --git a/src/include/merchantdb_lib.h b/src/include/merchantdb_lib.h @@ -87,7 +87,19 @@ GNUNET_NETWORK_STRUCT_END * @return connection to the database; NULL upon error */ struct TALER_MERCHANTDB_PostgresContext * -TALER_MERCHANTDB_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); +TALER_MERCHANTDB_connect ( + const struct GNUNET_CONFIGURATION_Handle *cfg); + +/** + * Connect to postgresql database for administration. + * Disables the check that the database schema is current. + * + * @param cfg the configuration handle + * @return connection to the database; NULL upon error + */ +struct TALER_MERCHANTDB_PostgresContext * +TALER_MERCHANTDB_connect_admin ( + const struct GNUNET_CONFIGURATION_Handle *cfg); /** diff --git a/src/merchant-tools/taler-merchant-dbinit.c b/src/merchant-tools/taler-merchant-dbinit.c @@ -60,7 +60,7 @@ run (void *cls, { struct TALER_MERCHANTDB_PostgresContext *pg; - pg = TALER_MERCHANTDB_connect (cfg); + pg = TALER_MERCHANTDB_connect_admin (cfg); if (NULL == pg) { fprintf (stderr,