Database Migration
noun
say it: “DAY-tuh-bays my-GRAY-shun” /ˈdeɪtəˌbeɪs maɪˈɡreɪʃən/
A numbered script that makes one change to a database's tables, such as adding a column, run once on every copy of the database, in order.
What is a database migration?
A database migration is a numbered script that makes one change to a database's tables, such as adding a column. Each copy of the database (yours, a teammate's, the live one) runs every migration once, in number order, so they all end up with the same tables. A migration that has run somewhere is never edited: the next change is a new one.
-- 0003_add_set_notes.sql: runs once on each database, after 0001 and 0002
ALTER TABLE sets ADD COLUMN notes TEXT;
In a sentence
- “Adding a notes column meant writing a new database migration, 0003_add_set_notes.sql, not editing 0001.”
- “When the API starts, it runs each database migration the database hasn't had yet.”
Level: Journeyman · More Database terms at this level
Updated