https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Policies UPDATE all rows for specific users (If auth.uid() = XY then..)
    m

    Micky

    04/21/2023, 12:26 PM
    Hello everybody, I have some issues while editing new policies to my database. I would like to UPDATE all rows for specific users only. For this I tried the following in Supabase under Authentication -> Policies -> schema public -> *the table*: CREATE POLICY "update" ON "public"."*the table*" WITH CHECK ((auth.uid() = '0000000-0000-0000-0000-0000000000'::uuid)); It was saved successfully but there are no UPDATES possible.. also "auth.uid() = table.user_id" doesn't returns anything. If I use the role "anon" and "TRUE" only, everything is working fine. Everything is working via a software which supports Supabase API. So it's not the easiest one to handle with SQL comments from the application.. Supabase Support is not supporting because they don't know, what to do for this. I hope anybody can help me here that resolving it. Thank you in advance!
    g
    • 2
    • 1
  • ID to UUID
    j

    JohnyMcB

    04/21/2023, 12:38 PM
    Hello all, I currently have a table "Events" with the PK id (int8). I would like to convert the id into a UUID - unfortunately the system throws an error, even if all data is gone. I had wanted to do this before, but deleted the table completely and created a new one. "Cannot cast type bigint to uuid" Any idea how to do this without deleting and recreating the table? Best regards
    n
    s
    s
    • 4
    • 11
  • Wrong 2FA code makes my supabase account unusable
    g

    GregorDoltar

    04/21/2023, 1:44 PM
    Dear community. We are using 2FA. Sometimes when incorrect 2FA is entered system becomes unresponsive. I need to do "Fast database reboot" to get system back on trackk. Is this a known issue ?
    s
    d
    • 3
    • 13
  • supabase function deployment errrors
    r

    rbl

    04/21/2023, 2:59 PM
    Download https://deno.land/x/lz4@v0.1.2/wasm.js file:///src/import_map.json file:///src/index.ts file:///src/handler.ts file:///_shared/cors.ts error: Uncaught (in promise) Error: Module not found "https://esm.sh/v117/entities@4.4.0/deno/lib/decode.js". const ret = new Error(getStringFromWasm0(arg0, arg1)); ^ at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.35.0/eszip_wasm.generated.js:513:19) at (https://deno.land/x/eszip@v0.35.0/eszip_wasm_bg.wasm:1:1559899) at (https://deno.land/x/eszip@v0.35.0/eszip_wasm_bg.wasm:1:1398157) at (https://deno.land/x/eszip@v0.35.0/eszip_wasm_bg.wasm:1:1895031) at __wbg_adapter_40 (https://deno.land/x/eszip@v0.35.0/eszip_wasm.generated.js:229:6) at real (https://deno.land/x/eszip@v0.35.0/eszip_wasm.generated.js:213:14)
    s
    • 2
    • 3
  • Supabase edgefunction not inserting to database
    r

    Rosibert

    04/21/2023, 4:45 PM
    Following code does not insert data to my database:
    Copy code
    js
    import { createClient } from "https://esm.sh/@supabase/supabase-js@2.21.0"
    import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
    
    const supabaseClient = createClient(
      // Supabase API URL - env var exported by default.
      Deno.env.get('SUPABASE_URL') ?? '',
      // Supabase API ANON KEY - env var exported by default.
      Deno.env.get('SUPABASE_ANON_KEY') ?? '',
    )
    
    serve(async (req) => {
      const { userId } = await req.json()
      console.log(userId)
      supabaseClient.from('public.user_roles').insert({user: userId, role: 'customer'})
    
      return new Response(
        JSON.stringify(userId),
        { headers: { "Content-Type": "application/json" } },
      )
    })
    my schema looks like this:

    https://cdn.discordapp.com/attachments/1099013143746846840/1099013143985914006/image.png▾

    s
    • 2
    • 1
  • postgres ERROR: column "profileid" of relation "account" does not exist at character 31
    v

    ven

    04/21/2023, 5:51 PM
    Hello, I am trying to create a database function that would trigger an insert into the "profile" table and then use the newly create profile.id to insert an entry into the "account" table. I keep erroring out. obviously my sql is not right. here is my sql. thoughts?
    Copy code
    -- inserts a row into public.profile when a new user is created
    create or replace function public.handle_new_user() returns trigger as $$ begin
    -- insert a row into public.profile with the user_uid and email
    insert into public."profile" (user_uid, email)
    values (new.id::text, new.email);
    -- insert a row into public.account with the profile_id
    insert into public."account" (profileId)
    values (new.id::number);
    return new;
    end;
    $$ language plpgsql security definer;
    s
    b
    n
    • 4
    • 16
  • new row violates row-level security policy for table \"admins\"
    m

    MATTI

    04/21/2023, 6:01 PM
    I get the error "new row violates row-level security policy for table \"admins\"" after setting up a RLS policy on my "admins" table. Admins should be able to have access to ALL in the admins table, but for some reason it doesn't work. Does anyone have any clues why?

    https://cdn.discordapp.com/attachments/1099032207902912512/1099032208326533230/image.png▾

    https://cdn.discordapp.com/attachments/1099032207902912512/1099032208628531292/image.png▾

    s
    n
    +4
    • 7
    • 32
  • Supabase-Go
    m

    mantism

    04/21/2023, 6:24 PM
    Hello, I'm interested in using supabase with my Go backend for a personal-project. I saw that there are some go clients in the supabase-community repo and the supabase-go rep is just a readme at the moment. Is there a roadmap anywhere for implementing the supabase-go wrapper client or any general guidance to contributing if i want to help build it out?
    o
    • 2
    • 2
  • Postgres Changes Realtime Delivery Guarantees
    j

    Julian IncrEdelman

    04/21/2023, 7:33 PM
    Hey all! I'm excited to use Postgres DB push! Understandably the github says:
    Copy code
    The server does not guarantee that every message will be delivered to your clients so keep that in mind as you're using Realtime.
    https://github.com/supabase/realtime I'm curious - are there any sort of guarantees? Is it at-most-once? Are there any guidelines or best practices on what sort of fail-safes to have? I understand it will be application-specific, but I can imagine a few options (a refresh button, a system to poll with a lower frequency as a failsafe). I was wondering if perhaps there was any recommended libraries for these failsafes so I could avoid rolling my own. Thanks and love Supabase!
  • PgVector not an option with local hosting?
    t

    tristansinclair

    04/21/2023, 8:15 PM
    Hey all, I'm trying to develop my database locally before deploying to Supabase. I really want to work with PgVector but it seems to not be an option as a local extension. Am I doing something wrong? How can I get this on my local instance?

    https://cdn.discordapp.com/attachments/1099065832463675542/1099075845945041061/Screenshot_2023-04-21_at_1.54.39_PM.png▾

    i
    • 2
    • 10
  • Next 13 App Router: Auth Helpers - Way to check if user is successfully authorised? (redirect)
    m

    MusashiGarami

    04/21/2023, 8:23 PM
    I'm able to login my profile with a login component, but I want to Next Router Push "/" (back to home page) once I've successfully logged in. Something like: const { session } = await supabase.auth.getSession(); if (session) { router.push("/"); } else { alert("User not found"); } Any suggestions on best practice on how to automatically redirect user after successful login is welcome. (there is probably a super obvious way to do this). const { supabase } = useSupabase(); const router = useRouter(); const handleLogin = async (event: any) => { // Stop the form from submitting and refreshing the page. event.preventDefault(); const data = { email: event.target.email.value, password: event.target.password.value, }; await supabase.auth.signInWithPassword({ email: data.email, password: data.password, }); const { session } = await supabase.auth.getSession(); if (session) { router.push("/"); } else { alert("User not found"); } };
    r
    t
    +3
    • 6
    • 24
  • running the seed.sql using supabase cli
    v

    ven

    04/21/2023, 9:51 PM
    hi - how do i run the seed.sql that is created on supabase init using the supabase cli?
    n
    • 2
    • 20
  • Auto generate sequential bigint primary id in table
    c

    cptCrunch

    04/21/2023, 10:20 PM
    Is there an extension or maybe I can alter my table to sequentially generate the primary key id of data type bigint:
    Copy code
    sql
    create table
      public.myTable(
        id bigint generated by default as identity not null,
        created_at timestamp with time zone null default now()
    ) tablespace pg_default;
    • 1
    • 1
  • auth help
    d

    duhherro

    04/21/2023, 10:34 PM
    I am currently using SessionContextProvider in my nextjs app and using useSession to see if user is authenticated so they can access pages after login. Does useSession make call to the supabase server or is it verifying the access token locally? cuz I dont know if its a good idea to call useSession everytime I need to see if user is logged in. And I also have a express backend and I want to verify that the user is authenticated too. I am passing in the token from useSession from frontend and using supabase.auth.getUser(token) in express to verify the user but i think this makes a call to the server? can i verify the token locally somehow?
    j
    n
    • 3
    • 5
  • Advanced query
    c

    cptCrunch

    04/21/2023, 11:12 PM
    I have 4 tables that I would like to combine into a single
    select()
    statement.
    Copy code
    Users Table
    -----------
    id
    first_name
    last_name
    
    Clients Table
    -------------
    id
    first_name
    last_name
    
    Agents Table
    ------------
    id
    first_name
    last_name
    
    Inspections Table
    -----------------
    id
    user_id_fkey
    client_id_fkey
    agent_id_fkey
    Rather than returning the id's I would like to return the First and Last Names of each table respectively when I query the Inspections table.
    g
    • 2
    • 14
  • Registering an email/password user who then attempts to sign in with 3rd-party like Google
    i

    InASunshineState

    04/22/2023, 12:25 AM
    If our registration process offers a choice between email/pw or Google Sign-In, and someone does the former first, but then the latter later on, I had read on Reddit that it'd fork into two separate users. However in searching the threads here I saw this:https://github.com/orgs/supabase/discussions/3098 -- is it accurate to say they'll actually be joined? And no problems? In other words, email/pw user has spent a week saving data to their user, then they sign in with social auth and their data is there? If not, what's the best pattern to avoid the message this would cause, not just with empty useless user rows but also having to make a convention to tell them what happened and forcing a sign-out?
    g
    • 2
    • 2
  • Version 1 Still working?
    j

    jon.m

    04/22/2023, 3:40 AM
    I never migrated to V2, but my app is still working. Is this expected? How long will it last.
    g
    • 2
    • 1
  • Unable to filter delete events
    p

    PSully

    04/22/2023, 3:47 AM
    I have the following subscriptions to listen for events and do something with those:
    Copy code
    const subEvent = (event, table) => ({
        event: event,
        schema: 'public',
        table: table,
        filter: `user_id=eq.${user.id}`,
      });
      const on = 'postgres_changes';
      
      supabase
        .channel('any')
        .on(on, subEvent('INSERT', 'daily_foods'), insertDailyFoods)
        .on(on, subEvent('DELETE', 'daily_foods'), deleteDailyFoods)
        .on(on, subEvent('UPDATE', 'foods'), updateFoods)
        .on(on, subEvent('UPDATE', 'user_profile'), updateUserProfile)
        .subscribe();
    I have them being filtered by user.id so the events aren't sent to every single connected client. This seems to be working for all but the
    DELETE
    into
    daily_foods
    . I am still receiving this event on every single connected client. I've tried toggling RSL on or off, but this doesn't seem to change anything at all. (Other than only returning the ID in the
    payload.old
    ). I have also ensured that
    user.id
    is 100% populated. Am I totally missing something here? Can't seem to find anything in the docs that would shed any light on what is going on here for me.
    g
    • 2
    • 7
  • [RESOLVED] How to use new GraphQL like and startsWith filter operators?
    r

    richardoreo

    04/22/2023, 3:59 AM
    I saw this article posted today https://supabase.com/blog/whats-new-in-pg-graphql-v1-2#like-ilike-and-startswith that states that the like, ilike and startsWith operators have been made available. I tried to use it in the GraphQL client locally (got an error) as well as GraphiQL in the dashboard (also error), but I'm not seeing the option in the autocomplete for GraphiQL. And when I manually in put the startsWith operator, I'm receiving this error:
    Copy code
    {
      "data": null,
      "errors": [
        {
          "message": "Input for type StringFilter contains extra keys [\"startsWith\"]"
        }
      ]
    }
    here is my query:
    Copy code
    query Test {
      profilesCollection(filter: {username: {startsWith: "Richard"}}) {
        edges {
          node {
            name
          }
        }
      }
    }
    g
    • 2
    • 13
  • Confusion around deploying supavisor to fly.io
    a

    Apollo

    04/22/2023, 4:11 AM
    I am trying to replace a
    Render.com
    managed Postgres databased with a self-hosted postgres database on fly.io. After learning about supavisor, I want to host this + our db on fly.io. I see in the installation docs (https://github.com/supabase/supavisor/wiki/Installation-and-Usage) a section about deploying fly.io, but it doesn't make sense to me. I have a few questions. 1) I can attach any normal postgres database as a tenant, correct? So I could deploy a normal postgres-ha from fly.io, and connect them to supavisor. Or do I need to do something special? 2) It seems supavisor also needs a postgres database to keep track of tenants, do I attach a db when deploying to fly io, or is it bring your own database? 3) If I deploy supabase via self-hosting (https://supabase.com/docs/guides/self-hosting), how does supavisor integrate? 4) Would it be better to deploy the supabase image of postgres on fly, as shown by @copple here: https://github.com/kiwicopple/postgres-ha/pull/1/files ? I want to deploy most of the supabase stack on fly
  • Sending email via edge function at a date set in a DB record
    f

    Franck

    04/22/2023, 4:40 AM
    Hi there, I'm pretty new to cron jobs and I wondered how I can achieve the following scenario: - My user select a date and time when he wants to send an email. - This date is saved in a table (So far so good) - Then, I want to trigger an edge function that will send the email via sendgrid at the specified date then update the record I'm struggling to understand how I can link the date to the function. Thank you for your help
    g
    • 2
    • 2
  • Serverless API
    v

    ven

    04/22/2023, 5:29 AM
    If Supabase is offering serverless API (https://supabase.com/docs/guides/api) then hosting is logically next? Ideally I would like to deploy my Nuxt app as close to the data as possible. Also I dont see a tag for serverless for posting comments in this channel.
    r
    • 2
    • 3
  • 42501: permission denied for schema public
    h

    Hermanus147

    04/22/2023, 5:55 AM
    Hi everybody I am stuck trying to access a table in Supabase. The table is just a small test table I created in the SQL Editor called Hello. Below is the +page.ts file for accessing the table and the error I get doing so. +page.ts import type { PageLoad } from './$types'; import { redirect } from '@sveltejs/kit'; export const load: PageLoad = async ({ parent }) => { const { session, supabase } = await parent(); if (!session) { throw redirect(303, '/'); } const { data: testTable, error } = await supabase.from('public."Hello"').select('*'); console.log(error); return { testTable, user: session.user }; }; Below is the output of the console.log(error) code: '42501', details: null, hint: null, message: 'permission denied for schema public' And if I console.log(session.user) I get this (not real email) id: '051b831f-59af-4194-9329-2b5f1a9386d2', factors: null, aud: 'authenticated', email: 'me@me.co.za', phone: '', app_metadata: { provider: 'email', providers: [ 'email' ] }, user_metadata: {}, role: 'authenticated', aal: 'aal1', amr: [ { method: 'otp', timestamp: 1682073681 } ], session_id: '55d78ed6-66de-4d87-8f9b-531718188624' In Supabbes I have granted Select privileges to authenticated and anon roles on table Hello. Can anyone suggest something I can still do to get pass this. Cheers
    n
    • 2
    • 4
  • wierd error with offset
    l

    Limuz

    04/22/2023, 6:55 AM
    Hi, i try to fetch some data
    Copy code
    js
        async getPaginatedCustomersRest() {
          try {
            console.log(this.taskCount, this.taskPaginationSize, this.taskPagination);
            const runs = Math.floor(this.taskCount / this.taskPaginationSize / 10);
            const concurrency = 5;
            let tasks = [];
            for (let i = 0; i <= runs; i++) {
              let limit = this.taskPaginationSize * i * 10;
              let offset = limit + (this.taskPaginationSize * 10);
              if (runs === i) {
                offset = this.taskCount;
              }
              tasks.push(this.fillCustomers(limit, offset));
              if (tasks.length >= concurrency) {
                await Promise.all(tasks);
                tasks = [];
              }
            }
            await Promise.all(tasks);
            await new Promise(resolve => setTimeout(resolve, 1000))
          } catch (error) {
            console.error(error);
          }
        },
    with this function
    Copy code
    js
        async fillCustomers(limit, offset) {
          if (limit === 0){
            limit = this.taskPaginationSize
          }
          console.log('fillCustomers', limit, offset);
          const { data, error } = await supabase
            .from('customer')
            .select('*,customer_address(*),customer_contactperson(*)')
            .range(Number(limit), Number(offset))
            .order('id', { ascending: false })
          console.log('fillCustomers', limit, offset);
          if (data?.length) {
            this.allCustomers = this.allCustomers.concat(data as Company[])
          }
        },
    And after some runs, see screenshot but log says limit and offset is alright
    Copy code
    js
    fillCustomers 1250 1500
    customer.ts:98 fillCustomers 1500 1750
    customer.ts:98 fillCustomers 1750 2000
    customer.ts:98 fillCustomers 2000 2250
    customer.ts:98 fillCustomers 2250 2500
    customer.ts:98 fillCustomers 2500 2750
    customer.ts:98 fillCustomers 2750 3000
    customer.ts:98 fillCustomers 3000 3250
    customer.ts:98 fillCustomers 3250 3500
    customer.ts:98 fillCustomers 3500 3750
    customer.ts:98 fillCustomers 3750 4000
    customer.ts:98 fillCustomers 4000 4153

    https://cdn.discordapp.com/attachments/1099227043591364708/1099227043725574144/image.png▾

    • 1
    • 2
  • Generate access and refresh token with session
    e

    EKI

    04/22/2023, 7:40 AM
    We want to generate user's access and refresh token with session, if they pass the custom phone verification. Like we take user input(phone) and send OTP, after OTP verification We create new user from this method supabase.auth.admin.createUser. Now the question is how to generate user's access and refresh token with session with the help of supabase jwt secret.
    n
    r
    • 3
    • 15
  • Realtime Presence on Godot?
    t

    treepumpkin

    04/22/2023, 8:31 AM
    I am using Supabase with Godot (GDScript). I can see that Realtime is supported, but is Presence also supported? There is nothing about Presence in the docs for Godot. Can anyone provide a code snippet?
  • Supabase studio not running in my machine
    e

    eagerashwani

    04/22/2023, 10:25 AM
    Please checkout the below SS. Supabase docs and website runs smoothly but studio not running, it shows some error and after spending 2-3 hours, I’m not able to resolve this issue.

    https://cdn.discordapp.com/attachments/1099279860620349601/1099279860792303626/A7826EC4-FB64-4602-9820-FB18FB281A99.png▾

    r
    • 2
    • 13
  • Request to post major updates in #announcements
    j

    jarnold

    04/22/2023, 1:30 PM
    Is this the right place to request? Looking for something similar to what Mantine UI does in their "releases" channel.
    g
    • 2
    • 1
  • Use upsert to update unique data for each users
    f

    Fyl

    04/22/2023, 1:45 PM
    I have an exchanges table which may contain multiple unique entries per user. In my case, the
    exchange_id
    column must be unique for each user. If the user inserts new data and
    exchange_id
    already exists for this user, the row should simply be updated but never created again. Here is my table definition:
    Copy code
    create table
       public.exchanges(
         id integer not null default nextval('exchanges_id_seq'::regclass),
         user_id uuid not null,
         exchange_id text null,
         api_key text null,
         secret_key text null,
         constraint exchanges_pkey primary key (id),
         constraint unique_exchange_id unique (exchange_id),
         constraint exchanges_user_id_fkey foreign key (user_id) references auth.users (id) on delete cascade
       ) tablespace pg_default;
    and my query:
    Copy code
    js
    const { error } = await supabase
         .from("exchanges")
         .upsert(
           { exchange_id: exchangeId, api_key: api, secret_key: secret, user_id: uid },
           { onConflict: 'exchange_id' }
         )
         .select()
    This works almost fine except it is bound to all users. This makes user Y unable to create an entry if user X already has a row with user Y's exchange_id. Any help is welcome, thanks.
    g
    • 2
    • 3
  • Next.js api routes and supabase : can't insert in database
    f

    Fyl

    04/22/2023, 3:29 PM
    I'm using the Next.js API system to create routes and insert data into my database. Everything worked perfectly until adding policies (to allow insertion only to logged in users). My policies are working (I used the default one in the Supabase template) and to make sure I moved the supabase insert directly into a function on my frontend. This added the entry to my database. So this is not a policy issue but a conflict between Next.js and Supabase. When I disable the policies, my
    /add-exchange/
    API route works and correctly adds the data to my database. Is this a known issue? EDIT: another recent post describe this problem : https://discord.com/channels/839993398554656828/1096835059660636260
    n
    • 2
    • 3
1...188189190...230Latest