A database grows over time. At some point, you need a new column. It might store user preferences, track timestamps, or record calculated metrics. Adding it sounds simple, but in production systems it can be risky. Schema changes touch live data, indexes, queries, and application logic.
To add a new column safely, start with the schema migration. Define the column type with precision. Use defaults only when needed, because defaults can impact performance during large table updates. Consider nullability. Non-nullable fields require backfilling, which can lock rows and slow throughput.
Run migrations in a controlled environment first. Test on real-size datasets. Measure query plans before and after. If the new column needs indexing, add the index in a separate migration to reduce lock duration.