Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
GlossaryNovember 22, 20263 min read

What is a database migration?

Migrations are the change log of your database structure. Here is how they work, which changes are safe on a live app, and how to back out of one without losing data.

Startbase Team
Editorial ink illustration of numbered renovation work orders pinned beside a house under scaffolding, the stamp in ember orange

Key takeaways

  • A migration is a small, timestamped SQL script that changes the database structure; they run once each, in order.
  • Adding tables and optional columns is safe; renaming, dropping and changing types on live data needs a careful sequence.
  • Never edit a migration that already ran. Write a new one that reverses or corrects it.

Think of a database migration as one numbered step in the history of your database's structure: a small script that changes the schema in a specific way, such as creating a table, adding a column or adding an index, recorded so that every copy of the database ends up with the same shape.

Renovating a house works the same way. You do not redraw the whole building each time; you keep numbered work orders: 1, add a porch; 2, move the kitchen door; 3, add a window. Anyone holding the list can bring an identical house up to date by doing the orders they have not done yet.

How migrations work

Each migration is a file whose name starts with a timestamp, for example 20261122093000_add_phone_to_profiles.sql, containing something like `alter table profiles add column phone text;`. The database keeps a small table recording which migrations have run. Applying migrations means running, in order, every file not yet recorded. That is how a fresh test database and the live one stay identical, and how a teammate's change reaches yours.

Safe changes and risky ones

On a live app with real users, changes fall into two groups:

  • Usually safe: creating a new table, adding an optional column, adding a column with a default, adding an index (large tables may need it built without locking writes).
  • Needs care: renaming a column (the running app still asks for the old name), dropping a column or table (data gone), changing a type (text to number fails on "n/a"), making an existing column required (fails if any row is empty).

Risky changes are done in steps. To rename full_name to display_name: add display_name, copy the data over, switch the app to read the new column, and only in a later migration drop the old one. To make a column required: fill in the empty rows first, then add the rule. Back up before anything destructive.

Undoing a migration

Once a migration has run, treat it as history. Editing the old file changes nothing on databases that already ran it and makes copies drift apart. The fix is a new migration that reverses or corrects the change. Dropped data does not come back from a script, which is why destructive steps come last and only after a backup. This is different from restoring a version of your code: rolling back files does not by itself rewind what is stored in the database (checkpoints and undo).

Migrations when building with Startbase

In a Startbase Cloud project, the agent manages your schema through SQL migrations in the project and normally applies them as part of its work. The Schema Sync panel shows applied and pending migrations and whether a seed file exists, with Apply migrations and Apply seed buttons for when you want to run them yourself (database docs). Daily backups are taken automatically; point-in-time recovery is a paid database add-on. When asking for a structural change to a live app, say that real data exists and must be kept.

The app is live with real customers. Rename the bookings column "note" to "customer_note" without losing data: add the new column, copy existing values, switch the app to the new column, and leave dropping the old column for a separate migration I will approve later. Show me the migration SQL before applying it.

Common confusions

  • Schema migration vs data migration. A schema migration changes structure; a data migration moves or transforms rows (also "migrating" from one provider to another). The steps above often mix both.
  • Migration vs seed. Seed files load starter or demo data once; migrations change structure.
  • Migrations vs backups. A migration history rebuilds the shape, not the rows. Only backups restore data. Background in database schema and from prototype to production.

Frequently asked questions

Why not just edit the database directly?

Manual edits are not recorded, so test and live databases drift apart and changes cannot be repeated or reviewed. Migrations make every structural change reproducible.

Can a migration delete my data?

Yes, if it drops a table or column or changes a type destructively. Do those steps last, after copying data and taking a backup.

How do I undo a migration?

Write a new migration that reverses it. Editing or deleting one that already ran leaves databases out of sync.

On this page

  • How migrations work
  • Safe changes and risky ones
  • Undoing a migration
  • Migrations when building with Startbase
  • Common confusions

Keep reading

More in Glossary
Editorial ink illustration of a hand-cranked music box drum plucking a metal comb, the crank handle in ember orange
GlossaryNovember 22, 2026

What is a game loop?

Every real-time game runs one repeating cycle: read input, update the world, draw it. Here is what that cycle looks like and why it decides how your game feels.

3 min read
Editorial ink illustration of a brass stopwatch beside a small wind-up toy car, the second hand in ember orange
GlossaryNovember 22, 2026

What is delta time?

Delta time is the number that keeps your game the same speed on every screen. Here is how to use it, where it breaks, and how to spot a game that forgot it.

3 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.