Adding a new column is one of the most common schema changes in any production database. It sounds simple, but execution matters. A poorly planned column migration can lock tables, slow queries, and block deploys. The right approach avoids downtime and keeps your data clean.
First, understand the column’s purpose. Define its data type, default value, and nullability. Decide if it needs constraints, indexes, or foreign keys. If it’s large text or JSON, consider storage and query impact.
Second, choose your migration method. For small datasets, a standard ALTER TABLE ADD COLUMN works. On large or high-traffic tables, use an online schema change tool like pt-online-schema-change or gh-ost to avoid locking. Break up heavy writes into batches.