The table was failing under the weight of its data. You needed a fix, and it had to work without breaking production. The answer was simple: add a new column.
A new column is one of the most common schema changes in any database. It sounds small, but it changes the shape of your data and the way your application reads, writes, and stores information. Done right, it unlocks new features and optimizations. Done wrong, it can lock queries, block writes, and bring down a service.
The process starts with precision. Decide the column name and data type. Consider nullability. If the column must be not null, set a default value or use a two-step migration. Indexes should be added only if proven necessary; the wrong index can cause performance hits.
In relational databases like PostgreSQL or MySQL, adding a new column with a default and not null in one step often rewrites the whole table. That means a table lock and potential downtime. The safer pattern: