MySQL · 645 bytes Raw Blame History
1 -- SPDX-License-Identifier: AGPL-3.0-or-later
2
3 -- name: CreateEmailVerification :one
4 INSERT INTO email_verifications (user_email_id, token_hash, expires_at)
5 VALUES ($1, $2, $3)
6 RETURNING id, user_email_id, token_hash, expires_at, used_at, created_at;
7
8 -- name: GetEmailVerificationByTokenHash :one
9 SELECT id, user_email_id, token_hash, expires_at, used_at, created_at
10 FROM email_verifications
11 WHERE token_hash = $1;
12
13 -- name: ConsumeEmailVerification :exec
14 UPDATE email_verifications
15 SET used_at = now()
16 WHERE id = $1 AND used_at IS NULL;
17
18 -- name: DeleteExpiredEmailVerifications :exec
19 DELETE FROM email_verifications WHERE expires_at < now();
20