Adding a new column to a database sounds simple, but it carries the weight of schema design, data integrity, and production safety. Whether it’s PostgreSQL, MySQL, or a distributed SQL service, the workflow must balance speed with zero downtime. A careless ALTER TABLE can lock rows, block queries, and cost real money.
Plan the change. Identify the column name, data type, default value, and nullable state. Decide if the new column should be indexed. In PostgreSQL, adding a nullable column without a default is instant. Adding one with a default rewrites the table and can freeze large datasets. In MySQL, the cost depends on storage engine and row format.
Test the migration script on a realistic dataset. Use feature flags or phased rollouts if the application must handle both old and new schemas during deployment. If you need to backfill data, break it into batches to avoid long-running locks or high replication lag.