The query hit the database, but the schema had changed. A new column was there, waiting, unknown to the code that had called it.
Adding a new column is simple in syntax, but the real work is in making it safe, fast, and reversible. In SQL, the standard pattern is straightforward:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This runs instantly on small tables, but on large datasets it can lock writes, block reads, and cause downtime. The best approach is a staged migration. First, add the new column as nullable with no default. Then backfill in small batches. Finally, add indexes or constraints only after data is populated.
In systems with heavy traffic, consider online schema change tools like gh-ost or pt-online-schema-change to avoid blocking. For Postgres, ALTER TABLE ... ADD COLUMN is fast if no default is specified, since it stores null metadata instead of rewriting rows. Adding a default or NOT NULL constraint rewrites the entire table, so apply those in a later migration after backfilling.