The query ran. The results came back. One column was missing.
Adding a new column is a standard operation, but the wrong approach can bring down production. Schema changes are not just code edits—they are changes to the heartbeat of your database. The faster and larger the dataset, the greater the risk of lock contention, slow queries, and failed writes.
A NEW COLUMN should be introduced with precision. In SQL, ALTER TABLE is the direct tool. For small tables, this is instant. On large tables in PostgreSQL or MySQL, it can lock writes for longer than your SLOs permit. That’s why online schema migration tools like pt-online-schema-change or gh-ost exist—to create a shadow table, copy rows incrementally, and swap when ready.
When adding a new column in PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP WITH TIME ZONE DEFAULT NOW();
Be aware that adding a DEFAULT with a non-null value rewrites the table in older versions. In Postgres 11+, constant defaults are metadata-only and avoid the rewrite. MySQL behaves differently—adding a column can still rebuild the table depending on storage engine and options.