Adding a new column is never just a single line in a migration file. It is a point of friction with production data, downstream services, and every query that touches that table. The wrong approach can block writes, trigger timeouts, or corrupt data under load. The right approach keeps systems online, safe, and consistent.
A new column in SQL means modifying the table definition. The simplest form—
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
—may be fine for small datasets. But on large tables, this operation can lock reads and writes. Always check the database engine’s behavior. Postgres and MySQL handle new columns differently. In Postgres, adding a column with a default value can rewrite the whole table. In MySQL, storage engines vary in speed and lock strategy.
Before adding a new column, audit all ORM models, API contracts, and ETL scripts. Backfill logic must be explicit and idempotent. Use transactional migrations where possible. For massive datasets, consider adding the column as NULL initially, then running an async background job to populate values, and only then enforce constraints.