Database
Tables, relationships, CRUD, migrations, database design and troubleshooting.
How to design tables you will not regret in three months, and how to read and write them safely.

Guides in Database
Prompts for this topic
Answered questions in Database
20 short, plain-English answers filed under this topic.
What is Lovable Cloud?
Lovable Cloud is a Supabase backend (Postgres database, authentication, storage, edge functions) that Lovable provisions and manages for your project automatically, with no separate account or dashboard needed.
When should I use Lovable Cloud?
Use Lovable Cloud for most new projects needing a backend — it's the fastest path with no separate account; connect your own Supabase project instead if you already have one, need direct dashboard access, or must integrate with existing Supabase infrastructure.
How do I connect Supabase to Lovable?
In your Lovable project, open the Supabase integration and authorise Lovable to connect to an existing Supabase project (or create a new one), then Lovable can read and write to it the same way it does with Lovable Cloud.
How do I create a database in Lovable?
Ask Lovable to set up Lovable Cloud (or connect your own Supabase project) and describe the tables you need — Lovable provisions the Postgres database and creates the tables from your description.
How do I create database tables?
Describe the table's purpose and fields in plain language to Lovable — including which fields are required, their types, and any relationships to other tables — and Lovable generates the table with appropriate row-level security policies.
How do I view my database data?
Open the Cloud tab (or ask Lovable) to browse tables, edit rows and run SQL directly inside your project — no separate Supabase login needed.
Why isn't Lovable saving data?
Most commonly this is a missing or misconfigured RLS policy blocking the insert/update, an unconnected database, or a form that never calls the backend at all.
Why is Supabase returning a 403 error?
A 403 means Row Level Security blocked the request — the current user's role doesn't match any policy allowing that read or write on that table.
What is Row Level Security (RLS)?
RLS is a Postgres feature that restricts which rows a query can see or change, enforced per-row on the database itself rather than trusted to your app's code.
Do I need RLS on my Lovable app?
Yes, for almost any app with user data, private content or logged-in users — without RLS, anyone can read or write any row via the database's public API.
How do I fix RLS errors?
Identify which operation and role is being blocked, then ask Lovable to add or correct the specific policy for that table rather than disabling RLS.
Why can users see other users' data?
Almost always a missing or too-permissive RLS policy — either RLS isn't enabled on the table, or a policy allows reading rows regardless of who owns them.
How do I safely store API keys?
Store keys as secrets in your backend (Lovable Cloud/Supabase) and call the third-party API from a server/edge function — never put keys in front-end code.
How do I use environment variables?
Use `VITE_`-prefixed variables only for non-sensitive, public values baked into the front-end build; use Secrets for anything sensitive that a server/edge function needs.
What are Supabase Edge Functions?
Edge Functions are small serverless backend functions that run outside the browser — used for anything requiring a secret key, a third-party call, or logic that shouldn't be trusted to the client.
When should I use an Edge Function?
Use one whenever your app needs a secret key, must call a third-party service, or needs logic that shouldn't be trusted to run in the user's browser.
How do I upload and store files?
Ask Lovable to add file uploads and it will wire up storage in Lovable Cloud (or your connected Supabase project), including an upload UI and access policies for the files.
How do I back up my Lovable database?
Lovable Cloud stores backups you can restore from directly in the Database screen; for extra safety, also ask Lovable to export your data periodically.
How do I migrate a database?
Describe the schema change you want in chat and let Lovable write and apply the migration — it handles new tables, columns and RLS policy updates together.
Can I move from Lovable Cloud to Supabase?
Yes — Lovable Cloud is a Supabase backend under the hood, and Lovable supports connecting your own Supabase project instead, though moving existing data across takes an export/import step.