Adding a new column sounds simple. It’s not just syntax. It’s about keeping the database consistent, avoiding downtime, and keeping queries fast. In production, even small changes can cause incidents if they are not planned.
A new column changes the structure of your table. In SQL, the command is straightforward:
ALTER TABLE users ADD COLUMN created_at TIMESTAMP DEFAULT NOW();
But production work needs more than a statement. You must check the database engine. Some engines lock the table during ALTER, which can block writes. Others support adding columns online. In PostgreSQL, adding a nullable column or one with a constant default is usually fast, but large tables with computed defaults will lock.
If your app depends on migrations, plan them in phases. First, add the column as nullable. Then backfill in batches to avoid write spikes. Finally, add constraints or defaults. This approach reduces risk.