The migration locked halfway. The logs showed nothing useful. The schema needed one thing: a new column.
Adding a new column should be simple, but in production systems, nothing is simple. Downtime, migrations, constraints, and null handling all matter. A small change can ripple across services, APIs, and analytics pipelines.
First, define the column with precision. Use the right data type from the start to avoid costly rewrites. For integers, pick the lowest range type that fits the future. For text, constrain it. For timestamps, store in UTC.
Second, plan the migration path. On large tables, adding a new column with a default can lock writes. Use online schema changes if your database supports it. MySQL has ALTER TABLE ... ALGORITHM=INPLACE. PostgreSQL can add a nullable column instantly, but defaults require rewrites.