https://supabase.com/ logo
Join Discord
Powered by
# sql
  • p

    Peanut

    08/27/2021, 1:37 AM
    Yes:
    Copy code
    CREATE POLICY "Everyone can read all users."
        ON users
        FOR SELECT USING (
            true
        );
  • p

    Peanut

    08/27/2021, 1:38 AM
    So I need to allow the
    authenticated
    role to UPDATE the users table?
    j
    • 2
    • 22
  • p

    Peanut

    08/27/2021, 1:38 AM
    Because I have RLS on all tables wouldn't it be easier to just let them UPDATE all tables and rely on RLS to protect them?
  • b

    bim

    08/27/2021, 3:30 AM
    If i create an index on a user id column in a table with a RLS policy that only allows a user to read their own data, would the RLS policy leverage the index, or would I need to need to add in a
    where
    clause to take advantage of the index?
  • p

    Peanut

    08/27/2021, 6:57 AM
    How do I delete all table policies?
  • p

    Peanut

    08/27/2021, 7:06 AM
    Just came up with this script:
    Copy code
    SELECT format('DROP POLICY IF EXISTS "%s" ON %s;', policyname, tablename)
    FROM pg_policies WHERE schemaname = 'public';
  • p

    Peanut

    08/27/2021, 7:28 AM
    Another script to delete all functions:
    Copy code
    SELECT
        format('DROP FUNCTION IF EXISTS %s;', p.proname)
    FROM
        pg_proc p
        LEFT JOIN pg_namespace n ON p.pronamespace = n.oid
    WHERE
        n.nspname = 'public'
  • p

    Peanut

    08/27/2021, 7:41 AM
    Does anyone have any good suggestions for using RLS with views?
  • k

    kennethcassel

    08/27/2021, 4:52 PM
    is there a way to restrict what type of file extensions can be uploaded to a bucket?
    b
    • 2
    • 1
  • t

    tomjohn | Designer

    08/27/2021, 5:57 PM
    Is there any site out there that has SQL templates that could be used in common situations? I'm doing some research for a project a basedash to have premade queries that could be used with connected databases, and I figured the community here would know if that existed.
    b
    • 2
    • 6
  • b

    burggraf

    08/27/2021, 6:17 PM
    Restricting file extensions
  • b

    burggraf

    08/27/2021, 6:18 PM
    SQL Templates
  • s

    Steve

    08/27/2021, 8:50 PM
    Check this previous discussion: https://github.com/supabase/supabase/discussions/901#discussioncomment-500895
  • p

    Peanut

    08/28/2021, 1:18 AM
    Thanks! Awesome!
  • r

    RichCorbs

    08/28/2021, 2:06 AM
    I renamed some tables and columns and updated my queries but now the relationships are duplicated and I'm being told to disambiguate the query. I'd rather get rid of the duplicated relationships. Any ideas? I don't even know what to search for.
  • r

    RichCorbs

    08/28/2021, 2:20 AM
    I've completely deleted and recreated the table and still get the errors.
  • a

    assistattow

    08/28/2021, 2:40 AM
    I'm getting an issue with the row level security where I can't delete the user data even though it checks their user id
  • r

    RichCorbs

    08/28/2021, 2:40 AM
    It's weird. I was "aliasing" like
    my_name:original_name
    . When I removed the alias it started working.
  • r

    RichCorbs

    08/28/2021, 2:41 AM
    Wish I could help @User . I haven't gotten to RLS yet. Good luck!
  • a

    assistattow

    08/28/2021, 2:43 AM
    It actually isn't too complicated atleast with what I'm doing but thats what confuses me
  • a

    assistattow

    08/28/2021, 2:44 AM
    it should work haha
  • a

    assistattow

    08/28/2021, 2:44 AM
    if uid() = userid then all of the others work
  • a

    assistattow

    08/28/2021, 2:44 AM
    its only the delete one that doesnt work
  • r

    RichCorbs

    08/28/2021, 2:45 AM
    The record for sure matches (userid == uid())?
  • a

    assistattow

    08/28/2021, 2:46 AM
    yep it does because it allows me to insert,update and access with the same exact perms
  • a

    assistattow

    08/28/2021, 2:47 AM
    if I change the id or remove that policy then those features stop working
  • a

    assistattow

    08/28/2021, 2:47 AM
    and my delete function works with row level disabled
  • r

    RichCorbs

    08/28/2021, 2:47 AM
    Could there be conflicting policies somehow?
  • a

    assistattow

    08/28/2021, 2:47 AM
    From what I can see there are only 4 policys so I don't believe so
  • a

    assistattow

    08/28/2021, 2:47 AM
    I'm digging through documentation though right now to see
1...101112...52Latest