Adding a new column to a database table can feel routine, but the wrong approach will cost uptime, corrupt data, or stall deploys. The right approach is controlled, fast, and reversible. This is how to do it.
First, confirm why the new column exists. Does it store new data, replace an old column, or support a future feature? Locking scope at the start prevents extra migrations later.
Next, analyze the table. Large tables need special handling to avoid locks. Check row count, index usage, and downstream dependencies. For PostgreSQL, consider ALTER TABLE ... ADD COLUMN only if the default is NULL, or create a default in a second step to avoid full table rewrites. For MySQL, verify storage engine and version since online DDL features differ.
Name the new column with intent. Short, consistent names reduce confusion. Match the data type to the smallest precise type possible. For timestamps, pick UTC and enforce it. For booleans, choose clear defaults.