Back to guide/General Productivity

Database Setup

Includes RLS policies, indexes, and type generation alongside table definitions. This produces a secure, performant database setup instead of just bare table creation.

lovable-promptstable_1table_1_fieldstable_2
Edit View
Prompt
Set up the Supabase database for this application:\n\nTables:\n1. {{table_1}}\n   - id (UUID, primary key, auto-generated)\n   - {{table_1_fields}}\n   - user_id (UUID, foreign key to auth.users)\n   - created_at (timestamp with timezone, default now())\n   - updated_at (timestamp with timezone)\n\n2. {{table_2}}\n   - id (UUID, primary key, auto-generated)\n   - {{table_2_fields}}\n   - {{table_1}}_id (UUID, foreign key)\n   - created_at, updated_at\n\nRow Level Security:\n- Users can only read/write their own {{table_1}} rows (WHERE user_id = auth.uid())\n- Users can read/write {{table_2}} rows that belong to their {{table_1}}\n\nIndexes: Add indexes on user_id, {{table_1}}_id, and any field used for sorting or filtering.\n\nGenerate the corresponding TypeScript types and Supabase query functions for CRUD operations on each table.

Variables to customize

{{table_1}}{{table_1_fields}}{{table_2}}{{table_2_fields}}

Why this prompt works

Includes RLS policies, indexes, and type generation alongside table definitions. This produces a secure, performant database setup instead of just bare table creation.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.