The query ran. The table was big. You needed a new column, and you needed it fast.
Adding a new column sounds simple. In production, it can break everything if done wrong. Schema changes can lock tables, increase latency, and create migration bottlenecks. The safest way is to understand how your database handles schema modifications and plan for zero downtime.
First, decide the column’s data type. Using the right type from the start prevents expensive future conversions. Avoid generic types if you know the exact constraints. For example, use INT instead of TEXT for numeric IDs, or VARCHAR(255) instead of unlimited strings.
Second, consider defaults and nullability. Setting a default value avoids NULL-related bugs on existing rows. But assigning a default can cause a full table rewrite in some databases. Check the documentation for your engine—PostgreSQL, MySQL, MariaDB, or others—before applying the change.