Adding a new column should be simple. In practice, it touches code, data, queries, and performance. The change can cascade across services, APIs, and analytics pipelines. Small mistakes lead to silent data loss or slow queries that surface weeks later.
The first step is clear: define the column with exact data types and constraints. Avoid nullable fields unless necessary. Default values should reflect actual business logic, not just placeholders to pass migrations.
In relational databases, adding a column in production can lock tables. For large datasets, an online migration is safer. Tools like pt-online-schema-change or gh-ost allow background operations without blocking writes. For PostgreSQL, use ALTER TABLE ... ADD COLUMN carefully, and consider NOT NULL constraints in a follow-up migration after backfilling.
Code changes must be versioned alongside migrations. Deploy the database change first, but do not read or write the new column until application code supports it. This prevents runtime errors during rollout and rollback.