The schema was solid until the product team asked for one more field. A new column.
Adding a new column sounds simple. In practice, it can break deployments, slow queries, and lock tables at the worst possible moment. Done right, it’s seamless. Done wrong, it’s a production incident waiting to happen.
When designing a new column in a relational database, start with the type. Use explicit data types. Avoid generic types like TEXT or VARCHAR(MAX) for structured data. This reduces index size and improves query planning.
Set sensible defaults. If the new column must be non-null, choose a default value that works for both legacy and future records. For boolean flags, store as TINYINT(1) or BOOLEAN depending on the engine. For timestamps, decide whether to use UTC and enforce it at the database layer.
Backfill strategy matters. For large tables, update in small batches to avoid long-running locks. Use transactional scripts or background jobs. Monitor read and write latency during the migration.