Databasebeginner
Create a Database Table With Access Rules
Creates a table and its security policies in one step, so you never end up with a table nobody can query.
When to use it
Data modelling
Lovable Prompt
Create a [TABLE NAME] table. Columns: - [column] — [type] — [required or optional] — [default] - (repeat for each column) - A reference to the owning user - A created timestamp Rules: - Enable row level security and grant the correct table privileges in the same migration. - Signed-in users can read, insert, update and delete only their own rows. - Admins can manage all rows using the existing role-check function. - Add an index on every column I will filter or sort by. After creating it, show me a simple screen that lists my rows and lets me add one, with empty, loading and error states.
Build your version of this prompt
Fill in your details and the prompt below updates as you type. Anything you skip stays as a square-bracket placeholder so you can see what's still missing.
Your prompt
Create a [Table name] table. Columns: - [column] — [type] — [required or optional] — [default] - (repeat for each column) - A reference to the owning user - A created timestamp Rules: - Enable row level security and grant the correct table privileges in the same migration. - Signed-in users can read, insert, update and delete only their own rows. - Admins can manage all rows using the existing role-check function. - Add an index on every column I will filter or sort by. After creating it, show me a simple screen that lists my rows and lets me add one, with empty, loading and error states.
1 field still empty — the prompt works better when they're filled in.
How to use this prompt
- Fill in the fields above — plain language beats jargon.
- Copy the prompt and paste it into Lovable as a single message.
- Let it finish before you send anything else, then read what changed.
- If the result is close but not right, describe the difference rather than restating the whole prompt.
Suggested follow-up prompt
Review what you just built for Create a Database Table With Access Rules. 1. List anything you changed that I did not ask for, and undo it. 2. Check it works on a 375px-wide phone screen: no horizontal scrolling, tap targets at least 44px. 3. Confirm every form shows a clear error and a clear success state. 4. Tell me in plain language what is still missing before this is safe to publish. Do not add new features in this step.
Why it works
It bundles the four things that must happen together — table, privileges, policies, indexes — so none of them is forgotten.
Was this prompt helpful?
You might also need
- GuideHow to Create Your First Database TableColumn types, defaults, required fields and relationships — designed so you are not migrating data in three weeks.
- 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.