Adding a new column to a production database is a simple idea that can trigger a chain of events. Done wrong, it blocks queries, locks tables, or breaks application code. Done right, it expands your data model without disrupting uptime.
The first step is to define the new column in your migration script. Name it with precision. Choose the right data type. Decide if it will allow nulls or require a default value. These decisions are permanent in practice, even when the schema says otherwise.
Next, run the migration with zero downtime in mind. On large tables, adding a new column with a default value inline can lock writes. Use patterns like backfilling data in small batches, or add the column as nullable first, then populate it asynchronously. Only apply constraints after you complete the backfill.