Build · Database · intermediate
Design a SaaS Database Schema
Database SaaS intermediate LovableSupabase
How to use
- Copy the prompt below
- Paste it into Lovable, Supabase
- Review the output and follow up with refinements
Prompt
Set up a Supabase PostgreSQL database schema for a multi-tenant SaaS application. Create the following four tables: users (id uuid primary key, email text unique, name text, created_at timestamptz), organizations (id uuid primary key, name text, owner_id uuid references users, plan_tier text default 'free', created_at timestamptz), organization_members (org_id uuid references organizations, user_id uuid references users, role text check role in ('owner', 'admin', 'member'), joined_at timestamptz, primary key on org_id + user_id), and projects (id uuid primary key, org_id uuid references organizations, name text, status text default 'active', created_at timestamptz). Add Row Level Security policies so users can only select, insert, update, or delete rows that belong to an organization they are a member of. Write the SQL migration file for all tables, foreign keys, indexes on frequently queried columns (email, org_id), and RLS policies. Related prompts
Was this helpful?
Enjoying this guide?
Get weekly practical guides, plus tool updates and implementation playbooks.