Row-Level Security Policy Generator
Implement PostgreSQL Row-Level Security for multi-user data isolation
Set up Row-Level Security (RLS) for: **Tables:** [TABLES — e.g., "projects, tasks, comments, files"] **Roles:** [ROLES — e.g., "admin (full access), manager (team access), member (own data only)"] **Tenant model:** [MODEL — e.g., "organization_id on every table", "team-based access"] Generate: 1. **RLS policies** — SELECT, INSERT, UPDATE, DELETE policies for each table and role 2. **Current user context** — set session variable with authenticated user info 3. **Policy functions** — reusable security functions for common patterns 4. **Cascading access** — manager sees team data, admin sees everything 5. **Performance** — ensure policies use indexed columns, avoid sequential scans 6. **Testing** — queries to verify each role sees only authorized data 7. **Bypass** — service role for migrations and admin operations Include the complete SQL for enabling RLS, creating policies, and test queries.
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
More Database Prompts
Related database templates from the vault
Database Normalization Advisor
Use this prompt to database normalization advisor with AI assistance
Query Result Caching Strategy
Use this prompt to query result caching strategy with AI assistance
Database Schema Designer
Design a normalized database schema from application requirements
Database Sharding Strategy Designer
PRODesign a database sharding strategy with shard key selection, routing logic, and migration plan from a single database
You Might Also Like
Prompts from other categories that share similar tags
Multi-Tenant Architecture Planner
Design multi-tenant isolation strategies for SaaS applications
Database Query Performance Analyzer
Analyze slow database queries and generate optimized alternatives
Authentication System with JWT
Implement a complete authentication system with signup, login, and session management
Database Deadlock Resolver
Use this prompt to database deadlock resolver with AI assistance
Keep Exploring the Vault