A new column changes everything. One line in a migration file can alter the shape of your data, the speed of your queries, and the way your application works. It is simple to write, but its impact is deep.
In SQL, adding a new column means altering a table schema. This can be done with the ALTER TABLE command followed by ADD COLUMN. The definition must include the column name, data type, and constraints. For example:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
This command works fast on small datasets. On large tables, it can lock writes or even reads while the operation completes. The performance cost comes from the database rewriting part of the table to accommodate the schema change.
Before creating a new column, check the indexing strategy. Adding indexes on a new column speeds up lookups, but also increases write time and storage use. Choose index types that match the query patterns. For example, a B-tree index fits equality and range queries, while a hash index is optimized for exact matches.