https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Syntax Error near 'return' when creating function and trigger.
    b

    Brian

    05/18/2023, 5:24 PM
    Does anyone see an issue with this code? I'm attempting to create a function and trigger but getting a syntax error.
    Copy code
    CREATE
    or REPLACE FUNCTION create_signature_code()
    returns trigger as $$
    begin
      UPDATE public.signature_activity
      SET signature_code = '1234'
      WHERE id = new.id
      
      return new;
    end;
    $$ language plpgsql security definer;
    
    create trigger on_new_signature_activity
      after insert on public.signature_activity
      for each row execute procedure public.create_signature_code();
    Failed to run sql query: syntax error at or near "return"
    v
    • 2
    • 3
  • "message": "update or delete on table \"url_data\" violates foreign key constraint \"clicks_url_id_f
    f

    formigueiro

    05/18/2023, 5:48 PM
    Im trying to delete some items but im getting this error. what could do?

    https://cdn.discordapp.com/attachments/1108813485023952996/1108817302650101760/image.png▾

    v
    • 2
    • 6
  • Enable pg_stat_monitor.pgsm_enable_query_plan?
    i

    iano

    05/18/2023, 5:53 PM
    I have some large queries which are being generated by postgrest and are very slow which I am trying to figure out how to optimize. Unfortunately the query is larger than the track_activity_query_size so it gets truncated in the logs and everything. I wondered how I can enable pgsm_enable_query_plan config to have it show me the query plan, or extend track_activity_query_size. This is on hosted supabase
  • Violates Foreign Key Constraint
    c

    cbunge3

    05/18/2023, 6:56 PM
    I have a table ( test_load ) and another called ( test_account ) - within in the test_load table is a column called rtms__Carrier__c that is a UUID of the test_account ID field - so im trying to make a foreign key relationship but i keep getting this error : Failed to run sql query: insert or update on table "test_load" violates foreign key constraint "test_load_rtms__Carrier__c_fkey" i know that this should work but im not sure how to fix this error
    g
    v
    • 3
    • 13
  • Typescript type for supabase client instance
    y

    Yuu

    05/18/2023, 7:27 PM
    I have this error in CI (but not locally): https://github.com/hamza1311/firestorm/actions/runs/5014021366/jobs/8987795179#step:9:189 Can anyone help fix this? The supabase type is https://github.com/hamza1311/firestorm/blob/665a8f10dd0cf8db067670905763013925144479/src/lib/supabase.ts#L21
    o
    • 2
    • 17
  • Connection pooling is default using JS client?
    j

    jinsley8

    05/18/2023, 8:33 PM
    Connection pooling is the default when using the Javascript client correct?
    g
    • 2
    • 4
  • .select('*, clicks(*)') getting empty array
    f

    formigueiro

    05/18/2023, 8:52 PM
    Copy code
    js
      const { data, error } = await supabase
        .from("url_data")
        .select('*, clicks(*)')
        .eq('slug', slug)
        .single()`
    i have items clicks with the same url_data id but its returning []

    https://cdn.discordapp.com/attachments/1108859680815587480/1108859681306325022/image.png▾

    https://cdn.discordapp.com/attachments/1108859680815587480/1108859681646067802/image.png▾

    • 1
    • 5
  • Deleting function from auth schema
    j

    jpow's_printer

    05/18/2023, 9:34 PM
    Can't seem to delete a function I made since it does not show up in database functions and its for the protected auth schema. Tried via the SQL editor but it keeps telling me 'Failed to run sql query: could not find a function named ...'
    g
    • 2
    • 19
  • react native signinwithotp
    z

    zj

    05/18/2023, 9:53 PM
    Hi its my first time on this channel, im using signinwithotp function. Is there a way i can distinguish between a new auth user or an already auth user? Thanks
    g
    • 2
    • 16
  • Is it possible to autoscale Realtime Subscription?
    u

    <hmmhmmhm/>

    05/18/2023, 11:04 PM
    If I use SupaFly to deploy Supabase to Fly.io and then use Auto Scaling, will I be able to use more websockets? Previously, I used Upstash to operate Serverless Redis as much as I needed, But I was wondering if I could auto-scaling the Supabase Realtime Subscription. ( I am currently looking at a distribution tool called SupaFly ) https://github.com/nicholasoxford/SupaFly
    v
    g
    • 3
    • 22
  • With Next.js RSC, do I still need the SupabaseProvider?
    e

    edgaras

    05/19/2023, 12:13 AM
    If I am only using RSC with the new Next.js, do I still need to use client side context to create a SupabaseProvider for the authentication to work?
  • Self-Hosting
    b

    bonglv

    05/19/2023, 12:17 AM
    Dear everyone Self-Hosting: Can Supabase deploy a product, because I try to deploy in docker local, the url is always localhost:3000 and also deploy to vps ip_vps:3000 has no security attached so please ask Is the supabase only at the research level or can be used for real? thank you guys
  • Autosave functionality with forms
    l

    lampaboy

    05/19/2023, 1:16 AM
    Does anybody know if there is a function in Supabase that syncs the form state with the database? The idea is to have it update the db when there is a change of value in the form. I have seen the RLS documentation but it would seem the most suitable function would be using
    postgress_change
    when subscribed to the channel, but that just updates the form when there is a change in db on not vice versa. Thoughts of an own implementation would be to self implement a debounce rate and a mix of
    insert
    and
    upsert
    calls to track the change of the form state before loading it into db
    onChange
    . Doing this with nextJS. Any feedback regarding the implementation or reusable patterns are also much appreciated.
  • Local logs not working for me
    u

    user8923

    05/19/2023, 2:26 AM
    I followed the instructions on https://supabase.com/docs/guides/getting-started/local-development#enabling-local-logging to a T. I created a Google Cloud account (provided CC too, yay...). Sometimes I'm getting a ton of error messages when starting the containers. Sometimes I don't, but there is no log icon in the Studio menu. And I see a bunch of errors in the vector container log (see attached, something to do with being rate limited by Google). I do not do anything else with BigQuery than launching the Supabase CLI, so I'm not sure why I'm being rate limited. https://cdn.discordapp.com/attachments/1108943696038199327/1108943696193404988/message.txt
    v
    • 2
    • 4
  • How to set up query log/audit in local dev?
    u

    user8923

    05/19/2023, 2:49 AM
    Is there a way to see a query log/audit using the local dev Supabase? For example using the pgAudit extension locally?
  • Unable to pull arm64 image for supabase/postgres
    n

    ninjashrimp

    05/19/2023, 6:31 AM
    I'm trying to pull the docker image down for my rpi and it keeps pulling the amd64 image no matter what I try. Anyone else able to pull the correct image for arm based systems? This is what I'm using:
    Copy code
    postgres:
        container_name: postgres
        image: supabase/postgres
        platform: linux/arm64
        healthcheck:
          test: pg_isready -U postgres -h localhost
          interval: 5s
          timeout: 5s
          retries: 10
        command:
          - postgres
          - -c
          - config_file=/etc/postgresql/postgresql.conf
          - -c
          - log_min_messages=fatal # prevents Realtime polling queries from appearing in logs
        restart: unless-stopped
        ports:
          # Pass down internal port because it's set dynamically by other services
          - "5432:5432"
        environment:
          # POSTGRES_HOST: /var/run/postgresql
          # PGPORT: ${POSTGRES_PORT}
          # POSTGRES_PORT: ${POSTGRES_PORT}
          # PGPASSWORD: ${POSTGRES_PASSWORD}
          POSTGRES_PASSWORD: postgres
          # PGDATABASE: ${POSTGRES_DB}
          # POSTGRES_DB: ${POSTGRES_DB}
        volumes:
          - ${STORAGE_ROOT}/data/postgres/realtime.sql:/docker-entrypoint-initdb.d/migrations/99-realtime.sql:Z
          # Must be superuser to create event trigger
          - ${STORAGE_ROOT}/data/postgres/webhooks.sql:/docker-entrypoint-initdb.d/init-scripts/98-webhooks.sql:Z
          # Must be superuser to alter reserved role
          - ${STORAGE_ROOT}/data/postgres/roles.sql:/docker-entrypoint-initdb.d/init-scripts/99-roles.sql:Z
          # PGDATA directory is persisted between restarts
          - ${STORAGE_ROOT}/data/postgres/data:/var/lib/postgresql/data:Z
  • Creating new tables dynamically using javascript
    k

    krzychu

    05/19/2023, 6:35 AM
    Hi folks, as in the title I would like to create new table dynamically using javascript. So for example each user can create a multiple projects on my page. Each project will contain a lot of data. - so I would like to build the logic that if the user clicks create new project button, it creates new table in supabase with table name I provide in the parameters and certain schema. And ideas how do I do it. I appreciate all the help. thanks
    g
    • 2
    • 1
  • FetchError: fetch failed
    j

    Jinni

    05/19/2023, 6:53 AM
    Anyone have an idea wha'ts wrong with my code? I can't seem to make it work

    https://cdn.discordapp.com/attachments/1109011030987780126/1109011031201677414/image.png▾

    https://cdn.discordapp.com/attachments/1109011030987780126/1109011031541420052/image.png▾

    g
    v
    • 3
    • 55
  • FastAPI to combine PostgREST and custom endpoints
    t

    thevelop

    05/19/2023, 7:47 AM
    I'm looking to use a FastAPI application to pass-through specific Supabase PostgREST endpoints I'd like to make available to customers. Furthermore, I'd like to add custom endpoints for the business logic specific endpoints. I'm wondering if anyone has a similar setup and how they solved to following items: - How to combine the openAPI docs created by PostgREST with the endpoint documentation of the custom FastAPI endpoints - How does one use the end-users access tokens to also make sure RLS/Auth keep functioning as when directly interacting with PostgREST - How does one use Supabase Auth for the custom FastAPI endpoints - Preferred way of linking FastAPI and Supabase (direct DB sessions or going through PostgREST) Eager to hear any idea's or experiences with similar setups!
  • how to import npm package types on edge functions?
    m

    milly

    05/19/2023, 8:04 AM
    If I import types like this: //@deno-types="https://esm.sh/@types/express"; supabase showing error: error: Relative import path "stream/promises" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v122/@types/node@18.16.9/stream/promises.d.ts" If you want to use a built-in Node module, add a "node:" prefix (ex. "node:stream/promises"). at https://esm.sh/v122/@types/node@18.16.9/stream/promises.d.ts:42:19
    g
    • 2
    • 1
  • Issues with Supabase's Role Functionality and RLS Feature
    a

    Akkilah

    05/19/2023, 9:09 AM
    I have come across numerous discussions on Discord and GitHub regarding Supabase's role-based user access. It appears that Supabase has indeed implemented a role system, which can be utilized in their Row-Level Security (RLS) feature. However, ,it seems that the role functionality is not functioning as expected. I am wondering if I may have overlooked any crucial steps or requirements. Could you kindly advise if there is anything I might be missing in order to properly utilize Supabase's role-based user access? First, I created a role named 'webadmin' within the Supabase dashboard, accessible at https://app.supabase.com/project/_/database/roles. Next, I proceeded to create Row-Level Security (RLS) for a specific table. Subsequently, I executed the following SQL command to update the role of the desired user:
    Copy code
    UPDATE auth.users
    SET role = 'webadmin'
    WHERE email = 'akxxxxxx@gmail.com';
    Additionally, I granted the 'webadmin' role to the 'authenticator' user by executing the following command: GRANT webadmin TO authenticator; So can i have any advice ?

    https://cdn.discordapp.com/attachments/1109045181711384606/1109045181908529192/1.PNG▾

    https://cdn.discordapp.com/attachments/1109045181711384606/1109045183334580254/2.PNG▾

    h
    g
    v
    • 4
    • 39
  • Table Versioning Control
    t

    tgps26

    05/19/2023, 9:49 AM
    Hi guys, In our Startup we want to create a small database to be used by tech and non-tech people. Could you help me clear out some doubts regarding databases in Supabase? - is the UI friendly for a non-tech person to make changes into a cell? - 3 different people in the org may be changing different parts of the table. Since different kind of people will be changing the table, it'd make sense to have separate "safe" tables where they can make their changes (independently), and then merge it into production. What's the approach you recommend? - is there a log for changes in a certain table? We use SQL but we're not used to managing a SQL database for envs (prod / stage /etc) bc we've been using firebase since 2019. Thanks in advance! 🙂
  • Create cron job programmatically
    w

    ws

    05/19/2023, 10:05 AM
    Hi, Is it possible to create a cron job from client or edge function ? I tried with database function but I get Invalid SQL query

    https://cdn.discordapp.com/attachments/1109059316759134218/1109059317501546516/image.png▾

    g
    b
    s
    • 4
    • 23
  • signInWithOTP auto login
    z

    zj

    05/19/2023, 12:14 PM
    Hi, im using signInWithOTP and i want to auto login without having to receive a code each time. In the previous login page i used password so i managed to store the details of the user as asyncstorage with react native and re log him automotaicaly. Now i moved to signInWithOTP. Is there a way i can have a similar approach pleasE? const { data, error } = await supabase.auth.signInWithPassword({ email: loginDetails.email, password: loginDetails.password, }); if (data.session) { dispatch(setSessionToken(data.session.access_token)); dispatch(setUserID(data.user.id)); setIsSocketConnected(true); }
    g
    • 2
    • 14
  • Using RPC to hide table name
    e

    EKI

    05/19/2023, 12:22 PM
    So I don't want my frontend developer to know the table name. Is it a good idea to use rpc to perform basic actions like select, insert, update and delete. Will it have any impact on performance?
    g
    • 2
    • 3
  • How change the mail templates on self hosted?
    t

    TheRien

    05/19/2023, 12:37 PM
    I know the regular mail template settings are not available from the self-hosted Supabase Studio. But I can't find anywhere what makes those emails either. Is there any way of changing those mail templates whatsoever?
    v
    g
    • 3
    • 13
  • Inserting ID of an authenticated user automatically
    m

    murko

    05/19/2023, 12:42 PM
    Hey guys, a new Supabase user here. I'm stuck with the following issue: I have a table called
    connections
    with the following structure:
    Copy code
    table connections
    
    id  |  user_id  | data
    where
    user_id
    is a foreign key pointing to
    auth.users.id
    . Now I want to insert a new record via Javascript to the
    connections
    table (it's only possible when the user is authenticated):
    Copy code
    js
    const { data, error, ...rest } = await supabase
      .from("connections")
      .insert({
        data
      })
    What I would like to happen is that
    user_id
    would be inserted automatically based on the currently authenticated user - basically just inserting
    auth.uid()
    . Unfortunately, I can't figure out how to achieve that without me manually passing the data in the payload like so:
    Copy code
    js
    const { data, error, ...rest } = await supabase
      .from("connections")
      .insert({
        data,
        user_id: supabase.getSession().session.user.id
      })
    which doesn't seem right... I was thinking of creating a trigger that adds the
    user_id
    after the connection record is created but I don't know how to retrieve the currently authenticated user's ID in a trigger. Any help would be highly appreciated! Thank you!
    t
    e
    g
    • 4
    • 29
  • exclude _timescale schemas from supabase
    t

    Tinog

    05/19/2023, 12:56 PM
    Hi, i'm currently try to setup supabase (self hosted via kubernetes) on our existing database project. we are using timescale and have a lot of bucket tables. in fact so many that the database -> table dashboard does not load due to a timeout. is there a way to tell supabase that it should exclude certain schemas and/or tables?
  • signInWithOTP
    z

    zj

    05/19/2023, 1:05 PM
    How do i get an access token that doesnt expire to auto login a user after closing the app using signInWithOTP please?
    g
    • 2
    • 1
  • Preventing resource exhaustion by malicious client queries
    c

    Crembo

    05/19/2023, 2:24 PM
    Hi folks, since Supabase basically lets you send freeform SQL from a browser, how do I stop a user from trying something silly like a
    cross join
    between a pair of million row
    generate_series
    -es and crashing the server due to RAM/disk exhaustion?
    g
    n
    • 3
    • 9
1...219220221...230Latest