How do I create a database in Lovable?
Last checked 31 Aug 2026
Short answer
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.
The database comes with Cloud, not as a separate step
You don't "create a database" independently — enabling Lovable Cloud provisions a Postgres database automatically. From there, you describe the tables you need and Lovable creates them.
Set up Lovable Cloud for this project. I need tables for
products(name, price, description, image) andorders(customer name, email, items, total, status).
Reviewing what was created
Use the built-in Database view in Lovable to see the tables, columns and data that get created — you can browse rows and check structure without needing separate dashboard access.
Show me the current database schema.
Add security as you go
Every table storing user or business data needs row-level security reviewed, not just created:
Add row-level security to the
orderstable: customers can only see their own orders, and only admins can see all of them.
Roles for checks like "is this user an admin" must live in a separate user_roles table — never as a column on a profile row, since that pattern is far easier to exploit.
What usually goes wrong
- Assuming a table is instantly secure: newly created tables need explicit RLS policies matched to your actual access rules — don't assume defaults are correct for sensitive data.
- Over-specifying types you don't understand: if you're unsure what column type fits (e.g. currency, dates with time zones), describe the real-world use ("store a price in dollars and cents") and let Lovable choose an appropriate type.
- Forgetting relationships: if
ordersshould referenceproductsorcustomers, say so explicitly so Lovable adds the correct foreign keys.
For the actual mechanics of adding tables and columns after the database exists, see how do I create database tables.
Sources
Was this answer helpful?
Related questions
- AnswerHow 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.
- AnswerHow 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.
- AnswerHow 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.
- AnswerHow 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.