https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Database Hooks In Local Development
    d

    drewbie

    10/07/2022, 4:13 PM
    Is there any work arounds to have database hooks enabled in local development? I'm relying heavily on certain database events triggering an http request which is available in the Studio GUI in a live Supabase account. However, in a local development environment, the Studio GUI doesn't show the option for database hooks. I'm wondering if behind the scenes, the live Supabase GUI creates a migration that runs the http postgres extension to fire off your API request after a database event and that if I could create that same migration in my local development setup I could accomplish the same things. Really I just want them to be available locally since my development flow is all local development. Without the database hooks Im sort of flying blind on how those things will behave in production. Any help or suggestions on how to accomplish this would be appreciated!
    s
    • 2
    • 14
  • Cant connect to db using postgres details
    c

    config_wizard

    10/07/2022, 4:52 PM
    When I try and connect to the database directly using psql, I get
    Copy code
    psql: error: connection to server at "db.XXX.supabase.co" (35.176.XXX.XXX), port 5432 failed: Operation timed out
        Is the server running on that host and accepting TCP/IP connections?
    When I try to do it programatically (Go code)
    dsn := fmt.Sprintf("user=%s password=%s host=%s port=5432 dbname=postgres", USER, PASSWORD, HOST)
    It hangs for ages, before I end up receiving:
    Copy code
    failed to initialize database, got error failed to connect to `host=db.XXX.supabase.co user=alex.walker database=postgres`: dial error (dial tcp [64:ff9b::XXX:XXX]:5432: connect: no route to host)
    Interestingly this looks like the cli is using IPV4 and the Go Postgres cli is using IPV6, both failing. I have created the database about 20 minutes ago. I wondered if there is any firewalling going on or something I need to change?
    s
    • 2
    • 2
  • Error in trigger function
    s

    Spartan

    10/07/2022, 5:10 PM
    # tl;dr
    NEW.updated_at := NOW();
    is not working, where
    updated_at
    stores a
    timestamptz
    value. I have this trigger function, where the error seems to happen in the first line. The
    updated_at
    field stores a
    timestamptz
    value, which
    NOW()
    should be, but doesn't seem to cooperate with me. I have tried both
    CURRENT_TIMESTAMP
    and
    NOW()
    and neither seems to work. Does anyone know what might be causing this issue?
    Copy code
    sql
    BEGIN
      NEW.updated_at := NOW();
      UPDATE public.projects 
      SET updated_at = NEW.updated_at 
      WHERE id = NEW.project_id;
      INSERT INTO public.document_contributor (document_id, contributor)
      VALUES (NEW.id, NEW.created_by)
      ON CONFLICT
      DO NOTHING;
      INSERT INTO public.commits (message, created_by, project_id, document_id, created_at, previous_content, current_content)
      VALUES (NEW.note, NEW.updated_by, NEW.project_id, NEW.id, NEW.updated_at, OLD.content, NEW.content);
      RETURN NEW;
    END
    • 1
    • 2
  • Where can I find service key for local development?
    r

    reed

    10/07/2022, 6:02 PM
    I have supabase setup locally (based on the published guide). Where can I find my service key?
    • 1
    • 3
  • Local development invite emails not sending
    h

    Heath

    10/07/2022, 8:29 PM
    I'm using the default
    config.toml
    setup for my local supabase development. With supabase cli, should the invitation emails be coming through to InBucket? We've implemented magic link signin functionality, and the magic link emails do correctly get routed to InBucket, but the invite emails do not. Is this a config thing, by design, or a bug? here is the relevant config that we have
    Copy code
    toml
    [inbucket]
    # Port to use for the email testing server web interface.
    pop3_port = 54326
    port = 54324
    smtp_port = 54325
    
    # ...
    
    [auth.email]
    # Allow/disallow new user signups via email to your project.
    enable_signup = true
    # If enabled, a user will be required to confirm any email change on both the old, and new email
    # addresses. If disabled, only the new email is required to confirm.
    double_confirm_changes = false
    # If enabled, users need to confirm their email address before signing in.
    enable_confirmations = false
  • How do I write a simple join for these tables in v2
    m

    Matt

    10/08/2022, 1:47 AM
    Copy code
    profiles
      user_id (pk)
      username 
      avatar_url
    Copy code
    posts
      post_id (pk)
      user_id
      title
      description
    I want to just get do a select get every post along with the users profile who made the post, but I get error (400) when I try. Just returns null, but this is what the API section says to use.
    Copy code
    let { data: posts, error } = await supabase
        .from('posts')
        .select('*, profiles(*)')
    • 1
    • 1
  • supabase-js v2 Database type creating intellisense issues
    u

    user8923

    10/08/2022, 2:47 AM
    I generate the complex
    Database
    type using the supabase CLI to be used in my Typescript codebase. This ends up creating a massive intellisense headache, as seen in the screenshot below. Is there a better way to work with the Database type? The problem is the same if I create my own type aliases since the Supabase client is not aware of them. It's pretty much impossible to read this function signature.
  • RLS Policy with array
    i

    iLikeBikes

    10/08/2022, 4:28 AM
    Hey all, I have an RLS policy that I am trying to update from a string to an array. Currently it takes one string, but I want it to take a list of strings that map to a column. I have setup using the community custom claims library and my original rls function was setup as
    Copy code
    (get_my_agency() = agency)
    but what I want is something like this
    Copy code
    (agency contains(get_my_agencies())
    is this possible or performnat? https://github.com/supabase-community/supabase-custom-claims
    g
    • 2
    • 2
  • Shouldn't select rls policy be enough to view use from.list() on storage
    r

    rgfx

    10/08/2022, 5:36 AM
    Copy code
    sql
    CREATE POLICY "files images are publicly accessible."
        ON storage.objects
        AS PERMISSIVE
        FOR SELECT
        TO public
        USING ((bucket_id = 'files'::text));
    • 1
    • 1
  • How to set a trigger that sets column value before it inserts
    k

    Karmotrine

    10/08/2022, 7:35 AM
    Here is my code so far. So basically, I expect it to insert the row and put the
    hashid
    value of the serial id but somehow I cannot make it to work.
    m
    g
    c
    • 4
    • 13
  • Email sign-up with supabase-py
    m

    MG95

    10/08/2022, 8:26 AM
    There is no documentation on this so i have no clue how to do it.
    • 1
    • 1
  • Database function as Trigger has null values for new.column
    a

    akshg05

    10/08/2022, 12:07 PM
    Hi All I have used Supabase database functions as triggers before and everything worked correctly. Today while doing it again on a new project I am setting up a trigger with a database function and am trying to access the inserted column value using the new.column syntax. I can confirm my function is triggered and I can even have update queries run successfully when using constants. However when I am trying to use the updated values using the new.column syntax my query doesn't do anything silently and throws no error either. Can someone please help me out here? I am very much stuck.
    • 1
    • 1
  • should i use supabase text search or algolia?
    t

    Thoth Trismegistus

    10/08/2022, 12:45 PM
    I need a basic varchar text search for finding rows from my db. There's textSearch option in supabase
    j
    • 2
    • 44
  • Error error executing command
    a

    aquila

    10/08/2022, 1:51 PM
    Hey, I'm trying to serve a supabase function locally but I keep getting "Error: error executing command". I've restarted the supabase service and recreated the function. Thanks
    • 1
    • 1
  • duplicate a database project
    d

    Duncan

    10/08/2022, 1:51 PM
    Is there any possibility to either duplicate a database/project, or export an existing database and import in a new project? I am using the web gui. But nowher i can find documentation about this. Please help!
    v
    • 2
    • 3
  • Storage adding metadata to files
    r

    rgfx

    10/08/2022, 3:58 PM
    Is this possible, I noticed a column on files.
    Copy code
    Object.assign(file, { test: 'test' });
    Tried this, but it doesn't get passed.
    g
    b
    • 3
    • 4
  • How to return an error from an edge function
    s

    sante | kiftdao

    10/08/2022, 4:08 PM
    I'm trying to handle errors from edge functions correctly on the client. The docs show to return:
    return new Response(err.message, { status: 400 })
    https://github.com/supabase/examples/blob/main/supabase-js-v1/edge-functions/supabase/functions/stripe-webhooks/index.ts Basic edge function:
    Copy code
    const { result } = await request.json();
      console.log(`Testing errors. Result requested: ${result}`)
    
      if (result === "success") {
        console.log('sending success')
        return new Response(JSON.stringify("You got a success"), {
          headers: { "Content-Type": "application/json" },
        });
      } else {
        console.log('sending error')
        return new Response("You got an error!", { status: 400, statusText: "Error" });
      }
    Client:
    Copy code
    const {data, error} = await supabase.functions.invoke("test-errors", {
        body: JSON.stringify({ result: "error" }),
      });
      console.log('Test Result: ', data, error);
    Client result:
    Test Result:  {} null
    Expected result: error to be not null
    • 1
    • 1
  • Invite User To Update Password
    j

    jon.m

    10/08/2022, 5:01 PM
    Hello, I'm trying to build this user flow. 1. admin invites user from Supabase dashboard 2. email is sent to user with a link that prompts them to update their password What I'm having trouble with is sending a magic link in the initial email that will log the user in, so that my form can update their password
    • 1
    • 1
  • Has anyone elses migration from firebase auth not quite worked?
    l

    lewisd

    10/08/2022, 5:26 PM
    Hi guys, ive followed this repo here: https://github.com/supabase-community/firebase-to-supabase It seems to work quite well, I've setup the server on my local machine and if I ping
    localhost:3000/:salt/:hash/:password
    with the right params from my list of firebase users, it comes back
    valid
    , meaning all should be well. After importing my users into supabase auth, attempting to login fails (with password, google sign in works fine). I get an
    AuthApiError: Invalid login credentials
    error
    s
    • 2
    • 3
  • Anybody else having connection issues with the Postgres db?
    m

    Miguel Espinoza

    10/08/2022, 5:40 PM
    Randomly started to get connection attempt failed with Datagrip, so I tried to connect with pgAdmin and getting a timeout expired error. Anyone else experiencing this? Application code is running just fine
    g
    • 2
    • 2
  • problem setting up website dev environment
    r

    Rafael

    10/08/2022, 6:25 PM
    hey y'all! I'm trying to run the development environment for the website, and everything looks ok when I install dependencies, but when I run `npm run dev`I get this error message:
    Error: Cannot find module 'config/postcss.config
    my fork/branch is up-to-date with the master branch. Anyone know why this is happening?
  • bytea? storing dataimagejpeg;base64,9j4AA.... types in columns
    u

    ((()))

    10/08/2022, 8:26 PM
    How would I go about storing "data:image/jpeg;base64,/9j/4AAQSkZJRgABA..." data in columns? I've tried setting bytea type for a column but supabase completely ignores it
    o
    • 2
    • 3
  • Query JSON Column
    b

    B3n

    10/08/2022, 9:55 PM
    I'm trying to query a table where an item in a JSON column is in an array. For example, the JSON in the column is ["1","2"] and the array to compare to is ["2","3"] - this row would therefore be returned because 2 is present. I've tried the following but it doesn't work: .contains('JSON_column', JSON.stringify(my_array)) Any help would be much appreciated.
  • Rapid refreshing breaks all edge functions
    s

    Shane

    10/08/2022, 10:25 PM
    Hi. I have an app with several edge functions. They access the database using the service role key and the supabase-js API. One of them is invoked on page load. If I refresh the page several times in a row, then all of my edge functions will be stuck at "Pending" in Chrome until I either leave the page for a while or close/reopen my browser (which always fixes it). Under normal circumstances, all of the edge functions work normally. Does anyone know why?
  • Read-only transaction error
    c

    courtstarr

    10/09/2022, 12:23 AM
    I am attempting to insert data and get the following error: "cannot execute INSERT in a read-only transaction" I found this via Google https://www.postgresql.r2schools.com/postgresql-error-cannot-execute-in-a-read-only-transaction/ but how do I get access to the files they specify (e.g. standby.signal, recovery.signal) Is my database in recovery mode? It isn't clear via the Supabase UI.
  • Email password reset link leaves error message for user but works fine to validate
    a

    Abnormal

    10/09/2022, 2:08 AM
    Howdy, trying to setup Supabase Auth for my NextJS project and have the base signup form going. When entering a new user credentials(email and password) I'm brought to a page like what is pictured. Its authenticates the account but leaves them on this page, is there a way to redirect users to my homepage, or is this just an error.
    • 1
    • 1
  • User needs to refresh the page to get logged in after third party auth (Supabase, NextJS)
    n

    Nevski

    10/09/2022, 6:10 AM
    Hello everyone, I'm using supabase with next and third party auth. The problem is that my user has to refresh the page to get logged in after using third party auth. I have tried getting the user's data from the client side with supabase methods and useEffect and from the server side with getServerSideProps with supabase methods and sql request but my userState won't update. However I can see the created user token in my localStorage and in the cookies... This problem occurs only online, when I'm on localhost everything is working. When the user is loggin in with email everything is working. I noticed that the token is persisting in the url when I'm on local, but it flashes then diasapear when I'm online. Thanks to anyone who could help.
    n
    s
    • 3
    • 12
  • auth returns null on first call
    s

    Shelby

    10/09/2022, 7:51 AM
    When a user is logged in, db.auth.user() and db.auth.session() both return null initially. I can call it again later and it returns correctly, but not on initial page load. This also ruins nextjs auth helper withPageAuth where redirect to dashboard returns back saying no user but If I refresh the dashboard again sometimes it works and sometimes not. Using nextjs v12 & supbase v1 thanks in advance
    g
    l
    u
    • 4
    • 7
  • querying table columns and types
    i

    ixxie

    10/09/2022, 8:07 AM
    In the JS API, is there a way to ask Supabase what columns and types a table has? I know postgres has
    information_schema
    , so I guess I could initialize a second client using this schema and query that, but I guess maybe that is locked out by default?
    o
    • 2
    • 3
  • Why do I need to provide schema for realtime subs?
    i

    ixxie

    10/09/2022, 8:39 AM
    It seems supabase clients are schema-specific; why do I need to provide the schema a second time when creating a subscription, like in this example from the docs [1]
    Copy code
    js
    supabase
      .channel('public:countries')
      .on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'countries' }, payload => {
        console.log('Change received!', payload)
      })
      .subscribe()
    [1] https://supabase.com/docs/reference/javascript/next/subscribe
    j
    • 2
    • 1
1...404142...230Latest