https://supabase.com/ logo
Join Discord
Powered by
# help
  • d

    DarrenJr

    12/12/2021, 7:49 PM
    Anyone know if there is a way to delete all rows in a table? instead of using .delete.match()
    g
    • 2
    • 3
  • c

    codesalim

    12/12/2021, 7:58 PM
    Thank you, cheers
  • g

    garyaustin

    12/12/2021, 8:03 PM
    delete all rows
  • u

    ulisses

    12/13/2021, 12:04 AM
    Hello. I created this function to run on a trigger after a user signup. But, I'm receiving an error (Database error saving new user) when I try to signup. The request:
    Copy code
    js
        const result = await supabase.auth.signUp({ email, password }, {
          data: { type: 1 }
        })
    The function:
    Copy code
    sql
    CREATE OR REPLACE FUNCTION create_profile_for_user() 
      RETURNS TRIGGER AS $body$
        BEGIN
          IF (NEW.raw_user_meta_data->>'type')::integer NOT IN (1, 2, 3) THEN
              RAISE EXCEPTION 'Invalid account type %', NEW.raw_user_meta_data->>'type';
          END IF;
    
          INSERT INTO public.profile (id, type)
              VALUES (NEW.id, (NEW.raw_user_meta_data->>'type')::integer);
    
          return NEW;
        END;
      $body$ LANGUAGE plpgsql;
    Can someone help me debug the function?
  • g

    garyaustin

    12/13/2021, 12:24 AM
    You probably at least need "security definer" in the function especially if your public profile table has RLS on.
  • k

    kroket

    12/13/2021, 3:26 AM
    try this
    Copy code
    sql
    CREATE OR REPLACE FUNCTION create_profile_for_user() 
      RETURNS TRIGGER AS $body$
        BEGIN
          IF (NEW.raw_user_meta_data->>'type')::integer NOT IN (1, 2, 3) THEN
              RAISE EXCEPTION 'Invalid account type %', NEW.raw_user_meta_data->>'type';
          END IF;
    
          INSERT INTO public.profile (id, type)
              VALUES (NEW.id, (NEW.raw_user_meta_data->>'type')::integer);
    
          return NEW;
        END;
      $body$ LANGUAGE plpgsql security definer;
  • u

    ulisses

    12/13/2021, 9:02 AM
    thanks @User and @User, it worked!
  • e

    egnus

    12/13/2021, 10:08 AM
    Hello people, I am trying to connect Cloudinary with their new service "Media Optimizer" as a proxy or a web adress mapped to a supabase public storage. However, despite all the direct calls works, when proxied, all calls fails with 400 and unable to find the resource, I think this is due to how "Cloudflare" provided by the storage restrict the calls to them. Did someone found a workaround for this?
  • d

    dcuk89

    12/13/2021, 11:04 AM
    Anybody know how to log out from a protected route? If I use the normal supabase.auth.signOut() I can still access the protected route 🤔
    s
    m
    • 3
    • 3
  • s

    silentworks

    12/13/2021, 11:53 AM
    Logging out
  • t

    TremalJack

    12/13/2021, 1:19 PM
    Hello, I have a little question about the docker configuration: The docker conf work with images, changing a lil bit the configuration of docker-compose.yml, applying a name of volume is pretty simple avoid the "reset" of database data, in this way what we made like tables and rows will persist into Database. But... doing this will be always an issue go to update the schemas if will be released an update on DB schemas configurations. Why don't use directly the migration system? Someone is already handling an situation like that?
  • t

    TremalJack

    12/13/2021, 1:22 PM
    Personally I made a "maintenance" script to make and restore an DB but... in case of changes of schemas ect at the moment of restore the DB will get errors because the schema applied would be the old
  • t

    TremalJack

    12/13/2021, 1:24 PM
    so... therefore in anticipation of this problem Im here to ask help, to know if someone have already handled this scenario or if is any way to get migrations and apply them
  • k

    kroket

    12/13/2021, 1:26 PM
    well it happens to me too, i don't know why. this is my solution, though i don't know it's a real solution or not just add this code after the signOut
    Copy code
    js
    localStorage.removeItem("supabase.auth.token");
  • j

    jjj.westra

    12/13/2021, 2:42 PM
    Hey; does anyone know something about the twitter and facebook auth? for twitter I get this message after the redirect:
    Copy code
    {
      "message": "no Route matched with those values"
    }
    For facebook, it redirects correctly but is not logged in; the log says:
    Copy code
    error: server_error
    error_description: Unable to exchange external code: AQBQUHP_BLABLABLA.LONGCODE
  • j

    jjj.westra

    12/13/2021, 2:42 PM
    Everything is configured correctly afaik
  • t

    TremalJack

    12/13/2021, 2:50 PM
    @User
  • m

    Muphet

    12/13/2021, 4:45 PM
    i can't understand how relationships are supposed to work. how do i make a table rows reference user? i can't make foregin key because it requires to be unique, but it cannot be unique in my case
    t
    • 2
    • 31
  • m

    Muphet

    12/13/2021, 4:45 PM
    imagine u have table of posts and each post has "added_by". if it was unique, each user could make only one post
  • m

    Muphet

    12/13/2021, 4:46 PM
    so i dont get it
  • s

    Scott P

    12/13/2021, 5:05 PM
    Postgres relations
  • j

    jbergius

    12/13/2021, 7:07 PM
    Having problems with users that forgot that they already created an account, and tries to create a new account with the same email. Have been reading around on different GitHub threads about this and discovered that I'm not the only one having this problem. Regarding to this post: https://github.com/supabase/supabase-js/issues/296#issuecomment-976200828 it says that the users should get an account recovery email, but that isn't working for me. Is someone else having the same issue?
  • d

    DevilsBlade0

    12/13/2021, 9:18 PM
    Hey guys, was wondering if any kind soul can help, I’ve created a one way relation between profiles (using the snippet) and manually created another table called customers where it shares a foreign key uuid with profiles. In react, I have a state, customers and set customers initiated as an empty array . I get the data back from the db, but it comes back as an object which I can use to map into components, can anyone point me into the right direction? Thank you 🙏🏽
  • d

    DevilsBlade0

    12/13/2021, 9:25 PM
    Am following the NextJs todo list, which shares the same logic, only diff I’ve created the table using the UI and not the sql snippet (which doesn’t have any array specification)
  • d

    DevilsBlade0

    12/13/2021, 9:31 PM
    Nvm, a very rookie mistake from my side, been on Supra base from morning and I just love the power it gives you, guess I need some sleep
  • w

    wiesson

    12/13/2021, 10:12 PM
    Is there a guide how to migrate users from firebase/firestore to supabase? Created users with
    Copy code
    supabaseAdmin.auth.api.createUser({
        email: authUser.email,
        data: {
          ...firebaseUserData
        }
      })
    I checked https://supabase.com/docs/reference/javascript/auth-api-createuser but the docs only mention a "name" field? I checked the Typescript types as well, but I still don't know where I should add. the phone number. It also looks like, the mentioned data object doesn't work at all (at least I can't find it in the db)
  • k

    kennethcassel

    12/13/2021, 10:39 PM
    Is there a way to use storage without using the auth.users table?
  • a

    Ant

    12/14/2021, 1:44 AM
    hey man can you open this in our discussions, https://github.com/supabase/supabase/discussions and tag "@inian"
  • s

    Sophic

    12/14/2021, 3:39 AM
    For supabase auth settings I set my jwt expiration to
    604800
    on supabase auth settings. However, the session I am getting back still has an
    expires_at
    and
    expires_in
    as if it were
    3600
    I may just be missing something. I was however using those values to determine when to call
    refreshSession
  • k

    kroket

    12/14/2021, 5:27 AM
    did you set the value there?
1...158159160...316Latest