The database table was finished, but the product needed more data. A new column had to exist — now.
Adding a new column should be fast, safe, and predictable. In most databases, the basic command is simple:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
But in production, it’s never just the SQL. You have to think about defaults, nullability, indexes, and performance. A migration that locks a table can freeze requests and drop revenue. The cost of getting it wrong grows with the size of your dataset.
Choosing the Right Data Type
Pick the smallest type that holds the data you need. Large text or blob columns will hurt storage and query speed. If you only need a date, don’t use a timestamp. If the value is boolean, make it boolean — not text or integer.
Handling Nulls and Defaults
Adding a column with a NOT NULL constraint and no default will fail if existing rows don’t meet the rule. If you need strictness, add the column nullable, backfill values in small batches, then enforce NOT NULL. Defaults can hide missing data problems, so set them deliberately.