Adding a new column sounds simple, but it can break production if done wrong. Schema updates can lock tables, block writes, and slow reads. Downtime costs money. The key is to create a new column safely, without impacting live traffic.
In SQL, adding a column depends on the database engine. In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast when adding a nullable column without a default. But adding a default value rewrites the full table, which can cause long locks. In MySQL, avoiding a full table copy may require ALGORITHM=INPLACE or ALGORITHM=INSTANT. In modern MySQL or MariaDB, ALTER TABLE ... ADD COLUMN ... DEFAULT can be safe with instant DDL, but only on certain storage engines and versions.
For large datasets, online schema change tools like gh-ost or pt-online-schema-change stream data into a new table structure without blocking queries. This avoids downtime but adds complexity. The steps are predictable: