Adding a new column sounds simple, but in production systems it can be a high‑risk operation. Schema changes hit live databases. They can block writes, lock tables, or slow queries if handled carelessly. The key to adding a new column without downtime is choosing the right method for your database engine, traffic pattern, and deployment model.
For PostgreSQL, adding a nullable column without a default is safe because it updates only metadata. Adding a column with a non‑null default rewrites the table and can lock it. The best practice is to add the column as nullable, backfill data in batches, then set the NOT NULL constraint after the table is populated.
For MySQL, ALTER TABLE can be dangerous on large datasets. Use pt-online-schema-change or gh-ost to apply the new column online without blocking writes. These tools create a shadow table, copy data incrementally, and swap tables with minimal downtime.