https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • How to export remote database?
    k

    Kellen Mace

    03/16/2023, 7:01 PM
    I'm trying to follow along with this docs page (https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#migrate-your-project) to export my database. When I run one of the db dump commands, like:
    Copy code
    supabase db dump --db-url "postgresql://postgres:MYPASSWORD@db.krpyriciwjyezbzvkmjo.supabase.co:5432/postgres" -f schema.sql --debug
    (replacing
    MYPASSWORD
    with the actual password for the postgres user) ...I get this:
    Copy code
    Dumping schemas from remote database...
    Error: Error running pg_dump on remote database: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    Two questions: 1. When the docs say to use the "database URL" is this what they mean? Am I supposed to use the full
    postgresql:// (etc.)
    connection string? 2. What am I doing wrong? Why can't I connect to the remote database? I have the latest versions of psql, pg_dump and the supabase CLI installed, and I've been able to export my database in the past using the old method in the docs of setting the postgres user as a SUPERUSER, then running a pg_dump command to dump the database.
    o
    s
    • 3
    • 38
  • Has the 'generate and download types' option been removed?
    t

    titongo

    03/16/2023, 7:27 PM
    I want to use types but the option to download them seems to be gone and only CLI is usable. I don't have docker installed and all I want from the CLI is the types. Is there anything I can do?
    o
    b
    s
    • 4
    • 8
  • subscribe or removeChannel
    m

    Mindrest

    03/16/2023, 8:30 PM
    Hello, according to the documentation found on supabase, if you want to dispose of an instance you'd most likely do an
    .removeChannel(someChannel)
    What's then
    myChannel.unsubscribe
    used for then? in which cases is better to use
    unsubscribe
    instead of the other option?
    g
    k
    • 3
    • 3
  • Help with RLS
    c

    Creix

    03/16/2023, 8:42 PM
    Hello, I'm trying to find a way to implement RLS on my project. It is a event ticketing app where organizers can create new event and user can buy tickets. For the organizers I also have an app used for scanning tickets at the entrance, I'm doing a login using the eventID and a password set by the organizer through a rpc function. Once logged I need to get tickets from supabase (also with a realtime subscription) and update ticket status. Is there a way to implement RLS in some way or I necessarily need to login through supabase auth?
    o
    • 2
    • 17
  • Supabase x Doppler - Does this prevent exposing the API keys on the frontend?
    v

    Vik

    03/16/2023, 9:37 PM
    This article was posted and retweeted by the Supabase account and I'm curious on how it works. Does this prevent exposing the keys on the front end? https://twitter.com/doppler/status/1636377902244847616?s=20
    s
    • 2
    • 1
  • NEXTJS API - Supabase server client RLS
    c

    codecoolkid

    03/16/2023, 9:49 PM
    Hello Supabase team, my question is how to setup in the API layer on Nextjs the server client respecting the RLS of the tables more context in this thread
    g
    • 2
    • 16
  • NextJS: App with ~30 tables, to RLS or not RLS?
    s

    shane

    03/16/2023, 10:33 PM
    I'm building an app in NextJS with a pretty big database structure up to now (~30 tables or so). These include users (with a high level app specific user_roles table to control in app access to features), teams (with a team_roles table), and different types of components that users can create based on their team etc. After doing some research, setting up a lot of complicated policies to deal with RLS and who gets to edit/delete/create what seems like it would be very complicated and time consuming to manage across the whole application. The other option is to simply enable RLS on all tables by default with no policies and have all supabase calls from within server components (I'm using the app directory) - however, with RLS enabled, and my server client setup to use the service role key - no data is being returned. Turning off RLS does allow the data to be returned (as one would expect). Any reason as to why this would be the case? I thought using the service role key bypasses all RLS policies. Thanks!
    g
    n
    • 3
    • 26
  • Has there been a change in Postgres log?
    a

    AlanK

    03/16/2023, 10:54 PM
    I have added a raise log line to my function
    Copy code
    raise log 'var_where_clause = % ', var_where_clause;
    When I go to Logs/Postgres there is 'No Results' - like no logging at all. Have I missed something? Or have I got it wrong?
    g
    f
    • 3
    • 46
  • Supabase CLI local dev
    p

    pan_cheta

    03/16/2023, 11:08 PM
    Hey all! I've been fighting with trying to get local dev working on and off for months now and I can't seem to figure out what's going wrong. The main caveat I have is that I use podman rather than docker. I followed the steps here to run docker-compose with rootless podman (which got me past my initial blockers): https://fedoramagazine.org/use-docker-compose-with-podman-to-orchestrate-containers-on-fedora/ But whenever I run "supabase start" I get an error that the "Database is unhealthy...connection reset by peer" and subsequent containers don't start. Has anyone been able to get the CLI working with podman for local dev? Any help would be appreciated as I'm at a bit of a loss. Not sure if it's a configuration issue or maybe the health check retries expire before my container is ready. Thanks!
  • API key for local dev deployments
    s

    SmoothBot

    03/16/2023, 11:28 PM
    ... solved it. I found the anon_key
  • Postgres Memory
    l

    louis77

    03/16/2023, 11:47 PM
    How much memory and CPU does the Postgres database have available?
    g
    • 2
    • 1
  • Looking for guidance on securing API keys on the server and requesting when needed in React Native.
    v

    Vik

    03/17/2023, 1:02 AM
    If anyone has gone through this before I would love some guidance on how you did it and your approach. Essentially I have a Google API key that I need to secure that's used for location search. What would be the best way of securing this? I know Supabase secrets exists but is this the way to go?
  • Storage bucket - cannot read properties of undefined (reading 'from')
    v

    Vince

    03/17/2023, 1:03 AM
    I created a bucket called
    photos-bucket
    and I wrote the following logic:
    Copy code
    let { error: uploadError } = await supabase.storage
            .from('photos-bucket')
            .upload(filePath, file, { upsert: true });
    But I get the error that it cannot read properties of undefined? It looks like
    supabase.storage
    is undefined but why is this the case?
    g
    • 2
    • 2
  • I don't understand how to update data
    b

    Bigmancozmo

    03/17/2023, 1:54 AM
    I looked at the example,
    Copy code
    js
    const { error } = await supabase
      .from('countries')
      .update({ name: 'Australia' })
      .eq('id', 1)
    and I'm confused. Is .update updating the data, or telling it what data to update? Same with .eq. What I want to do is change this (first image) to this (second image) with my code, but I don't understand how to. Also, sorry if I put this in the wrong tags, I don't really understand much.
    g
    • 2
    • 24
  • Different results using same embeddings Supabase (pgvector) vs Pinecone
    k

    KitKat

    03/17/2023, 6:05 AM
    Hi there! I'm currently in the process of building a tool with Langchain and I decided to run some benchmarks on vector stores. Interestingly, I found that there were significant differences in the results between Supabase (using pgvector extension) and Pinecone. Pinecone's results were much more accurate, but I'm not exactly sure why. I'm wondering if this could be due to Supabase not being as performant as Pinecone. As someone been benchmarking those tools or do anyone know the reasons behind this ? (to note, i've also created index using pg-vector in supabase and that help for speed for not for the quality of the results, the cosine distance seems not to been calculated the same way at tall)
    n
    s
    s
    • 4
    • 16
  • Create an API request in edge function
    m

    moxdisboss

    03/17/2023, 6:33 AM
    I was able to deploy an edge function that calls on a random joke generator api and logs it in the console. For some reason my post requests after deploying are not being seen by the edge function and its not logged in logs or invocations.
    u
    • 2
    • 7
  • Limit allowed rows per user
    j

    joni.giuro

    03/17/2023, 8:53 AM
    Hi, I have a an "anomalies" table, I always fear that if something goes wrong in the frontend I might end up with a thousand requests to create an item in the table, how can I make sure this doesn't happen? I thought about limiting the allowed amount of entries per user with RLS, is this possible?
    n
    g
    • 3
    • 5
  • Can not automatically update user email from Github OAuth
    u

    0xAA

    03/17/2023, 9:03 AM
    We use supabase to host Github OAuth of our website. We have a problem: 1. when the user login on our website for the first time, we get the github id and email of the user. 2. the user changed the main email on github 3. when the user login again on our website, the email is not updated to the new github email. How to solve this? Is there any code snippets? Thank you!
    r
    • 2
    • 1
  • Redirect immediately after auth
    t

    TomCarnay

    03/17/2023, 9:29 AM
    hi, in my app a user authenticates and then if its the first time they are taken to a profile page. if the user has already authenticated and entered profile info previously, I want the profile page to automatically route to the home/search page. If I do this with client-side code, its not great - a but slow with a few screen flickers. I tried to do with getserversideprops with some automatic routing like this: export async function getServerSideProps( ctx ) { const supabase = createServerSupabaseClient(ctx) const { req, res } = ctx; const { data: {user} } = await supabase.auth.getUser() if ({user}) { const { data, error } = await supabase .from('profiles') .select('created_at') .eq('id', user.id); if (data) { res.setHeader('Location', '/search'); res.statusCode = 307; res.end(); return { props: {} }; } return { props: {} }; } else { res.setHeader('Location', '/'); res.statusCode = 307; res.end(); return { props: {} }; } } user seems to be null during the auth flow - e.g. directly after authenticating using the Auth component (I think there is a similar issue if using withpageauth right after the Auth redirect). However, if I go back to the profile page once already logged in - the code works fine. Is there an issue in doing this when there is a redirect from the Auth component?
  • RLS access for authenticated users not working with magic link auth?
    j

    jimbo123

    03/17/2023, 10:20 AM
    Im accessing my table from the client with:
    supabase.from("designs").select("name");
    As a test I used the default RLS policy of "Enable read access for all users" and it works. But I actually want to restrict access to logged in users. I made this policy but now the client gets an empty array instead of table data:
    Copy code
    CREATE POLICY "Enable select for authenticated users only" ON "public"."designs"
    AS PERMISSIVE FOR SELECT
    TO authenticated
    USING (true)
    I used the email magic link authentication method. With the
    useUser
    hook I can see the user is authenticated (I can see the ID, email address, etc). Im brand new to Supabase. Any help debugging this would be much appreciated.
    • 1
    • 1
  • Can't do anything after signing up, what's up?
    i

    itsnftsergio

    03/17/2023, 10:25 AM
    I signed up and can't perform any action. I confirmed my email address and still get unauthorized for every action I do. I can't even create a support ticket. Tried creating a new account with Github signup and I have the same issues, need this fixed asap.
    g
    • 2
    • 1
  • Is there a way to resize an image into multiple versions before uploading to a bucket?
    e

    Entropy

    03/17/2023, 10:36 AM
    When a user uploads a profile banner I want to take that image and split it into three images that are small, medium, and large. So when I make request for their banner my database just returns an object with the urls to the three different versions. Is this possible with supabase or would I have to use a 3rd party package to do this?
    r
    • 2
    • 4
  • What will happen if supabase instance fails?
    l

    lflserg

    03/17/2023, 11:55 AM
    How supabase supports instance failures and how much involvement is needed?
    • 1
    • 1
  • setSession not persisting on server
    b

    b600

    03/17/2023, 12:48 PM
    Hi all. I'm trying to use Supabase with Qwik City and I want to create a server client on request, kind of like the Supabase auth helpers do with other full-stack frameworks. I'm using the code from the server-side rendering part of the docs to save the cookies under the website's domain so the server can access it. On request, I've been able to get these cookies and successfully call
    setSession
    , which validates everything and seems to give a proper response. However, when immediately calling
    getSession
    after setting the session it seems like the session was never set. Here is the code I'm using and the corresponding output:
    Copy code
    const supabaseClient = createClient(import.meta.env.VITE_SUPABASE_URL, import.meta.env.VITE_SUPABASE_ANON_KEY)
    const refreshToken = cookie.get("my-refresh-token");
    const accessToken = cookie.get("my-access-token");
    
    if (refreshToken && accessToken) {
      const res = await supabaseClient.auth.setSession({
      refresh_token: refreshToken.value,
        access_token: accessToken.value,
      });
    console.log("Validated token when initializing client >>> " + JSON.stringify(res.data.session?.access_token))
    console.log("Getting the new session right after >>> " + JSON.stringify(await supabaseClient.auth.getSession()))
    }
    Output:
    Copy code
    Validated token when initializing client >>> "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjc5MDU4NTI5LCJzdWIiOiJiNjIyMTY2Ny1hZGQ2LTQ2YWEtOWM1Ny0xOTNlNjMyNmIzMWUiLCJlbWFpbCI6ImZvb2Zvb0BiYXJiYXIuY29tIiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6e30sInJvbGUiOiJhdXRoZW50aWNhdGVkIiwiYWFsIjoiYWFsMSIsImFtciI6W3sibWV0aG9kIjoicGFzc3dvcmQiLCJ0aW1lc3RhbXAiOjE2Nzg5NjI5MTh9XSwic2Vzc2lvbl9pZCI6IjhhMWIzYjNjLWYxMmMtNDcwYy05MDg0LWRhZDZkYjlkMGE2YiJ9.ehZMXCMa_FVmY1kXdLkNlkorbVw1ghKJpEWWxEnPYzQ"
    Getting the new session right after >>> {"data":{"session":null},"error":null}
    Thanks for your help! I'm very confused by this
    g
    o
    • 3
    • 4
  • Best way to handle sign out
    c

    chrtravels

    03/17/2023, 1:09 PM
    Hello! I noticed that the only thing the signout method does is to remove the session token from the browser. So if I sign out from the profile page, I am still left on the profile page, until I reload or navigate elsewhere. Clicking signout "should" bring you back to the login page. If I use an event handler and route to "/". That would bring you back to the login page because I have middleware that will handle that. However, I would need to use a setTimeout since there is a bit of a delay before the session token is fully removed. Is there a better way to handle that? One would think that the supabase function would take care of the full sign out process. The NextJS tutorial says to use it on a button like this:
    Copy code
    <button className="button block" onClick={() => supabase.auth.signOut()}>
    However the docs for sign out show that we should use await:
    Copy code
    const { error } = await supabase.auth.signOut()
    supposedly it is supposed to trigger a sign out event but nothing visibly happens. Thank you!
    r
    • 2
    • 2
  • createServerSupabaseClient with service key
    k

    kompiledstore

    03/17/2023, 1:49 PM
    createServerSupabaseClient is using NEXT_PUBLIC_SUPABASE_ANON_KEY by design (on nextjs helpers) is there any way to bypass this?
    r
    • 2
    • 3
  • migration phone auth schema error
    s

    SparK

    03/17/2023, 2:53 PM
    hi! I'm having this error: running db migrations: error executing migrations/20230116124310_alter_phone_type.up.sql, sql: -- alter phone field column type to accomodate for soft deletion alter table auth.users alter column phone type text, alter column phone_change type text; : ERROR: cannot alter type of a column used by a view or rule (SQLSTATE 0A000) and I cant login to my app, how could I fix this? thanks!
    g
    • 2
    • 2
  • Get Authentication Data With SQL
    m

    MATTI

    03/17/2023, 2:56 PM
    Is it possible to get data from authentication using the SQL on the supabase platform?
    g
    • 2
    • 5
  • RLS policy on joint table doesn't work
    b

    bencehusi

    03/17/2023, 3:01 PM
    I've checked this resource https://supabase.com/docs/guides/auth/row-level-security#policies-with-joins and tried to recreate it, but it always returns zero values. My tables in public: - profiles (which equals auth.user.id, so auth.uid() should match this id) - teams - team_users (join table for the two above with user_id and team_id) My policy on the
    teams
    table should allow authenticated users to retrieve teams they belong to: My USING expression is the following:
    Copy code
    pgsql
    id IN (
      SELECT user_id
        FROM public.team_users tu
        WHERE tu.user_id = auth.uid()
    )
    What is wrong with this expression? Why does it return zero results while my user clearly belongs to two teams?
    g
    • 2
    • 25
  • How can I create a seed.sql file from a local database?
    r

    ryanwelcher

    03/17/2023, 3:35 PM
    I am creating a local development env with a fair amount of data and I'd like to export it to a seed.sql file. The docs say to use
    supbase db export
    but that command doesn't seem to exist. Any help would be greatly appreciated!
    n
    r
    s
    • 4
    • 8
1...170171172...230Latest