insert into secd.email_validation
       (
           email_validation_public_id
           , email_id
           , code
           , is_oauth_derived
           , created_at
           , validated_at
           , expired_at
       )
values (
           $1
           , $2
           , $3
           , $4
           , $5
           , $6
           , $7
) on conflict (email_validation_public_id) do update
  set validated_at = excluded.validated_at
      , expired_at   = excluded.expired_at;
--
insert into secd.identity_email_validation (
       identity_id
       , email_validation_id
       , revoked_at
       , deleted_at
) values (
       (
       select identity_id
       from secd.identity
       where identity_public_id = $1
       )
       , (
         select email_validation_id
         from secd.email_validation
         where email_validation_public_id = $2
         )
        , $3
        , $4
) on conflict (identity_id, email_validation_id) do update
  set revoked_at = excluded.revoked_at
      , deleted_at = excluded.deleted_at;
