Adding a new column can be simple. Doing it right, without downtime or broken code, is not. The way you handle a database schema change can decide whether your next release ships smooth or fails in production.
A new column in a relational database changes the shape of the data. It can affect indexes, queries, and application logic. Before you add it, confirm its type, defaults, and constraints match the intended use. For large tables, think about the cost of backfilling values. Avoid locking writes in high-traffic environments.
Plan the migration. In SQL, you might use:
ALTER TABLE users ADD COLUMN last_seen_at TIMESTAMP WITH TIME ZONE;
In PostgreSQL, this is fast for nullable columns without defaults. Adding a non-null column with a default rewrites the whole table. That can lock it for minutes or hours, depending on size. Break these steps apart: create the column nullable, backfill in batches, then apply constraints once data is consistent.