A database migration is a versioned, repeatable change to a database schema or its data, such as adding a column or creating a table. The same migration files run in development, staging, and production in a fixed order.
Why it matters
Migrations make schema changes reviewable and reproducible, like source code. Tools record which migrations have been applied so new servers can be built from scratch and old ones brought forward. On large tables, a careless migration can lock the table and cause an outage, so safe rollout patterns matter. The phrase is also used for moving data between database systems.
Example
-- 0007_add_phone_to_users.sql
ALTER TABLE users ADD COLUMN phone TEXT;
A safe rollout often adds a nullable column first, deploys code that writes it, backfills old rows in batches, and only then adds constraints.
Common mistakes
- Editing a migration that has already run elsewhere instead of adding a new one.
- Running a table-locking change on a huge table at peak traffic.
- Deploying code that needs the new column before the migration has finished.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.