The migration was supposed to be routine. One more table change, a quick push to production. Then the request came: Add a new column.
Adding a new column can be simple. It can also break everything if you miss the details. The difference is how you plan and execute. Schema changes must match your application logic, data flow, and deployment process.
Start by defining exactly what the new column will store and how it will be used. Pick the right data type. If it needs indexing, decide before creation, not after. If it requires a default value, define it explicitly to avoid null handling issues.
In SQL, the core operation looks like:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
For large datasets, run this with care. Some engines will lock the table while altering, causing downtime. Use tools like pt-online-schema-change or native database features for online migrations. Verify if your database supports instant column addition without a full table rewrite.