Adding a new column to a database table is simple—until it isn’t. The wrong approach locks tables, blocks queries, and slows production traffic. The right approach keeps systems live while the schema evolves.
When you add a new column, start by defining the change in version-controlled migration scripts. In SQL, this means an ALTER TABLE statement with explicit data types, constraints, and defaults. For small tables, it can run inline. For large, high-traffic tables, plan for asynchronous backfills and phased rollouts.
In PostgreSQL, adding a nullable column without a default is instant. Adding a column with a default rewrites the table, which can freeze traffic. Run the default as a separate update for better availability. In MySQL, watch for table copy operations during ALTER TABLE. Choose the algorithm: INPLACE or INSTANT when possible to reduce downtime.
Index creation on a new column should be deferred unless queries demand it immediately. Build indexes concurrently to avoid table locks. For production deployments, coordinate migrations with application changes: applications should be able to read and write without depending instantly on the presence of the new column.