https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • ignoreDuplicates not working
    m

    morgan

    02/24/2023, 3:03 AM
    Hi guys, I keep getting this error, it seems Supabase isn't ignoring duplicates with my constraints. My goal is to keep unique columns per
    wc_store_id
    row. So the table could have the same email a few times in relation to different
    wc_store_id
    , but never for the same one. Error when there's already a record:
    Copy code
    js
    {
        "code": "23505",
        "details": "Key (email, wc_store_id)=(hidden@gmail.com, 37d2310e-f789-4ae0-a314-b379aeea0851) already exists.",
        "hint": null,
        "message": "duplicate key value violates unique constraint \"unique_email_wc_store_id_for_wc_customers\""
    }
    Upsert:
    Copy code
    js
      const { error: errorUpsertingGuests } = await supabaseAdmin
        .from("wc_customers")
        .upsert(foundGuestCustomers, {
          onConflict: "email,wc_store_id",
          ignoreDuplicates: true, // This is not working with my setup. Maybe because the record matches the first contraint? 
        });
    SQL Constraints:
    Copy code
    sql
    ALTER TABLE wc_customers
    ADD CONSTRAINT unique_internal_id_wc_store_id_for_wc_customers UNIQUE (internal_id,wc_store_id);
    
    ALTER TABLE wc_customers
    ADD CONSTRAINT unique_email_wc_store_id_for_wc_customers UNIQUE (email,wc_store_id);
    Any help is appreciated 🙏
  • is hosted read replicas for supabase on the roadmap?
    o

    ostoto

    02/24/2023, 3:08 AM
    this would be a gamechanger!
  • How do I get this to render other components after sign in provider.
    d

    declanmiddleton

    02/24/2023, 3:32 AM
    How do I get this to render other components after sign in provider? any advice is greatly appreciated.
    Copy code
    js
    import { useSession } from "@supabase/auth-helpers-react";
    import { supabase } from "../lib/supabase";
    import { useEffect, useState } from "react";
    
    import Navbar from "@/Navbar/Navbar";
    import Footer from "@/Footer/Footer";
    import Auth from "@/Auth/Auth";
    
    const Layout = ({ children }) => {
      const session = useSession();
    
      return (
        <>
          {!session ? (
            <>
              <Auth />
            </>
          ) : (
            <>
              <Navbar />
              <main>
                <section>{children}</section>
              </main>
              <Footer />
            </>
          )}
        </>
      );
    };
    
    export default Layout;
    s
    • 2
    • 9
  • Documentation for PHP Google Auth
    a

    akshatgggggg

    02/24/2023, 3:39 AM
    Hi, I am building a PHP based web app and want to use Google Auth using Supabase. I've successfully setup email password auth using the Supabase PHP Client on Github (https://github.com/rafaelwendel/phpsupabase) but for Google Auth, I'm unable to find support in this client. Can someone advise on how to go about it?
  • Help with discord Auth
    l

    lecookie

    02/24/2023, 4:17 AM
    why do I get this ?
    s
    • 2
    • 3
  • Unable to view tables in table editor
    a

    aar2dee2

    02/24/2023, 5:05 AM
    I get a
    500
    error when trying to view tables. There's a
    permission denied for schema supabase_functions
    error in my Postgres logs. This is a recent bug, I could view the tables till a couple days ago.
    r
    • 2
    • 1
  • How to Full Text Search on Multiple Columns in JS
    r

    RB_Gaura

    02/24/2023, 5:51 AM
    Title^^. The docs show how to do it for SQL, but don't show how that translates to the JS library. Documentation is linked here: https://supabase.com/docs/guides/database/full-text-search
    g
    • 2
    • 1
  • How to generate UUID inside a triggered function
    w

    w3center

    02/24/2023, 7:44 AM
    I created a function handle_new_user which is called by a trigger (creating a new user). The function looks like this:
    Copy code
    postgresql
    declare
       orgId uuid := uuid_generate_v4();
    begin
       insert into public.org(id,name) values (orgId,'Personal');
       insert into public.profile(orgId,userId,email) values (orgId,new.id,new.email);
       return new;
    end;
    Unfortunately, the function returns an error:
    Copy code
    function uuid_generate_v4() does not exist
    Which is strange because the extension is enabled and generates uuid correctly elsewhere. It looks like it doesn't work only in the triggered function. I also tried using
    public.uuid_generate_v4()
    but also without success. Any hints?
    • 1
    • 1
  • Reinviting the user
    n

    NJ™

    02/24/2023, 7:48 AM
    As an admin, i am able to send invite links to my users and redirect them to set password page. But in case they fail to set password the link is expired but the user gets authenticated nonetheless. Is it possible to send a reinvite link if the user hasn't set up the password? The current flow i am using is I have to soft delete the user and recreate them in auth and my create user table.
  • Use PostGIS functions within filters?
    j

    J_B

    02/24/2023, 7:52 AM
    Hey all, how can i use a PostGIS function (in my case ST_WITHIN) within a filter. I tried the following code (normally, the extent is calculated dynamically):
    Copy code
    const extent = "ST_BUFFER(ST_POINT(11.5339694, 48.2147208)::geography, 250)::geometry";
    supabase.from("table").select().filter("location", "st_within", extent);
    But it gave me an error:
    Failed to parse [(\"location\",\"st_within().ST_BUFFER(ST_POINT(11.53397, 48.214712)::geography, 250)::geometry\")]
    This generated query looks obviously wrong. I would expect to get the following query:
    st_within(location, ST_BUFFER(ST_POINT(11.53397, 48.214712)::geography, 250)::geometry)
    g
    • 2
    • 2
  • Update postgres extension
    e

    erik-beus

    02/24/2023, 7:52 AM
    We're using the
    pg_net
    extension, but want to update it to the latest version (
    0.7.1
    ). Currently, we're on version
    0.2
    on our cloud hosted postgres. If I run:
    SELECT * FROM pg_available_extension_versions where name='pg_net';
    it seems that there are no other versions available than
    0.2
    If I start a new project in supabase, the postgres db is using version
    0.7.1
    of
    pg_net
    . How do we update this and other extensions? Thank you 🙂
    v
    • 2
    • 10
  • AuthStateChanged does not fire onsignOut
    j

    jfbn

    02/24/2023, 8:38 AM
    Using SvelteKits form actions, I am making a post request to a form action handler that then fires the
    signOut
    function available on the supabase clients auth module. The user is signed out, the session is terminated, but the
    onAuthStateChanged
    listener from my layout is not firing. Notice that it does fire correclty when signing in.
    s
    • 2
    • 33
  • Recover deleted users
    k

    Kcrik

    02/24/2023, 9:16 AM
    Hello guys, I couldn't find an answer to that one. We are using Supabase to register user and authenticate them in our Web App. We are working on back-up plans and recovery plans. If a user account get deleted from Supabase, is it backed-up somewhere, or we would need to ask our user to create a new account ? Cheers, Chris
    s
    • 2
    • 2
  • Question about allowing deletion of all rows based on a user
    m

    MAXOUXAX

    02/24/2023, 10:34 AM
    Hey guys! I'm trying to add an RLS policy to allow the deletion of all rows on a table based on the value of the current user column. Anyway, here's my problem: I've got a user_metadata table that looks like this: | user_id | admin | | abc... | true | | def... | false | user_id refers to the UUID from Supabase's auth.users table I want to allow all users having that admin column set to true to delete any other row in the table, as well as the corresponding user from the auth.users table. I read the documentation but I'm new to PostgreSQL RLS and don't really know what to write as my expression.
  • I am not superuser when creating a new DB
    c

    ConnorSmiley

    02/24/2023, 10:35 AM
    I am trying to change postgres to super user. I know about the
    alter user postgres with superuser
    but I am not a SU. I deleted by DB and restarted and cannot run the command inside the SQL editor on supabase. How can I become a superuser when creating a new DB? Thanks
    g
    • 2
    • 4
  • Redirect after Login with "signInWithOtp"
    m

    Maxoouuu

    02/24/2023, 11:48 AM
    Hello, I try to redirect users on the last page they were on, on my Nuxt 3 project but **redirecTo **didn't seem to work really well even when I try on a specific page /test-connexion. We have tried this and the link received by mail is always the same at the end:
    https://ydipallaaniajlzvcdqu.supabase.co/auth/v1/verify?token=547004c8a6763e54d8593f0700eb34e71caf2b7a951ec67140eac553&type=magiclink&redirect_to=http://localhost:3000/
    Copy code
    js
    const handleLogin = async (event) => {
      try {
        loading.value = true;
    
        const { data: response, error } = await supabase.auth.signInWithOtp(
          {
            email: email.value,
          },
          { redirectTo: "http://localhost:3000/test-connexion" }
        );
    
        if (error) throw error;
        alert("Check your email for the login link!");
      } catch (error) {
        alert(error.error_description || error.message);
      } finally {
        loading.value = false;
      }
    };
    s
    • 2
    • 4
  • nextjs 13 and "@supabase/auth-helpers-react"
    g

    Grimmjoww231

    02/24/2023, 12:55 PM
    hey guys im working with nextjs 13 and was wondering if the "@supabase/auth-helpers-react" will be affected with their new app/pages folder structure . any advice on how to move forward ?
    s
    • 2
    • 2
  • Enable access to profiles of certain users via RLS policies
    b

    benjaminpreiss

    02/24/2023, 12:55 PM
    Dear all! I have been trying to allow a certain user to SELECT other users profiles by writing a SELECT policy. This SELECT policy looks like:
    Copy code
    sql
    auth.is_matched(auth.user_id(), user_id) = true
    and the function auth.is_matched:
    Copy code
    sql
    create or replace function auth.is_matched(requesting_user text, requested_user text) returns boolean as $$
    declare
      is_matched boolean;
    begin
      raise log 'Value: %', $1;
      raise log 'Value: %', $2;
      is_matched := false;
      if exists ( 
        select o.user_id from match_offers o 
        inner join matches m on o.id = m.offer
        inner join match_requests r on r.id = m.request
        where o.user_id = $1 and r.user_id = $2 or o.user_id = $2 and r.user_id = $1
      ) then
        is_matched := true;
      end if;
      return is_matched;
    end;
    $$ language plpgsql stable;
    The problem is that the select policy seems to block all access. Any ideas what I am doing wrong?
    s
    g
    • 3
    • 36
  • PostGIS have no access to tiger tables
    a

    Alexander Kremenets

    02/24/2023, 1:30 PM
    I am trying to restore a backup of a database which use postGIS. And I have dealt with most of the issues, but one thing I do not know how to overcome. tiger.geocode_settings - no permissions to tiger schema. It is owned by supabase_admin user, hence I have no access as the postgres user. I am not too proficient with postgres, this one might be some stupid mistake. But I can nor change tiger extension schema nor its owner. Any tips or ideas will be highly appreciated.
    g
    • 2
    • 6
  • Is there a way to automatically create a referenced row on insert?
    e

    enyo

    02/24/2023, 2:13 PM
    I have two tables, that link to one another:
    organisations.default_team_id -> teams.id
    teams.organisation_id -> organistion.id
    I want to insert a default team every time an organisation is created, and because I know that this happens, I want
    default_team_id
    to be
    not null
    . I tried creating a trigger like this:
    Copy code
    sql
    
    create
    or        replace function public.create_default_team_on_org_insert () returns trigger language 'plpgsql' volatile security definer cost 10000 as $body$
    declare
      new_team_id bigint;
    begin
      insert into teams (organisation_id, name, is_default) values (new.id, 'All', true) returning id into new_team_id;
      new.default_team_id = new_team_id;
      return new;
    end;
    $body$;
    
    create    trigger create_default_team_on_org_insert
    before     insert on organisations for each row
    execute   procedure create_default_team_on_org_insert ();
    But this fails, because the organisation doesn't exist when I try to insert the team. If I change the trigger to
    after
    , then it fails because
    default_team_id
    cannot be null. Any tips?
    s
    g
    • 3
    • 9
  • How to migrate users from firebase to supabase
    s

    slavendjervida

    02/24/2023, 3:06 PM
    I read the instructions in the following GitHub repository: https://github.com/supabase-community/firebase-to-supabase/tree/main/auth. However, I'm still experiencing some issues. Specifically, it appears that passwords have been changed and the tables indicate that they are waiting for email verification, even though I turned off this feature in the settings.
  • What's the easiest way to download the production db into my local environment?
    s

    stillmotion

    02/24/2023, 3:22 PM
    Supabase CLI is really fast to get my local environment setup, but I was sad to see that all the work I put into creating my db schema on the production website isn't automatically copied into my local postgres instance. Other than pg_dump, is there a fast simple way to do this via the CLI?
    s
    d
    • 3
    • 10
  • User has to sign in again and again when launching app on iOS
    k

    kaaloo

    02/24/2023, 4:23 PM
    Any insights as to why some users need to sign in again and again each time the use our app on iOS? Our app is running in a web view via Capacitor from Ionic. The web app itself is hosted on Vercel and is a Next.js app. The only thing I can think if is that somehow the supabase auth cookies are getting cleared but I don't see why this would affect some users and not others. I can't reproduce the behavior on a stock iPhone.
  • Wait for query to finish
    h

    Hamburger

    02/24/2023, 4:25 PM
    Is there a way to wait for a query to finish? I am checking if a value does not exists in a column and sometimes it does not return any data.
    s
    g
    • 3
    • 23
  • PGvector not avaliable locally.
    m

    maxbaluev

    02/24/2023, 4:27 PM
    I cabt see PGvector extension in the extension list, also I cant enable extension by sql command 'create extension if not exists "pgvector" with schema extensions;' I use last supabase cli 1.38.7. How I can enable it?
    g
    s
    • 3
    • 5
  • Discord Auth Token
    l

    lecookie

    02/24/2023, 4:45 PM
    How can I get access_token when the user is redirected to the success page ? When I use
    supabase.auth.getSession()
    there is not access_token provided. Here is my code
    Copy code
    js
    import { createClient } from "@supabase/supabase-js";
    import { Auth, ThemeSupa } from "@supabase/auth-ui-react";
    import { useNavigate } from "react-router-dom";
    import React, { useEffect, useState } from "react";
    
    const supabase = createClient(
      "https://yzrejpciblqqfsybjqye.supabase.co",
      "secret"
    );
    
    function Success() {
      const [user, setUser] = useState({});
      const navigate = useNavigate();
    
      useEffect(() => {
        async function getUserData() {
          await supabase.auth.getUser().then((value) => {
            //value.data.user
            if (value.data?.user) {
              console.log(value.data.user);
              setUser(value.data.user);
            }
          });
        }
        getUserData();
      }, []);
      async function getData() {
        const { data, error } = await supabase.auth.getSession();
        console.log(data);
      }
      async function signOutUser() {
        const { error } = await supabase.auth.signOut();
        navigate("/");
      }
      return (
        <div className="App">
          <header className="App-header">
            {Object.keys(user).length !== 0 ? (
              <>
                <h1>Success</h1>
                <button onClick={() => signOutUser()}>SignOut</button>
              </>
            ) : (
              <>
                <h1>Your are not logged in</h1>
                <button onClick={() => navigate("/")}>Go Back</button>
              </>
            )}
          </header>
        </div>
      );
    }
    
    export default Success;
  • Hello, what would be the best way to generate specific types for JSON columns?
    d

    DevGuy

    02/24/2023, 5:12 PM
    Copy code
    export type Json =
      | string
      | number
      | boolean
      | null
      | { [key: string]: Json }
      | Json[];
    I currently use this in my types with Supabase now but was wondering if anyone knows a good workflow to assign specfic typescript types to these json columns. Thanks!
  • why does delete not include the whole object?
    t

    techleed

    02/24/2023, 5:20 PM
    Copy code
    dota  | DELETE {
    dota  |   schema: 'public',
    dota  |   table: 'steam_accounts',
    dota  |   commit_timestamp: '2023-02-24T17:19:04Z',
    dota  |   eventType: 'DELETE',
    dota  |   new: {},
    dota  |   old: { id: 'cleisrp4b0000cwt2tb96nmrb' },
    dota  |   errors: null
    dota  | }
    ime xpecting old to contain the entire row, not just id. how do i change this? my replication is already set to
    full
    for this table
    s
    g
    • 3
    • 22
  • nextjs 13 authentication and protected pages
    m

    mct.dev

    02/24/2023, 5:38 PM
    How to implement supabase v2 authentication using the helper library in nextjs 13
    s
    t
    r
    • 4
    • 28
  • Import Supabase into Edge Function
    i

    ICAZ117

    02/24/2023, 6:35 PM
    Hey yall, I need to import Supabase into an edge function, but I keep getting the following error:
    Copy code
    Relative import path "@supabase/supabase-js" not prefixed with / or ./ or ../ and not in import map from "file:///
    My code is as follows:
    Copy code
    js
    import { createClient } from "@supabase/supabase-js";
    I've also tried adding a deno.json file and changing the code to this:
    Copy code
    js
    import { createClient } from "supabase";
    The deno.json file in the root directory of my Vue project (which contains the Supabase project). The contents of the deno.json file are as follows:
    Copy code
    json
    {
        "imports": {
          "std/": "https://deno.land/std@0.168.0/",
          "stripe": "https://esm.sh/stripe@11.9.1",
          "supabase": "npm:supabase/supabase-js"
        }
    }
    I have attached a screenshot of the file structure of my project. Please advise on how to proceed. Thank you!
    g
    • 2
    • 1
1...144145146...230Latest