if condition on postgress function - Supabase