[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"glossary-database-migration::en":3,"gloss-cluster-database-migration::en":19,"gloss-next-database-migration::en":9},{"slug":4,"category":5,"name":6,"definition":7,"meta_desc":8,"faq":9,"schema_markup":9,"related":10},"database-migration","data-infra","Database Migration","A database migration is a single, version-controlled file describing an incremental change to a database's schema — creating a table, adding a column, adding an index — designed to be applied in a fixed order across every environment (a developer's laptop, staging, production) so the schema stays identical and reproducible everywhere, rather than someone manually running `ALTER TABLE` commands by hand and hoping every environment stays in sync. Why it matters for AI\u002FSaaS builders: migrations are the mechanism by which a schema evolves safely alongside a growing product — adding the `embedding vector(1536)` column for a new RAG feature, adding a `tenant_id` column to enforce multi-tenant isolation, or adding an index to fix a slow query are all migrations, checked into version control alongside the application code that depends on them, so a `git checkout` of any historical commit corresponds to a schema a migration tool can reproduce exactly. How it works: migration tools (Laravel's built-in migrations, Prisma Migrate, Alembic for Python, Rails migrations) track which migrations have already run (typically in a dedicated `migrations` table in the database itself) and apply only the new ones in order when `migrate` is run. Migrations are written to be reversible where practical (an `up` step and a `down` step) so a bad deploy can be rolled back cleanly. The genuinely hard part in production systems isn't writing migrations — it's running them safely against a live, high-traffic database without downtime: adding a column is usually safe and fast, but adding a `NOT NULL` constraint to an existing large table, or building an index, can lock the table and block writes for the duration unless done carefully (e.g., Postgres's `CREATE INDEX CONCURRENTLY`, which builds an index without holding a table-wide lock, at the cost of taking longer and being non-transactional). Worked example: a team adding vector search to their SaaS writes a migration `AddEmbeddingToDocuments` that runs `ALTER TABLE documents ADD COLUMN embedding vector(1536);` followed by `CREATE INDEX CONCURRENTLY ON documents USING hnsw (embedding vector_cosine_ops);` — the concurrent index build lets the production database keep serving live reads and writes throughout the multi-minute index build on a 5-million-row table, instead of the blocking, non-concurrent version locking writes to the table until it finishes. The migration is peer-reviewed before merge specifically because of this production-safety concern — a reviewer familiar with the team's traffic patterns catches that the naive `CREATE INDEX` (without `CONCURRENTLY`) would have taken the documents table offline for writes during business hours, the kind of mistake that's invisible in a local dev environment with a few hundred rows and only becomes obvious at production scale.","A database migration is a version-controlled, incremental change to a database's schema, applied in order so every environment stays in sync.",null,[11,14,16],{"slug":12,"name":13},"index-database","Index (Database)",{"slug":15,"name":15},"pgvector",{"slug":17,"name":18},"postgresql","PostgreSQL",[20,24,27,30,33,37,40,43,46,49,53,56],{"slug":21,"category":5,"name":22,"updated_at":23},"acid","ACID","2026-08-24T02:46:37+00:00",{"slug":25,"category":5,"name":26,"updated_at":23},"ann-search","ANN Search",{"slug":28,"category":5,"name":29,"updated_at":23},"backpressure","Backpressure",{"slug":31,"category":5,"name":32,"updated_at":23},"batch-processing","Batch Processing",{"slug":34,"category":5,"name":35,"updated_at":36},"bm25","BM25","2026-08-24T02:46:38+00:00",{"slug":38,"category":5,"name":39,"updated_at":23},"cache","Cache",{"slug":41,"category":5,"name":42,"updated_at":23},"cap-theorem","CAP Theorem",{"slug":44,"category":5,"name":45,"updated_at":23},"change-data-capture","Change Data Capture (CDC)",{"slug":47,"category":5,"name":48,"updated_at":23},"chroma","Chroma",{"slug":50,"category":5,"name":51,"updated_at":52},"chunk-overlap","Chunk Overlap","2026-08-24T03:30:02+00:00",{"slug":54,"category":5,"name":55,"updated_at":23},"columnar-storage","Columnar Storage",{"slug":57,"category":5,"name":58,"updated_at":23},"connection-pooling","Connection Pooling"]