Adding a new column to a database sounds simple, but in production it carries weight. Schema changes touch queries, indexes, application logic, and downstream systems. A single ALTER TABLE can block writes, lock rows, or break an API if not planned. Precision matters at every step.
Start with the schema migration. In SQL, the direct command is:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
For small tables, this runs instantly. For large ones, the impact can be severe. Always profile the table size and use online migration strategies. Tools like pt-online-schema-change or native database options for non-blocking column adds can minimize downtime.
Update ORM models and validation rules before deploying the migration. This ensures that new writes handle the new column cleanly, without creating null or inconsistent data. Document the change in version control alongside the code that depends on it.