Adding a new column sounds simple. It isn’t. In production, it can lock tables, block writes, and drop performance into the floor. The key is to plan the schema change, choose the right migration strategy, and execute without downtime.
First, define the column name, data type, and constraints. Match them to the purpose. Avoid vague types. Use NOT NULL only if you can set a safe default. If default values are expensive to compute, fill them in after creation.
Second, pick a safe migration method. For small datasets, a direct ALTER TABLE ADD COLUMN works. For large datasets, use an online schema change tool like pt-online-schema-change or gh-ost. They create the new column without locking the whole table.
Third, test in a staging environment with production-like data. Measure query performance before and after. Check index usage. If the new column will be part of joins or filters, index it immediately but avoid adding indexes you don’t need.