summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-18 16:26:33 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-18 16:26:33 +0100
commit9a86e1f1e10338bf869944b2fb215a53aa1fcc54 (patch)
treecdba1d99a1186e1c720811c775a14dd6a1315f6c /src/backenddb
parent6ee72ea210a93327ee36fa360e5264c393ffa224 (diff)
downloadmerchant-9a86e1f1e10338bf869944b2fb215a53aa1fcc54.tar.gz
merchant-9a86e1f1e10338bf869944b2fb215a53aa1fcc54.tar.bz2
merchant-9a86e1f1e10338bf869944b2fb215a53aa1fcc54.zip
add minimum age to products
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/merchant-0003.sql7
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c16
2 files changed, 19 insertions, 4 deletions
diff --git a/src/backenddb/merchant-0003.sql b/src/backenddb/merchant-0003.sql
index 80860d23..370af625 100644
--- a/src/backenddb/merchant-0003.sql
+++ b/src/backenddb/merchant-0003.sql
@@ -54,5 +54,12 @@ COMMENT ON COLUMN merchant_kyc.exchange_url
IS 'Which exchange base URL is this KYC status valid for';
+-- add age restriction column to product
+ALTER TABLE merchant_inventory
+ ADD COLUMN minimum_age INT4 NOT NULL DEFAULT 0;
+COMMENT ON COLUMN merchant_inventory.minimum_age
+ IS 'Minimum age of the customer in years, to be used if an exchange supports the age restriction extension.';
+
+
-- Complete transaction
COMMIT;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 5465b4e8..7aad3c7c 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1364,6 +1364,8 @@ postgres_lookup_product (void *cls,
&pd->address),
GNUNET_PQ_result_spec_timestamp ("next_restock",
&pd->next_restock),
+ GNUNET_PQ_result_spec_uint32 ("minimum_age",
+ &pd->minimum_age),
GNUNET_PQ_result_spec_end
};
@@ -1433,6 +1435,7 @@ postgres_insert_product (void *cls,
GNUNET_PQ_query_param_uint64 (&pd->total_stock),
TALER_PQ_query_param_json (pd->address),
GNUNET_PQ_query_param_timestamp (&pd->next_restock),
+ GNUNET_PQ_query_param_uint32 (&pd->minimum_age),
GNUNET_PQ_query_param_end
};
@@ -1482,6 +1485,7 @@ postgres_update_product (void *cls,
GNUNET_PQ_query_param_uint64 (&pd->total_lost),
TALER_PQ_query_param_json (pd->address),
GNUNET_PQ_query_param_timestamp (&pd->next_restock),
+ GNUNET_PQ_query_param_uint32 (&pd->minimum_age),
GNUNET_PQ_query_param_end
};
@@ -6993,6 +6997,7 @@ postgres_connect (void *cls)
",image"
",merchant_inventory.address"
",next_restock"
+ ",minimum_age"
" FROM merchant_inventory"
" JOIN merchant_instances"
" USING (merchant_serial)"
@@ -7027,12 +7032,14 @@ postgres_connect (void *cls)
",price_frac"
",total_stock"
",address"
- ",next_restock)"
+ ",next_restock"
+ ",minimum_age"
+ ")"
" SELECT merchant_serial,"
- " $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12"
+ " $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13"
" FROM merchant_instances"
" WHERE merchant_id=$1",
- 12),
+ 13),
/* for postgres_update_product() */
GNUNET_PQ_make_prepare ("update_product",
"UPDATE merchant_inventory SET"
@@ -7047,6 +7054,7 @@ postgres_connect (void *cls)
",total_lost=$11"
",address=$12"
",next_restock=$13"
+ ",minimum_age=$14"
" WHERE merchant_serial="
" (SELECT merchant_serial"
" FROM merchant_instances"
@@ -7054,7 +7062,7 @@ postgres_connect (void *cls)
" AND product_id=$2"
" AND total_stock <= $10"
" AND total_lost <= $11",
- 13),
+ 14),
/* for postgres_lock_product() */
GNUNET_PQ_make_prepare ("lock_product",