aboutsummaryrefslogtreecommitdiff
path: root/crates/secd/store/pg/sql/write_address_validation.sql
diff options
context:
space:
mode:
Diffstat (limited to 'crates/secd/store/pg/sql/write_address_validation.sql')
-rw-r--r--crates/secd/store/pg/sql/write_address_validation.sql27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/secd/store/pg/sql/write_address_validation.sql b/crates/secd/store/pg/sql/write_address_validation.sql
new file mode 100644
index 0000000..3be830e
--- /dev/null
+++ b/crates/secd/store/pg/sql/write_address_validation.sql
@@ -0,0 +1,27 @@
+insert into secd.address_validation (
+ address_validation_public_id
+ , identity_id
+ , address_id
+ , "method"
+ , token_hash
+ , code_hash
+ , attempts
+ , created_at
+ , expires_at
+ , revoked_at
+ , validated_at
+) values(
+ $1
+ , (
+ select identity_id from secd.identity where identity_public_id = $2
+ )
+ , (
+ select address_id from secd.address where address_public_id = $3
+ )
+ , $4, $5, $6, $7, $8, $9, $10, $11
+) on conflict (address_validation_public_id) do update
+ set identity_id = excluded.identity_id
+ , attempts = excluded.attempts
+ , revoked_at = excluded.revoked_at
+ , validated_at = excluded.validated_at
+returning (xmax = 0);