aboutsummaryrefslogtreecommitdiff
path: root/src/backenddb/pg_insert_account.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backenddb/pg_insert_account.c')
-rw-r--r--src/backenddb/pg_insert_account.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backenddb/pg_insert_account.c b/src/backenddb/pg_insert_account.c
index 3b57b0ba..04b0637c 100644
--- a/src/backenddb/pg_insert_account.c
+++ b/src/backenddb/pg_insert_account.c
@@ -51,7 +51,7 @@ TMH_PG_insert_account (
check_connection (pg);
PREPARE (pg,
"insert_account",
- "INSERT INTO merchant_accounts"
+ "INSERT INTO merchant_accounts AS ma"
"(merchant_serial"
",h_wire"
",salt"
@@ -61,7 +61,13 @@ TMH_PG_insert_account (
",active)"
" SELECT merchant_serial, $2, $3, $4, $5, $6, $7"
" FROM merchant_instances"
- " WHERE merchant_id=$1");
+ " WHERE merchant_id=$1"
+ " ON CONFLICT(merchant_serial,payto_uri)"
+ " DO UPDATE SET"
+ " active = true"
+ ",credit_facade_url = EXCLUDED.credit_facade_url"
+ ",credit_facade_credentials = EXCLUDED.credit_facade_credentials"
+ " WHERE NOT ma.active");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_account",
params);