aboutsummaryrefslogtreecommitdiff
path: root/crates/secd/store/sqlite/sql/write_address_validation.sql
diff options
context:
space:
mode:
authorbenj <benj@rse8.com>2022-12-24 00:43:38 -0800
committerbenj <benj@rse8.com>2022-12-24 00:43:38 -0800
commitc2268c285648ef02ece04de0d9df0813c6d70ff8 (patch)
treef84ec7ee42f97d78245f26d0c5a0c559cd35e89d /crates/secd/store/sqlite/sql/write_address_validation.sql
parentde6339da72af1d61ca5908b780977e2b037ce014 (diff)
downloadsecdiam-c2268c285648ef02ece04de0d9df0813c6d70ff8.tar
secdiam-c2268c285648ef02ece04de0d9df0813c6d70ff8.tar.gz
secdiam-c2268c285648ef02ece04de0d9df0813c6d70ff8.tar.bz2
secdiam-c2268c285648ef02ece04de0d9df0813c6d70ff8.tar.lz
secdiam-c2268c285648ef02ece04de0d9df0813c6d70ff8.tar.xz
secdiam-c2268c285648ef02ece04de0d9df0813c6d70ff8.tar.zst
secdiam-c2268c285648ef02ece04de0d9df0813c6d70ff8.zip
refactor everything with more abstraction and a nicer interface
Diffstat (limited to 'crates/secd/store/sqlite/sql/write_address_validation.sql')
-rw-r--r--crates/secd/store/sqlite/sql/write_address_validation.sql26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/secd/store/sqlite/sql/write_address_validation.sql b/crates/secd/store/sqlite/sql/write_address_validation.sql
new file mode 100644
index 0000000..67ce916
--- /dev/null
+++ b/crates/secd/store/sqlite/sql/write_address_validation.sql
@@ -0,0 +1,26 @@
+insert into 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 identity where identity_public_id = $2
+ )
+ , (
+ select address_id from 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;