Adding a new column sounds simple. It is not. Done wrong, it locks tables, blocks writes, and wakes you in the night. Done right, it runs in seconds, ships safely, and avoids downtime.
A new column in a relational database changes the schema. Whether you use PostgreSQL, MySQL, or MariaDB, the core steps are the same: define the data type, set defaults wisely, and handle constraints with care. Defaults on large tables can trigger a full rewrite. On high-traffic systems, that’s fatal. Use nullable columns or backfill in batches to avoid table locks.
Plan the migration. In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast if no default is set. For large systems, add the column as nullable, backfill data in controlled steps, and then add constraints. In MySQL, online schema change tools like pt-online-schema-change or gh-ost can keep the database live while the new column is added.
Indexing a new column should be delayed until after the backfill. Creating the index first can block inserts and updates. Consider partial indexes or expression indexes if only a subset of data needs them.