Adding a new column sounds simple, but in production it can expose weak migrations, break integrations, and trigger data inconsistencies. Done right, it unlocks new features and analytics with zero downtime. Done wrong, it leads to lock contention, failed deploys, or silent data loss.
First, define the new column in your migration file with explicit type, nullability, and default values. Always avoid ambiguous data types. In PostgreSQL, for example, TEXT without constraints can cause unpredictable performance. In MySQL, watch for implicit conversions.
Run the migration in a way that does not block reads and writes. Use ALTER TABLE ... ADD COLUMN with DEFAULT and NOT NULL only if your database engine can apply it instantly. Otherwise, create the column as nullable first, populate it in batches, then apply constraints in a separate migration.
Update your application code to handle both the old and new schema during the rollout. Read logic should tolerate the absence of the column until the migration completes. Write logic should populate the new column without breaking backward compatibility for any dependent systems.