The query ran, but the table was wrong. The missing field made the data useless. You need a new column.
Adding a new column sounds simple, but mistakes can lock tables, corrupt data, or break services mid-request. The right approach depends on your database engine, schema constraints, and uptime requirements.
In PostgreSQL, the safest way is:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP WITH TIME ZONE;
By default, this is fast because it only updates the schema. Large migrations slow down when you set a default on existing rows, which forces a table rewrite. Instead, add the column empty, backfill in batches, then add defaults and constraints in separate statements.
In MySQL, schema changes differ based on storage engine. InnoDB can do many operations instantly, but not all. Plan for ALGORITHM=INPLACE or ALGORITHM=INSTANT when possible: