Adding a new column to a production database sounds simple. It’s not. Schema changes can break queries, spike error rates, and block deploys. The right approach avoids downtime and keeps data safe.
First, determine the column’s purpose and type. Use the smallest data type that works. Avoid NULL defaults unless truly needed. Explicit defaults make migrations safer and help with indexing.
Next, plan the deployment. On large tables, adding a column can lock writes. Use tools that support online schema changes—ALTER TABLE with ONLINE or INPLACE algorithms where possible. For PostgreSQL, consider adding the column without defaults first, then backfilling in batches.