The query landed. The schema didn’t match. You needed a new column, and you needed it without breaking production.
Adding a new column to a database seems simple, but execution matters. The right approach keeps downtime at zero, migration clean, and data safe. The wrong approach locks tables, blocks writes, or even loses data.
A new column can be created with standard SQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In development, this is instant. In production with large datasets, it’s different. Some database engines lock the table during ALTER TABLE, halting reads and writes until the change finishes. Others allow concurrent DDL, but only under specific conditions.
For PostgreSQL, ADD COLUMN with a NULL default is fast. It updates only the schema metadata. Adding a DEFAULT with a non-null value is slower—it rewrites the table. MySQL behaves similarly, but engine choice matters. InnoDB’s instant DDL can skip the rewrite for some column types. Migrations need to be tested for your version and configuration.