fix: keep one active email OTP per account
Staging Backend Quality Gate / validate (push) Successful in 12m39s
Staging Backend Quality Gate / publish (push) Successful in 12m9s

This commit is contained in:
Jesse_Chen
2026-08-10 10:49:25 +08:00
parent 43d0647de2
commit 8696eca022
3 changed files with 78 additions and 0 deletions
@@ -0,0 +1,18 @@
lock table identity.verifications in share row exclusive mode;
with ranked as (
select
id,
row_number() over (
partition by identifier
order by created_at desc, id desc
) as position
from identity.verifications
)
delete from identity.verifications verification
using ranked
where verification.id = ranked.id
and ranked.position > 1;
create unique index if not exists identity_verifications_identifier_key
on identity.verifications (identifier);