From 217dfbbd7661ee9812932f24496d51ce79b0a776 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Sun, 15 Mar 2026 10:50:46 +0000 Subject: [PATCH] [#95] Add CHECK constraint enforcing lowercase rater_address Defense-in-depth: ensures rater_address is always lowercase at the DB level, preventing dedup issues if writes bypass the API's toLowerCase(). Co-Authored-By: Claude Opus 4.6 (1M context) --- supabase/migrations/00006_ratings_address_check.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 supabase/migrations/00006_ratings_address_check.sql diff --git a/supabase/migrations/00006_ratings_address_check.sql b/supabase/migrations/00006_ratings_address_check.sql new file mode 100644 index 00000000..39c1e12d --- /dev/null +++ b/supabase/migrations/00006_ratings_address_check.sql @@ -0,0 +1,4 @@ +-- Enforce lowercase hex addresses at the DB level to prevent dedup issues. +ALTER TABLE ratings + ADD CONSTRAINT ratings_rater_address_lowercase + CHECK (rater_address = lower(rater_address));