The build was ready. The data was live. But the schema needed one last thing: a new column.
Adding a new column to a database should be simple. In many cases, it’s not. The wrong approach can lock tables, block writes, and stall critical services. At scale, these costs multiply fast. A careless ALTER TABLE can bring down production.
The core principle is safe, online schema changes. Whether you are on PostgreSQL, MySQL, or a distributed system, the method is the same: add the column without blocking queries. In PostgreSQL, adding a nullable column with a default value can lock writes. The safer path is to add it without a default, backfill in small batches, and then apply the default constraint once the data migration is complete.
In MySQL, adding a column to an existing table can trigger a full table rebuild. Use algorithms like INPLACE or tools such as pt-online-schema-change to write in the background while keeping reads and writes active. In sharded systems, coordinate changes across nodes with a migration framework that can handle retries and failures.