The table was built years ago, but today you need a new column. You open the migration file. You type fast. The schema must change, and it must change without breaking the world.
A new column in a database is simple in concept. It’s a blank space that holds new data. But in production, the choice is more than syntax. You decide the name, type, default value, constraints. You plan the migration path. You think about nulls. You think about locks. You think about the queries that will fail if you are careless.
To add a new column with SQL, you use ALTER TABLE. This works in every major relational database:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
That’s the easy part. The hard part is everything that follows. The deployment window, the migration order, the rollout of code that uses the new column. You need backward-compatible changes so the app runs during rollout. You may write the column as nullable first, backfill with a script, then make it NOT NULL once the data is ready.
For PostgreSQL, adding a new column with a default can lock the table. In MySQL, large tables can stall queries during the alter. Cloud-managed databases may hide some of this, but they never remove the need for care.