The code was failing, and the logs pointed to one reason: a missing column.
Adding a new column sounds simple. In production systems with live users, it can be the difference between a clean migration and an outage. The process must be deliberate, predictable, and fast.
A new column in a database table changes the schema. Whether you are on PostgreSQL, MySQL, or another system, the impact depends on storage engine, locking behavior, and index strategy. In large datasets, the wrong migration can lock tables for minutes or even hours. This is why the workflow for creating a new column must be optimized.
First, define the column schema with precise types and constraints. Avoid defaults that trigger a full table rewrite unless necessary. For example, adding a NOT NULL column with a default value may rewrite millions of rows. Instead, add the column as nullable, backfill in controlled batches, and then enforce constraints.
Second, ensure application code is aware of the change. Deploy code that can handle both old and new schemas before running the migration. Use feature flags or conditional logic until the migration is complete.