Adding a new column in a database should be simple. It rarely is. The complexity hides in schema drift, data consistency, locking behavior, and deployment pipelines. Whether it is PostgreSQL, MySQL, or a distributed data store, creating a new column impacts reads, writes, and application performance.
The first step is to define the new column in a migration file. Use explicit types. Avoid implicit defaults unless required. Every database engine handles ALTER TABLE differently. Some run an instant metadata change. Others rewrite the entire table. This affects downtime and transaction logs.
When adding a new column with a default in PostgreSQL 11 and above, adding it without a default and then updating rows in batches can reduce lock time. In MySQL, use ALGORITHM=INPLACE where possible. For systems with millions of rows, breaking the update into chunks prevents replication lag and reduces contention.
Code must handle the schema change safely. Deploy changes in phases: