fix(backend): address gift card review findings

Fix #1: remove expiry_date from gift card INSERTs (rolling 24-month via last_used_at only)

Fix #2: add FOR UPDATE to RedeemGiftCard SELECT (race condition)

Fix #6: add ?type=customer|inventory filter to GetGiftCards

Fix #7: add admin_audit_log INSERT to GetUserGiftCardBalanceAdmin

Fix #10: refactor normalizeCode to validators.NormalizeGiftCardCode

Schema: add admin_audit_log table (GDPR Article 30), update testdb.go

Tests: expiry-date-null, inventory-filter, audit-log, db table references

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-06-12 10:50:49 +01:00
co-authored by Sisyphus
parent e7fd9c89eb
commit 3c447a5c33
6 changed files with 399 additions and 154 deletions
+2
View File
@@ -103,6 +103,7 @@ func Migrate(t *testing.T, pool *pgxpool.Pool) {
// Drop all tables, sequences, and views in correct order
dropOrder := []string{
"till_sales",
"admin_audit_log",
"gift_card_transactions",
"gift_card_expired_balances",
"booking_discounts",
@@ -272,6 +273,7 @@ func TruncateTables(t *testing.T, pool *pgxpool.Pool) {
tables := []string{
"till_sales",
"admin_audit_log",
"gift_card_transactions",
"gift_card_expired_balances",
"booking_discounts",