How Do You Plan Your App's Data Before Building?
List the things your app stores, what belongs to what, and who may see or change each one, before the AI creates any tables. Do this as plain language in a planning session. Screens are cheap to redo, but changing how data is stored after real users arrive is slow and risky.
Here is my app brief: [paste it]. Plan the data. Don't write code or create tables yet. 1. List each thing the app stores, in plain language, and the fields it needs. 2. For each one, tell me: who owns it, who can read it, who can change it, and what should happen to it if its owner deletes their account. 3. Show how they relate: one user has many projects, and so on. Draw it as a simple text diagram. 4. Mark fields that must never be settable by users, such as role, plan, price, is_admin and owner. 5. Mark personal or sensitive data, and suggest what I could avoid storing at all. 6. Tell me which decisions would be hard to change later, and ask me about those now. In particular: can something belong to a team rather than one person? After I approve this, write it as one SQL migration for [Supabase], with row level security enabled on every table and a policy for each access rule. Keep it in a migration file. Don't change the database by hand.
- MembersEach one owns their own bookings
- ClassesOnly staff can create them
- BookingsBooked-by person, plus attendee if parents book
- Plan levelsA staff-only table, not on the profile
- Screens
- App code
- Access rules
- Live data
Try it now
- 1Paste the prompt into a planning mode with your brief, then read the table of who can read and change what. Would you be comfortable showing it to a customer?
- 2Answer section 6. Then check section 4 and make sure anything a user shouldn't control is listed there.
- 3In Supabase, run the approved migration through
supabase migration new <name>andsupabase db push --remote, or let your builder apply it. It worked if the Security Advisor shows no0013_rls_disabled_in_publicerrors.
Use it when
After your brief and before your first database prompt. Do it again before adding a feature that changes who owns what, such as moving from one user to teams.
Skip it when
Skip it while you're using sample data with "No login or database yet", which is a fine way to test screens. And don't design for scale you don't have. Five clear tables beat fifteen speculative ones.
Why it works
Access rules depend on your tables. A Supabase policy such as (select auth.uid()) = user_id only works if a user_id column exists on that table. Sharing features need a membership table, and Supabase's docs show why that design needs care: policies on two tables that read each other cause a loop that must be broken with a private helper function. If you work this out late, you rewrite every rule.
Data changes are also harder to undo. Lovable says reverting restores your code and keeps data changes. Replit says publishing applies structural changes to production after your approval, and it flags risky ones such as removing columns that contain data, changing column types and renaming. Supabase's docs recommend keeping changes as SQL migration files, so they can be repeated and reviewed.
Example
A small gym's class-booking app might store members, classes and bookings. A member owns their own bookings. Only staff can create classes. A member's plan level shouldn't be something they can edit, so it goes in a separate staff-only table rather than on their profile, since a Supabase policy letting users update their own row covers every column in it.
One question changes everything: can a parent book for a child? If so, a booking needs both a booked-by person and an attendee. Finding this now takes one line. Finding it after launch means changing live data and rewriting your access rules.
Going further
Add indexes for the columns your policies filter on. Supabase's docs show that a primary key on (team_id, user_id) doesn't cover lookups by user_id, so a membership table needs its own index on that column. Wrap auth.uid() as (select auth.uid()) as well, so Postgres can cache it per statement.
For membership, Supabase warns that team data stored in the sign-in token isn't up to date until the token refreshes, so a removed member can keep access until then. A membership table is checked on each request.
Don't store what you don't need. Rule of thumb, not legal advice: every sensitive field you skip is one you don't have to protect, back up or explain. Ask a qualified professional about the rules that apply to your data.
Common mistakes
- Putting role or plan columns on a row users can edit, so that an update policy lets them promote themselves.
- Letting the AI change tables by hand in the dashboard, so that production and your code no longer match and the change can't be repeated.
- Deleting a column in development without checking what publishing will do. On Replit, approved schema changes reach production.
- Storing names or emails in several tables, then having to update and protect each copy.
Sources
- Row Level Security, Supabase docs
- Database migrations, Supabase docs
- Database advisors, Supabase docs
- Column-level security, Supabase docs
- Project history, Lovable docs
- Development and production databases, Replit docs
Checked 6 November 2026. Products change often, so confirm details with the vendor.