The code refuses to run. The schema is wrong. You need a new column.
Adding a new column is one of the most common database changes. Yet it’s also one of the easiest ways to break production if done carelessly. Whether you work with PostgreSQL, MySQL, or a distributed SQL engine, the core principles stay the same: preserve data integrity, maintain uptime, and document the change.
Start with the definition. Decide if the new column is nullable or required. If it’s required, add it with a default value to avoid disrupting inserts. Choose the right data type; mismatches will lead to type errors in queries or cause unexpected casting.
Next, timing. For large tables, adding a new column can lock writes. Use ALTER TABLE with care. On some systems, adding a column with a constant default value rewrites the entire table, causing long migrations. For zero-downtime changes, add the column without a default, backfill in controlled batches, then set constraints when safe.