Adding a new column to a production database is simple to describe but unforgiving in practice. Schema changes affect performance, compatibility, and availability. Getting it right means thinking about more than just ALTER TABLE.
The first step is defining the purpose and type of the new column. Choose a data type that fits the data now and in the future. Avoid types that require implicit casts during reads or writes. Set NULL or NOT NULL rules based on actual usage, not guesswork.
Next, control the deployment to avoid locking the table for too long. Large tables under heavy load need online schema changes. In PostgreSQL, use tools like pg_repack or pg_osc. In MySQL, consider pt-online-schema-change. These approaches keep downtime near zero.
Add indexes only after the column exists and has data. Building an index during the same change can block queries. Batch the data backfill with throttling to avoid saturating the I/O and CPU.