insert into auth.email_validation
       (
           email_validation_public_id
           , identity_email_id
           , attempts
           , code
           , is_validated
           , created_at
           , expires_at
       )
values (
           $1
           , (
               select identity_email_id
               from auth.identity_email
               where identity_id = $2
               and email_id = $3
           )
           , $4
           , $5
           , $6
           , $7
           , $8
) on conflict (email_validation_public_id) do update
  set attempts       = excluded.attempts
      , is_validated = excluded.is_validated
      , expires_at   = excluded.expires_at;
