Complete the code to allow users to update their own profiles.
create policy "Users can update their own profile" on profiles for update using (auth.uid() = [1]);
The policy checks if the authenticated user's ID matches the user_id field in the profiles table to allow updates.
Complete the code to allow users to delete only their own posts.
create policy "Users can delete their own posts" on posts for delete using (auth.uid() = [1]);
The policy uses the user_id field to verify ownership before allowing deletion.
Fix the error in the delete policy to correctly restrict deletion to the owner.
create policy "Delete own comments" on comments for delete using (auth.uid() = [1]);
The correct field to check ownership is commenter_id, which stores the user who made the comment.
Fill both blanks to create a policy that allows users to update their own orders only if the order status is 'pending'.
create policy "Update own pending orders" on orders for update using (auth.uid() = [1] and status = [2]);
The policy checks that the authenticated user matches customer_id and that the order status is exactly 'pending' before allowing updates.
Fill all three blanks to create a delete policy that allows users to delete their own messages only if the message is unread and the user is the recipient.
create policy "Delete own unread messages" on messages for delete using (auth.uid() = [1] and status = [2] and recipient_id = [3]);
The policy ensures the authenticated user is the recipient (recipient_id), the message status is 'unread', and the authenticated user matches the recipient_id to allow deletion.
