The query runs. It fails. You realize the table needs a new column.
Adding a new column sounds simple. In production, it can be the difference between smooth deployment and hours of downtime. Schema changes affect live data, ongoing queries, and the integrity of your application. Planning is critical.
Start by defining the purpose of the new column. Know the data type, constraints, and default values before touching the database. This eliminates guesswork and reduces migration risk.
Choose the right operation. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward. But for large tables, adding a column with a default value rewrites the entire table — slow, blocking, and expensive. To minimize lock time, add the column without a default, update rows in batches, and then set the default afterward.
Index only when necessary. A new index can speed queries but will slow the migration itself. On high‑traffic systems, create indexes concurrently to avoid locking. Monitor query plans to ensure the new column does what it’s meant to do.