Back to Backend

What are database migrations and how do teams apply schema changes safely?

A migration is a versioned, repeatable script (or object definition) that changes the database schema or reference data: new tables, columns, indexes, constraints. Tools like Flyway, Liquibase, Prisma migrate, Alembic, or Rails migrations track which steps ran so every environment - local, CI, production - stays in sync. Good teams review migrations in PRs, test rollbacks or forward-only strategies, and avoid long full-table locks on hot tables in peak traffic when alternatives exist. Data backfills and zero-downtime column additions are a senior follow-up (expand–contract, dual-write, backfill, then cut over).

-- 20260427_add_status_to_orders.sql
ALTER TABLE orders ADD COLUMN status text NOT NULL DEFAULT 'pending';
CREATE INDEX idx_orders_status ON orders (status);

Start simple: try this concept in a tiny project before moving to advanced tools.

sqlmigrationsdevops

Want to check this topic right now?

Check this question