Adding a new column sounds simple. It can also break production, trigger costly reindexing, or cause migrations to lock tables for hours. The key is knowing how to add a new column without risking data integrity, uptime, or performance.
Start by identifying if the new column belongs in the existing table or if it should be stored in a separate table to avoid hot path writes. Check database documentation for how ALTER TABLE behaves in your engine. In MySQL, adding a nullable column at the end is often instant. In PostgreSQL, adding a column with a constant default before version 11 rewrites the table. In high-traffic systems, even small changes must be tested against a realistic dataset.
If the new column requires an index, create it in a separate step. Deploy the schema change first, then backfill data in batches to avoid spikes in load. Use LOCK TIMEOUT or statement_timeout settings to prevent bad queries from freezing your database. When possible, add the column as NULL, migrate data in the background, and then enforce NOT NULL constraints when ready.