The query ran clean, but the table needed a new column.
Adding a new column sounds simple. In production, it can break more than it fixes if done without care. Schema changes touch your data model, migrations, and application code. They change how queries run and how data is stored, indexed, and retrieved. The wrong approach can lock tables, slow requests, or cause downtime.
A new column should start with a clear definition: its name, type, nullability, and default value. Avoid surprises by mapping its purpose across every service that reads or writes the table. Use migrations that are backward-compatible. Deploy them in stages. First, add the column without constraints. Then write to it. Then update your reads. Finally, enforce constraints when the old paths are gone.
For large datasets, add new columns with NULL defaults to prevent full table rewrites. If a default value is needed, set it in the application until all rows are updated. This minimizes the impact on the database engine and keeps migrations fast. For indexed fields, create indexes after the column is filled to reduce pressure on storage and CPU.