The database table was ready, but the feature demanded more. You needed a new column.
Adding a new column sounds simple. In production, it can be brutal. Schema changes risk locks, downtime, and performance hits. The wrong ALTER TABLE can crush queries and stall the application.
The first step is clarity: define the column name, type, and constraints. Know exactly how it will be used. Avoid nullable columns unless required. Plan default values and indexing from the start to prevent expensive backfills later.
Choose the safest method for the migration. With small datasets, a direct ALTER TABLE works. On large datasets, consider adding the column without defaults, then populating it in batches. Use feature flags or backfill scripts to control rollout. Monitor load on the database during the operation.