The migration finished, but the table was wrong. A missing field broke the feature and the error log filled fast. The fix was simple: add a new column.
Adding a new column to a database table sounds small. It is not. A new column changes the schema, the queries, and often the logic that depends on them. In production, a careless ALTER TABLE can lock writes, slow reads, or even fail under load. The right approach depends on the database engine, the data size, and the uptime requirements.
First, choose the safest method to create the new column. In MySQL and PostgreSQL, ALTER TABLE is the direct command. In large datasets, adding with a default value can copy the full table, so adding a nullable column first and then backfilling data in batches is safer.
Second, update the application code in sync with the schema change. Feature flags and backward-compatible migrations prevent breaking changes. Deploy the new column before any code that writes to it. Then deploy the code that reads from it.