Adding a new column sounds simple. One line in a migration file, a quick deploy, and move on. In production, it’s rarely that clean. Schema changes touch live data. The wrong command can lock tables, block writes, or even corrupt rows. The key is to design the new column with zero-downtime in mind.
First, choose the right data type from the start. Changing types later is costly. If the column will store large text or JSON, confirm the storage engine can handle the load. For numeric data, define precision explicitly to avoid unexpected rounding.
Second, mark the column as nullable at creation if you need to backfill values. Adding a NOT NULL column with no default will scan the entire table and hold locks. Instead, create it nullable, deploy, run a background job to update rows, then add constraints in a later migration.
Third, consider default values. In some relational databases, setting a default on creation can be expensive if the engine writes it to every row. In others, it’s metadata-only. Know the difference.