Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent

How do I migrate a database?

Last checked 31 Aug 2026

Short answer

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.

What a migration means here

A migration is any structural change to your database: adding a table, adding or changing a column, adding an index, or updating RLS policies. In Lovable, you don't write raw migration files by hand — you describe the change and Lovable generates and applies it.

How to request one

Add a status column to the orders table (values: pending, shipped, delivered), default pending, and update the RLS policies so only the order's owner can update it

Lovable will:

  1. Generate the SQL for the schema change.
  2. Apply it to your database.
  3. Update or add any RLS policies the change affects.
  4. Update the front-end code that reads/writes the table, if you asked for that too.

Reviewing before applying

For anything on a live app with real data, ask Lovable to show you the migration before running it, and confirm whether it's reversible. Renaming or dropping columns is destructive — back up first (see /questions/how-do-i-back-up-my-lovable-database).

Safe sequencing for bigger changes

  1. Back up or export current data.
  2. Make the change on a small/test dataset if you have a test environment.
  3. Apply it, then verify existing features still work — especially anything relying on the changed column.
  4. Update related RLS policies explicitly rather than assuming they still apply correctly.

What usually goes wrong

  • Renaming a column that many parts of the app reference, breaking features that weren't part of the original request.
  • Forgetting that a new column with not null and no default will fail on tables that already have rows.
  • Assuming RLS policies migrate automatically when they reference a column that no longer exists — check they still make sense afterwards.

Related: /questions/how-do-i-back-up-my-lovable-database, /questions/can-i-move-from-lovable-cloud-to-supabase.

Sources

Was this answer helpful?

Related questions

Website made, maintained and hosted by PromptSites.com

PromptSites logo