The schema was perfect, except it needed one more field. You had to add a new column.
Adding a new column sounds simple. In production, it can break everything if done wrong. How you alter a table matters for performance, reliability, and uptime.
When you add a new column in SQL, you create a new field in your table definition. The exact command depends on your database, but the pattern is the same:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In PostgreSQL, this change writes a new schema record instantly if the column is nullable or has a default that doesn’t force a table rewrite. If you add a non-null column with no default, you must backfill data. For large tables, this can lock writes and stall queries.
MySQL handles some new column operations differently. Certain types require copying the full table, which can be slow and dangerous under load. Using ALGORITHM=INPLACE can reduce downtime, but only if your storage engine supports it. Always check the execution plan before running ALTER TABLE on production data.