Adding a new column is never just about adding data. It is a structural change. It affects query performance, migrations, indexing, and even deployment strategies. Done wrong, it brings downtime, broken features, and rolled-back releases. Done right, it is seamless. Invisible to the end user.
Start with the data type. Choose it for precision, storage cost, and query speed. Avoid defaults that lock you in. Decide if the column allows NULL. A nullable column can make the migration faster, but it can also add complexity in application logic.
Next, plan the migration path. On large tables, ALTER TABLE ADD COLUMN can lock writes. For zero-downtime deployments, break it into steps:
- Add the new column as nullable.
- Deploy code that writes to old and new columns.
- Backfill data in small batches.
- Switch reads to the new column.
- Remove old logic.
Index only if needed. An index on a new column speeds lookups but slows writes. Test real-world queries before committing.