Complete the code to enable Row Level Security on the table.
ALTER TABLE users ENABLE [1];Enabling RLS (Row Level Security) activates the policy enforcement on the table.
Complete the code to create a policy that allows users to select their own rows.
CREATE POLICY "Users can select their own data" ON users FOR SELECT TO authenticated USING ([1] = auth.uid());
The policy checks if the row's 'id' matches the authenticated user's id.
Fix the error in the policy condition to correctly check user ownership.
CREATE POLICY "Allow update if owner" ON posts FOR UPDATE TO authenticated USING (owner_id [1] auth.uid());
In SQL, '=' is used for equality comparison, not '==' which is invalid.
Fill both blanks to create a policy that allows inserts only if the new row's user_id matches the authenticated user.
CREATE POLICY "Allow insert if user matches" ON orders FOR INSERT TO authenticated WITH CHECK ([1] = auth.uid() AND [2] = auth.uid());
The policy checks that the 'user_id' in the new row matches the authenticated user's id for both conditions.
Fill the blanks to write a policy that allows deleting rows only if the row's owner_id matches the authenticated user and the row status is 'inactive'.
CREATE POLICY "Allow delete if owner and inactive" ON tasks FOR DELETE TO authenticated USING ([1] = auth.uid() AND [2] = 'inactive');
The policy checks that 'owner_id' matches the authenticated user and 'status' is 'inactive'.
