The cursor blinked, and the schema was about to change. One command, a single migration, and the database would gain a new column.
Adding a new column should be simple, but in production systems, it carries real weight. Schema changes can block writes, lock tables, and risk downtime. The moment you alter a table with live traffic, you need to be sure the operation is safe, fast, and reversible.
A new column in SQL typically starts with ALTER TABLE. In PostgreSQL, for example:
ALTER TABLE users ADD COLUMN last_login TIMESTAMPTZ;
This operation is straightforward for small tables but can cause performance issues on large datasets. Depending on the engine, adding a column with a default value may rewrite the whole table. On MySQL with InnoDB, the default expression determines whether the change is online or blocking. On PostgreSQL, ADD COLUMN ... DEFAULT will rewrite data unless you set the default without storing it, then backfill later.
For application-level changes, always deploy schema migrations in steps. First, add the new column as nullable. Then, update the application code to populate it for new rows. Next, backfill existing rows in batches. Finally, add any constraints or indexes. This approach avoids long locks and keeps services running.