Adding a new column in production is never just “one line of code.” Schema changes hit live systems. They trigger migrations, impact queries, and can spike CPU or lock tables if handled poorly. The right approach is deliberate.
First, define the column’s purpose and data type. Keep it lean—prefer native types with minimal storage cost. For example, use BOOLEAN instead of VARCHAR when your data is true/false. Every extra byte matters at scale.
Second, design the migration. In PostgreSQL or MySQL, adding a column with a default value can rewrite the entire table on disk. That’s dangerous for large datasets. Instead, add the column without a default, then update rows in batches. This avoids downtime and reduces lock contention.
Third, check indexing. Many engineers skip this until queries fail. If the new column will be part of a WHERE clause or JOIN, add the index after data population. Create it concurrently when your DB supports it to avoid blocking writes.