The sprint was almost over when the schema broke. A new column was needed. Not next week. Not tomorrow. Now.
Adding a new column should be simple, but it isn’t always. Tables in production hold terabytes of data, with queries running every millisecond. Schema changes can trigger locks, replication issues, or unexpected downtime. Speed matters, but so does safety.
Start by defining the new column in your local migration file. Use explicit naming that matches your data model. Avoid vague types. If the column holds strings, set a length limit. If it holds integers, decide on signed or unsigned early. Precision here prevents future rework.
For large tables, use online schema change tools like gh-ost or pt-online-schema-change. These allow you to add a new column without halting writes or reads. Always test migrations in a staging environment with production-like load. Measure how long they take. Check indexes. Adding a column can force table rewrites unless handled carefully.