The migration finished at 02:14. A new column had appeared in the production database, invisible hours earlier, now holding empty slots that will soon carry real data.
Adding a new column sounds simple. It isn’t. The change must be safe, fast, and reversible. Schema migrations that add columns can block writes, lock tables, or break code paths if not coordinated. The mechanics matter.
First, define the new column in your schema with explicit type, constraints, and defaults. Avoid implicit casts or database-specific quirks that create drift between environments. In PostgreSQL, use ALTER TABLE … ADD COLUMN with DEFAULT and NOT NULL only if the dataset is small, or set defaults in application code to prevent locking. In MySQL, beware of engine-specific behaviors when altering large tables; use online DDL or partition strategies to reduce downtime.
Second, deploy application changes before writing to the new column. This includes ORM mapping updates, query adjustments, and API contract changes. The sequence should be migration-safe: the app should tolerate the column both existing and being empty.