Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent
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
  1. Fill in the fields above — plain language beats jargon.
  2. Copy the prompt and paste it into Lovable as a single message.
  3. Let it finish before you send anything else, then read what changed.
  4. 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?

Guides that use this prompt

Website made, maintained and hosted by PromptSites.com

PromptSites logo