The database groaned under the weight of another migration. You had one job: add a new column.
Adding a new column is simple until it is not. Schema changes carry risk. Without planning, you lock rows, slow queries, or break production. The goal is zero downtime, minimal performance impact, and a smooth path to deploy.
First, define the reason for the new column. Avoid adding unused fields. Know the type, constraints, and defaults before touching the schema. If the column will store values for all existing rows, decide how to backfill the data without blocking writes.
In relational databases like PostgreSQL and MySQL, adding a nullable column without a default is fast. Adding with a default value is slower, especially on large tables, because the change rewrites every row. To reduce risk, create the column as nullable, deploy, then backfill in small batches. Once the data is in place, run a second migration to add NOT NULL constraints or indexes if needed.