Complete the code to enable Row Level Security (RLS) on the 'users' table.
ALTER TABLE users [1];To enable RLS on a table, use ALTER TABLE table_name ENABLE ROW LEVEL SECURITY;
Complete the code to create a policy named 'select_policy' that allows SELECT on the 'orders' table for all users.
CREATE POLICY select_policy ON orders FOR [1] TO public USING (true);The policy is for SELECT operations, so use FOR SELECT.
Fix the error in the policy creation by completing the code to restrict UPDATE on 'products' table only to users with matching user_id.
CREATE POLICY update_policy ON products FOR UPDATE TO authenticated USING (user_id = [1]);In Supabase, auth.uid() returns the current user's ID for RLS policies.
Fill both blanks to create a policy named 'delete_policy' that allows DELETE on 'comments' table only if the comment's author matches the current user.
CREATE POLICY delete_policy ON comments FOR [1] TO authenticated USING (author_id = [2]);
The policy is for DELETE operations and uses auth.uid() to check the current user.
Fill all three blanks to create a policy named 'insert_policy' on 'messages' table that allows INSERT only if the sender_id matches the current user and the message is not empty.
CREATE POLICY insert_policy ON messages FOR [1] TO authenticated USING (sender_id = [2]) WITH CHECK (content [3] '');
The policy is for INSERT, uses auth.uid() to check sender_id, and ensures content is not empty using <>.
