Adding a new column to a table seems simple. It is not. Done wrong, it can stall deployments, corrupt production data, and drag your system into downtime. Done right, it is controlled, reversible, and invisible to the user. The difference is preparation.
Start with the schema migration. Define the exact type. Decide on nullability. Set sensible defaults that avoid unnecessary backfills. Use migration frameworks like Flyway or Liquibase, or built-in ORM tools, but handle them with caution — schema changes tied to code deployments should be atomic, predictable, and staged.
For large datasets, break the work. Add the column first, without constraints. Then backfill in batches. Monitor locks, query performance, and replication lag. Never push a full-table update in one transaction unless you want indexes to scream.
Test in an environment identical to production. Schema diffs against production should be part of the CI/CD pipeline. Automate rollback scripts. Keep deployments idempotent.