KBAISE/ for lovable
Library
Docs

Database

about 10 minBuildingchecked 4d agoOfficial page
The short version

You can view, edit, and manage your app's built-in database directly within Lovable. This includes browsing tables, editing records, running special commands, checking security rules, and restoring from daily backups.

Anyone building an app with Lovable's built-in backend needs this to manage their app's data.

Do this, in order

  1. 1

    Tell Lovable in the project chat what data your app needs to store, describing the types of information and how they relate.

    This is the easiest way to create your database structure, and Lovable will set up the tables and columns for you.

  2. 2

    Go to 'More → Cloud → Database' to see your tables and the data inside them.

    This allows you to inspect and manage your app's data directly without needing to write any code.

  3. 3

    Click on a table name to open it, then double-click a value to change it, or use the 'Add row' button to create new entries.

    This lets you directly modify your app's data, which is useful for testing or making quick corrections.

  4. 4

    If you need to run advanced commands, go to 'More → Cloud → SQL editor' and type your command.

    This gives you direct control over your database for complex tasks, but it's often safer to ask Lovable in chat for changes.

  5. 5

    To check who can see or change what data, go to 'More → Cloud → Database → RLS policies'.

    This shows you the security rules Lovable automatically sets up to protect your users' private information.

  6. 6

    If you need to go back to an earlier version of your data, go to 'More → Cloud → Database → Backups' and choose a date to restore.

    This allows you to recover from mistakes or data loss, but be aware that any changes made after the backup will be lost.

Paste this into your project

I want a place to keep track of my clients with their name, email, phone number, and notes. I also need a way to track deals, including which client it's for, the value, the stage it's in, and when I expect it to close.

Words decoded

Database
An organized collection of information, like a digital filing cabinet, where your app stores all its data.
Postgres
A specific type of powerful and reliable database system that Lovable uses for your app.
Schema
The blueprint or structure of your database, defining what kind of information can be stored and how it's organized into tables and columns.
Table
A collection of related data organized in rows and columns, similar to a spreadsheet. For example, a 'Clients' table would hold all your client information.
Record
A single row in a database table, representing one complete item or entry, like one client's full details.
SQL
Structured Query Language, a special language used to talk to and manage databases, allowing you to ask for specific data or make changes.
RLS (Row Level Security)
A security feature that controls which specific rows (records) of data a user is allowed to see or change, based on rules you set.
Query
A request for information from a database, or a command to perform an action on the data.
Migration
A controlled change to your database's structure (schema), often used when you add new features that need new places to store data.
Index
A special lookup table that the database can use to speed up data retrieval, much like an index in a book helps you find information faster.

Where people get stuck

  • Editing records directly applies changes to your live project's database, which can't be undone without restoring a backup.
  • Deleting rows is permanent and cannot be undone.
  • Restoring a database backup is permanent; any data created or changed after the chosen backup will be lost.
  • If you restore a backup, your app's current features might not match the older database structure, potentially causing errors.
  • Using SQL commands like DELETE, DROP, TRUNCATE, ALTER, or UPDATE can permanently change or delete your data and database structure if not used carefully.

The short version, steps, decoder and prompt on this page are written automatically from Lovable's own documentation and can lag or misread it. The official page is always the authority.