The database was live. Traffic was spiking. And the request was simple but dangerous: add a new column.
Adding a new column can be routine or it can bring production to a crawl. The difference is in how you plan and execute it. Schema changes in modern systems touch critical paths. Even a single column can lock tables, block writes, or trigger unnecessary full-table rewrites. Choosing the right approach keeps your application fast and stable.
First, confirm the purpose of the new column. Is it storing computed data or raw input? Is it nullable, or will it require a default value? These properties determine the safety of the migration. In many SQL engines, adding a nullable column without a default is instant and non-blocking. But adding a column with a non-null default can rewrite the table, impacting performance under load.
For PostgreSQL, use ALTER TABLE ... ADD COLUMN with care. Know your Postgres version. Newer versions handle certain default additions without a full rewrite. In MySQL, ALTER TABLE behavior varies by storage engine and column type. In high-traffic systems, consider online schema change tools like gh-ost or pt-online-schema-change. These create shadow tables, migrate data incrementally, and swap tables with minimal downtime.