Adding a new column is one of the most common schema changes in production databases. It sounds routine, but done carelessly, it can slow queries, lock tables, or break dependent services. The goal is to alter the table without downtime, maintain data integrity, and keep the system responsive under load.
Start by defining the column type and constraints. Avoid guessing—choose data types that match the existing model and expected ranges. If defaults are required, decide if they can be set at creation or need backfill in stages to avoid large writes in a single transaction.
In PostgreSQL, ALTER TABLE table_name ADD COLUMN column_name data_type; is the basic command. In MySQL, the syntax is similar. What matters is testing the migration in a staging environment with realistic data. For large tables, add the column without defaults or indexes first. Then backfill in batches and add constraints or indexes after. This limits write locks and minimizes replication lag.