https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Can't update column type despite the table being empty
    k

    KiwiHour

    05/13/2023, 9:39 PM
    I have a table of type int8. That type was just being used as a placeholder whilst I made another table that it would link to When trying to create a foreign key relation (thus updating the type), it says that it couldn't update the type from bigint to uuid. I know that you shouldn't be able to update the type to something as different as a uuid, but I feel like this should be ignored if there is no data that needs to be converted Do I need to recreate all my tables or is there a different method I can do to update the type of my column?
    g
    • 2
    • 2
  • Issue with local realtime
    j

    jarnold

    05/13/2023, 10:09 PM
    Unable to get realtime working at all unfortunately. CLI: 1.58.1 "@supabase/supabase-js": "^2.21.0", "Subscribing to PostgreSQL failed: {:error, \"Subscription insert failed with error: ERROR 42P01 (undefined_table) relation \\\"realtime.subscription\\\" does not exist\\n\\n query: with sub_tables as (\\n\\t\\t select\\n\\t\\t\\t rr.entity\\n\\t\\t from\\n\\t\\t\\t pg_publication_tables pub,\\n\\t\\t\\t lateral (\\n\\t\\t\\t\\t select\\n\\t\\t\\t\\t\\t format('%I.%I', pub.schemaname, pub.tablename)::regclass entity\\n\\t\\t\\t ) rr\\n\\t\\t where\\n\\t\\t\\t pub.pubname = $1\\n\\t\\t\\t and pub.schemaname like (case $2 when '*' then '%' else $2 end)\\n\\t\\t\\t and pub.tablename like (case $3 when '*' then '%' else $3 end)\\n\\t )\\n\\t insert into realtime.subscription as x(\\n\\t\\t subscription_id,\\n\\t\\t entity,\\n filters,\\n claims\\n )\\n select\\n $4::text::uuid,\\n sub_tables.entity,\\n $6,\\n $5\\n from\\n sub_tables\\n on conflict\\n (subscription_id, entity, filters)\\n do update set\\n claims = excluded.claims,\\n created_at = now()\\n returning\\n id. Check that tables are part of publication supabase_realtime and subscription params are correct: %{\\\"event\\\" => \\\"UPDATE\\\", \\\"schema\\\" => \\\"public\\\", \\\"table\\\" => \\\"layers_properties\\\"}\"}" Doing a
    SELECT * FROM pg_publication_tables WHERE tablename = 'layers_properties';
    Results in:
    Copy code
    | pubname           | schemaname | tablename         | attnames                                | rowfilter |
    | ----------------- | ---------- | ----------------- | --------------------------------------- | --------- |
    | supabase_realtime | public     | layers_properties | {owner_id,layer_id,property_name,value} |
    |
    g
    • 2
    • 21
  • Quick question about RLS
    k

    KiwiHour

    05/13/2023, 10:44 PM
    If I enable RLS, but have no policies Does this mean that users (except for service role) cannot read, update, insert or delete rows at all?
    g
    • 2
    • 4
  • How to get a column of a table via a foreign key
    k

    KiwiHour

    05/13/2023, 11:05 PM
    If you have a table
    recipies
    that contains the
    user_id
    that crated it. I also have a junction table
    xref_recipe_ingredients
    which contains the
    recipe_id
    and
    ingredient_id
    which are both foreign keys However, I want an RLS conditional expression on this junction table to make sure that the user adding this new relation is the owner of the recipe So, how would I use the foreign key
    recipe_id
    to obtain the
    user_id
    of that specific recipe in a SQL conditional expression? If my explanation is unclear I can add some images which may help
    • 1
    • 5
  • Dashboarding Tools
    c

    caseycrogers

    05/14/2023, 12:17 AM
    Do you guys recommend any good dashboarding sites/tools for generating analytics graphs from my supa data? Example: I have a wordle-esque trivia game with player guesses stored in Supa. I want to generate a histogram of number of guesses users took to solve a given puzzle. I have the SQL query, I just want to visualize it.
  • Supabase sign in with magic link not calling onAuthStateChange
    m

    MobileMon

    05/14/2023, 1:17 AM
    I'm using react native and supabase I call await supabase.auth.signInWithOtp({ email: email, options: { emailRedirectTo: 'myURL', }, }) and this successfully sends the user an email. the user clicks the email. I can see that the user is created in the supabase dashboard and email is verified however in my app supabase.auth.onAuthStateChange method is never fired also upon returning to the app I try and call await supabase.auth.getUser() but I get this: {"data":{"user":null},"error":{"name":"AuthApiError","message":"invalid claim: missing sub claim","status":401}} so not sure whats going on. Again the user is created in the supabase dashboard. They click the link in the email, it opens my app. i just get no call back
    l
    • 2
    • 1
  • Why use Vercel plugin?
    v

    vandivier

    05/14/2023, 1:24 AM
    https://vercel.com/integrations/supabase found it today. why would i use that instead of spinning up supabase-side?
  • Custom Phone Provider
    s

    shnoman

    05/14/2023, 2:43 AM
    Hi team, Is there any way we can use supabase phone auth with different provider ?
    g
    • 2
    • 7
  • Title: Unable to access Supabase instance at http://localhost:5432
    s

    silentworks

    05/14/2023, 12:05 PM
    Where is the code you are using to connect to the database?
  • Table/schema limit
    e

    EKI

    05/14/2023, 3:10 AM
    Are there any limits on how many tables/schema we can create each supabase project?
    g
    • 2
    • 1
  • How to deploy to supabase cloud hosting
    r

    rendom

    05/14/2023, 3:37 AM
    Okay this is not clear to me. I have created nuxt application added nuxt/supabase and I want to host it on supabase cloud. How to do it?
    g
    • 2
    • 11
  • Auto-Generate types
    e

    etdev2

    05/14/2023, 4:53 AM
    I've been a huge fan of Supabase, particularly the auto-generating types feature. It's converted me from a TypeScript hater to fanboy . However, I've recently encountered an issue that I'm hoping sombody can assist me with. After updating to Next.js 13.4 , I've noticed that my types are only auto-generating up to the 'from' clause, and they aren't throwing any type errors as expected. I'm unsure if this issue arises from the recent VS Code updates, Supabase, or TypeScript 5. For generating types, I'm currently using the following command in my package.json: "update-types": "npx supabase gen types typescript --project-id \"$PROJECT_ID\" > types/supabase.ts". Before I attempt to manually delve into type-land. I wanted to check if anyone else has experienced a similar issue or has any insights into this problem. Any help or guidance would be greatly appreciated.
  • React Native - Any suggestions for offline database with sync to supabase
    o

    octalpixel

    05/14/2023, 5:41 AM
    I currently have production app that has been running on supabase for sometime now, and want to make it offine first with sync to supabase. Any thoughts on that and any recommendations for a good database for RN (expo)
  • Help setting Auth
    c

    Cokaps016

    05/14/2023, 5:47 AM
    I've just learnt about Supabase recently and I'm trying to add it to my project. I followed the guide but sadly it didn't work.
    console.log(supabase)
    print a bunch of info however
    console.log(data)
    just doesn't work Here is content of my
    routes/+page.server.js
    Copy code
    js
    import { supabase } from '$lib/supabaseClient';
    
    export async function load() {
           console.log(supabase);
        const { data: data, error } = await supabase.from('tara').select('*');
        console.log(data); // Nothing
        };
    
    }
    and
    +page.svelte
    (under script tag)
    Copy code
    js
    <script>
    ...
        export let data;
        let { tData } = data;
        $: ({ tData } = data);
        console.log('This is data');
        console.log(tData);
    </script>
    But the result when I run
    pnpm dev
    in the console show an empty array which makes me really confused. Any ideas on fixing this issue. Thanks

    https://cdn.discordapp.com/attachments/1107182476910141570/1107182477073711165/image.png▾

    https://cdn.discordapp.com/attachments/1107182476910141570/1107182477363138601/image.png▾

    g
    r
    • 3
    • 18
  • Private Schema, RLS-Disabled warning
    c

    ccssmnn

    05/14/2023, 10:46 AM
    Hey people! Using Prisma as my ORM, I put all Prisma Stuff in a separate schema: the private schema. According to the API-Settings, only public and storage schemas are exposed via API. But the Supabase UI is showing a warning, that the tables are publicly readable and writable (screenshot). Can I safely ignore this warning?

    https://cdn.discordapp.com/attachments/1107257745394126960/1107257745616420924/Screenshot_2023-05-14_at_12.42.37.png▾

    g
    • 2
    • 2
  • How to filter docs in vectorStore
    n

    niqqa bird

    05/14/2023, 11:07 AM
    what am I doing wrong here?
    Copy code
    export const query = async (query) => {
      const vectorStore = await SupabaseVectorStore.fromExistingIndex(
        new OpenAIEmbeddings(),
        {
          client: SUPABASE_CLIENT,
          tableName: 'documents',
          queryName: 'match_documents_with_filters',
        }
      );
    
      const chain = ConversationalRetrievalQAChain.fromLLM(
        model,
        vectorStore.asRetriever(null, {
          email: 'abc@gmail.com',
        }),
        { returnSourceDocuments: true }
      );
    
      const res = await chain.call({
        question: query,
        chat_history: [],
      });
    
      console.log(res.text);
      console.log({ docs: res.sourceDocuments });
    
      return res;
    };
    
    query('what is my name?');
    Copy code
    CREATE FUNCTION match_documents_with_filters (
      query_embedding vector(1536),
      match_count int,
      filter jsonb DEFAULT '{}'
    ) RETURNS TABLE (
      id bigint,
      content text,
      metadata jsonb,
      similarity float
    )
    LANGUAGE plpgsql
    AS $$
    #variable_conflict use_column
    BEGIN
      RETURN QUERY
      SELECT
        id,
        content,
        metadata,
        1 - (documents.embedding <=> query_embedding) as similarity
      FROM
        documents
      WHERE
        metadata @> filter
      ORDER BY
        documents.embedding <=> query_embedding
      LIMIT
        match_count;
    END;
    $$;

    https://cdn.discordapp.com/attachments/1107262993835774022/1107262994192277584/image.png▾

    https://cdn.discordapp.com/attachments/1107262993835774022/1107262994532007937/image.png▾

    https://cdn.discordapp.com/attachments/1107262993835774022/1107262994863378532/image.png▾

  • supbase start not working with remote docker host
    k

    KinTex

    05/14/2023, 12:07 PM
    I get this error getaddrinfow: A non-recoverable error occurred during a database lookup in github.com/supabase/cli/internal/utils.AssertDockerIsRunning:48 in github.com/supabase/cli/internal/start.Run:37
  • is there a way to forbid certain patterns in email addresses with supabase auth?
    n

    nicollegah

    05/14/2023, 1:19 PM
    Have some users abusing my freemium model with @tempmail email addresses and would like to forbid them
    g
    • 2
    • 4
  • Review wanted for POC on RBAC and Multi-tenancy
    v

    valentin-valchev

    05/14/2023, 2:40 PM
    Hello all, I've created a simple POC on RBAC roles with multi-tenancy here -> https://github.com/vvalchev/supabase-multitenancy-rbac. My intention is to make this a great starter for the community. But I'm not a PostgreSQL expert. So any suggestion, improvement, or comment is welcome. It is based on wonderful https://github.com/supabase-community/supabase-custom-claims, but the claims are managed in a table. And it has some test cases, something that I didn't find in any other multi-tenancy example. One of the things I need urgent help with is implementing better "tenant admins" (see https://github.com/vvalchev/supabase-multitenancy-rbac/issues/1)
  • Database error finding user (when creating one) in local env
    j

    jarnold

    05/14/2023, 2:48 PM
    const { user: createdUser, error: signUpError } = await supabase.auth.signUp(user); is returning the error
    AuthApiError: Database error finding user
    Unlike others, I don't have a
    public.users
    table It seems like this has been reported multiple times here (discord) over the past year and on github https://github.com/supabase/supabase/issues/1479
    • 1
    • 2
  • What do people recommend for visualizing my Supabase data?
    c

    Canman

    05/14/2023, 3:06 PM
    I found the article from last year on setting up Metabase - is that the way to go for someone that doesn't want to spend a ton of time building a custom analytics dashboard?
  • edge functions: Recieve a file
    m

    Mared

    05/14/2023, 3:12 PM
    i am trying to recieve a file using supabase edge function but it returns an undefiend, how can i fix it? please not that i'll revieve a file and i'll post it to some endpoint, after the endpoint process the file i'll call another endpint to get the data and set it to the user table. import { serve } from 'https://deno.land/std@0.168.0/http/server.ts'; const corsHeaders = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type', }; serve(async (req: any) => { // This is needed if you're planning to invoke your function from a browser. if (req.method === 'OPTIONS') { return new Response('ok', { headers: corsHeaders }); } try { const { file } = await req; console.log('file', file); const predictUrl = 'https://some-api.com/predict?user_id='; const headers = { 'api-key': '1234567890', 'Access-Control-Allow-Origin': '*', }; const formData = new FormData(); formData.append('audio_file', file); const predictResponse = await fetch(predictUrl, { method: 'POST', headers: headers, body: formData, }); const data = await predictResponse.json(); return new Response(JSON.stringify(data), { headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 200, }); } catch (error: any) { return new Response(JSON.stringify({ error: error.message }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 400, }); } });
  • Is abuse possible when writing queries in react-native code?
    r

    rostero

    05/14/2023, 3:49 PM
    I want to write a mobile expo react native app. Traditionally, I'd write the database code on a server and have react native code query that, but the examples show the queries directly in react native. Would this open up the database to abuse, where someone could somehow could capture the XHR request and modify it to create long running queries or other types of query abuse?
    g
    • 2
    • 7
  • auth-helpers-sveltekit | createSupabaseServerClient/createClient - multiple client calls
    p

    puffybatman

    05/14/2023, 4:02 PM
    i wonder how does supabase handle multiple client calls? createSupabaseServerClient is used in the hook.server of my sveltekit app ... i worry if i am creating too many connections might end up overloading/hitting limit.... Reason i ask, I want to recreate createSupabaseServerClient but use service role key, for few routes in my app.
    g
    • 2
    • 2
  • can you run API calls to third party services inside of the generated DB crud routes?
    a

    ABD

    05/14/2023, 4:04 PM
    I am trying to see if supabase can be used as a suitable backend for my app? 1. Can you chain together server less functions to create a backend? Is there an execution timeout on the functions? 2. Can you intersperse API calls inside of the crud API generated above the DB?
  • Auth Admin doesn't behave normally ?
    l

    Logaritma26

    05/14/2023, 4:17 PM
    With the client Supabase client, I can normally create user, and users receive confirmation emails, when I use server role admin auth and create users, neither user created nor any emails received, what am I missing ? I use below code to create admin auth and create user (next js - TS): const supabase = createClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.PRIVATE_SERVICE_ROLE!, { auth: { autoRefreshToken: false, persistSession: false, }, }, ) const { data, error} = await supabase.auth.admin.createUser({ email: userEmail, password: userPassword, user_metadata: { name: 'Yoda' }, app_metadata: { is_office_account: true, is_active: false, }, })
    g
    s
    • 3
    • 22
  • TypeError: Cannot read properties of null (reading 'useContext')
    m

    mohammadrahi

    05/14/2023, 4:40 PM
    I'm using supabase and react-loading-skeleton in my nextjs project. Now, getting an error to deploying on Vercel. TypeError: Cannot read properties of null (reading 'useContext') at exports.useContext (/vercel/path0/node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.production.min.js:24:118) at Skeleton (file:///vercel/path0/node_modules/.pnpm/react-loading-skeleton@3.3.0_react@18.2.0/node_modules/react-loading-skeleton/dist/index.js:36:39) at Ge (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:114:273) at Z (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91) at He (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:123:155) at Ge (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:115:215) at Z (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91) at He (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:123:155) at Je (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:122:100) at Z (/vercel/path0/node_modules/.pnpm/next@13.4.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:222)
  • How to set maintenance_work_mem
    a

    avalanche

    05/14/2023, 5:11 PM
    I'm trying to set maintenance_work_mem in supabase:
    Copy code
    sql
    alter system set maintenance_work_mem = '100000';
    but I get this error: 'permission denied to set parameter "maintenance_work_mem"' The reason I'm trying to do this is because I need to index chat gpt embeddings which require more than 64MB of maintenance_work_mem.
    Copy code
    sql
    CREATE INDEX ON public.context USING ivfflat (embedding vector_cosine_ops) WITH (lists = 113);
    Copy code
    Failed to run sql query: memory required is 65 MB, maintenance_work_mem is 64 MB
    g
    • 2
    • 2
  • help with Postgres function that returns a joined query
    a

    Athens Horseparty

    05/14/2023, 6:34 PM
    Hello, I'm new to functions and Postgres so I'm having trouble getting this to work. I can't seem to figure out what the return type should be, or how I would set it up using the UI. Here is the current definition I attempted:
    Copy code
    sql
    create or replace function get_user_data(uid_input uuid)
    returns setof auth.users as $$
    
        begin
            return query select users.id, email, name
            from auth.users left join public.profiles
            on profiles.user_id = users.id
            where users.id = uid_input;
        end;
    $$ language plpgsql;
    When I run the following query
    Copy code
    sql
    select * from public.get_user_data('6befbf51-8b93-42af-99c3-fd8732fa4c2c')
    I get the following error: Failed to run sql query: structure of query does not match function result type I feel like using a setof users is incorrect since the query it returns is a table with values from profiles as well, but I can't seem to find a good example of what I want to do by searching online. Thanks for your help!
    g
    • 2
    • 7
  • google auth not working
    h

    Holland

    05/14/2023, 6:39 PM
    Hey, I'm getting the following error.
    Copy code
    next-dev.js:20 Error: Abort fetching component for route: "/home"
        at handleCancelled (router.js:346:27)
        at _callee$ (router.js:1249:17)
        at tryCatch (runtime.js:45:16)
        at Generator.invoke [as _invoke] (runtime.js:274:1)
        at prototype.<computed> [as next] (runtime.js:97:1)
        at asyncGeneratorStep (_async_to_generator.js:23:1)
        at _next (_async_to_generator.js:12:1)
    I am using this function:
    Copy code
    const loginGoogleHandler = async () => {
        console.log('loggin in with google')
        const { data, error } = await supabase.auth.signInWithOAuth({
          provider: 'google',
          options: {
            redirectTo: `${new URL(location.href).origin}/logging-in?redirect=/home`,
          },
        })
        console.log('results of logging in: ', data, error)
      }
    I have a logging in component with the following fn:
    Copy code
    useEffect(() => {
        // check if user has been set in session store then redirect
        const url = new URL(window.location.href)
        const redirectTo = url.searchParams.get('redirect')
        ;(async () => {
          await waitload(1)
          router.push(redirectTo ?? '/posts')
        })()
      }, [])
    It redirects twice to the /logging-in route which is weird and shouldnt do that, and then the printed session is null In my home route the session is null meaning the google sign in failed, any ideas why.
    Copy code
    export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
      // Create authenticated Supabase Client
      const supabase = createServerSupabaseClient(ctx);
      // Check if we have a session
      const {
        data: { session }
      } = await supabase.auth.getSession();
      console.log('session: ', session);
    
      if (!session)
        return {
          redirect: {
            destination: '/auth/signin',
            permanent: false
          }
        };
    
      return {
        props: {
          initialSession: session,
          user: session.user
        }
      };
    };
    Im really confused cause this works in another project.
1...213214215...230Latest