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
statuscolumn to theorderstable (values: pending, shipped, delivered), defaultpending, and update the RLS policies so only the order's owner can update it
Lovable will:
- Generate the SQL for the schema change.
- Apply it to your database.
- Update or add any RLS policies the change affects.
- 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
- Back up or export current data.
- Make the change on a small/test dataset if you have a test environment.
- Apply it, then verify existing features still work — especially anything relying on the changed column.
- 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 nulland 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
- 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.