Adding a new column sounds trivial. In production systems, it is not. A single schema change can break deployments, lock tables, or slow queries. The wrong migration can trigger downtime. That’s why a new column demands a precise, tested approach.
Start by defining the change. Identify the table, the column name, the type, and the constraints. Check for nullable vs. non-nullable requirements. Adding a NOT NULL column without a default will fail if rows exist. Use a default value or make it nullable first, then backfill, then enforce NOT NULL.
Run the change in a non-production environment. Test reads and writes with the new column in place. Check ORM mappings, database views, and any dependent queries. Search your codebase for SQL fragments that use SELECT *; many break when a new column appears in result sets.
When possible, use online schema changes. In MySQL, tools like gh-ost or pt-online-schema-change avoid table locks. In PostgreSQL, adding a nullable column without a default is instant, but defaults on large tables rewrite all data; add them in steps to avoid blocking.