Adding a new column changes more than the schema. It changes queries, indexes, migrations, and the way your application communicates with data. A clean implementation reduces risk and downtime. A sloppy one can break production in seconds.
The first step is deciding the exact data type. Use the smallest type that can store the required values, and consider constraints up front. This improves performance and enforces integrity without extra code.
Next, create the migration. In SQL, a straightforward command might look like:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command works, but on large tables, it can lock writes and block traffic. Modern workflows often pair schema changes with online migrations. Tools like pt-online-schema-change or native database features allow you to add a new column without long-lived locks.
Default values need careful thought. Setting a default on a large table can rewrite every row. Sometimes it is faster to add the column as nullable, backfill in batches, and add the default after the data load completes.