Library / Data & backend / Database migration
No. 134·noun·also called migration, schema migration, schema change

Database migration

A saved script that changes your database's structure, like adding a column, so every copy of the database gets the same change.

SPECIMEN · DIAGRAM · FLOW
AppMigrationSaved with your code
DataStaging database
DataLive database
runs firstthen runs here
Definition

What it is

A database migration is a saved script that changes the structure of your database: adding a column, creating a table, renaming a field. It is stored with your code, so the same change can run on a test copy first and then on the live database.

You need one any time a feature needs somewhere new to put data. Your agent writes it, and good tools show it to you before running it. Two things to check: does it keep the rows you already have, and does it touch anything you didn't ask for?

A migration changes structure, not content. Adding sample records is seed data. People also say "migrating" for moving a whole app to a new host, which is a different job.

Say it like a builder

How to ask for it

Vague

“I want to add a phone number to customers but I don't want to lose the ones I already have.”

Precise

“Add an optional phone field to the customers table as a database migration. Show me the migration before running it, run it on staging first, and leave all existing rows unchanged.”

Why it works

"Add a phone number" could be done by rebuilding the table and losing data, while "database migration" means a reviewable, repeatable change and the prompt protects existing rows.

In the wild

You've seen this in

  • CLovable showing you the database change and asking for approval in the chat before it runs
  • PThe supabase/migrations folder of saved change files that appears in a project
  • DA "run migrations" step in the deploy of a Rails or Django app
Usage note

Often confused with