Adding a new column looks simple until production traffic, migration timing, and data consistency collide. The wrong approach locks tables, slows queries, and risks rollback at scale. The right process keeps uptime steady and avoids hidden performance regressions.
A new column in PostgreSQL, MySQL, or any relational database starts with defining type, constraints, and defaults. Defaults matter: adding a column with a non-null default may rewrite the entire table. That’s why many teams add it nullable first, backfill data in controlled batches, then enforce NOT NULL at the end. This minimizes lock time and avoids blocking writes.
For large datasets, online schema change tools such as pt-online-schema-change or gh-ost help. They create a shadow table with the new column, copy data incrementally, and swap tables instantly. This technique avoids downtime but adds operational complexity. Always test these migrations in staging with production-sized data.