The migration was live. Queries were hitting production, and the schema needed a new column—fast.
Adding a new column sounds simple. In practice, it’s where database operations and uptime collide. Get it wrong, and you lock tables, spike latency, or drop connections. Get it right, and the change slips into place without anyone noticing.
The first step is choosing the approach based on database type and workload. In PostgreSQL, adding a nullable or default-null column is instant, but a non-null column with a default can rewrite the whole table. MySQL and MariaDB may block readers and writers, depending on engine and column type. Understanding your database’s behavior is non‑negotiable.
For high‑traffic systems, use an online schema change tool. pt-online-schema-change, gh-ost, and native features like PostgreSQL’s concurrent operations can execute a new column addition without long locks. These tools create ghost tables, migrate data in chunks, and swap them in with minimal disruption.