insert into secd.credential (
       credential_public_id
       , identity_id
       , partial_key
       , type
       , data
       , created_at
       , revoked_at
       , deleted_at
) values (
       $1
       , (select identity_id from secd.identity where identity_public_id = $2)
       , $3
       , $4
       , $5::jsonb
       , $6
       , $7
       , $8
) on conflict (partial_key) do update
  set revoked_at = excluded.revoked_at
      , deleted_at = excluded.deleted_at;
