The schema had been stable for months. Then the feature request landed. You needed a new column.
Adding a new column sounds simple, but in production systems it can cause downtime, lock tables, and break integrations. Whether it’s PostgreSQL, MySQL, or a distributed database, a careless schema change can stall queries and block writes. The goal is to ship it fast and with zero user impact.
Plan the change. Start by confirming the column’s data type, nullability, and default values. Defaults trigger a full table rewrite in some engines, so consider adding the column as nullable first, then backfilling in small batches, and finally setting constraints. This three-step migration avoids long locks and keeps the database responsive.
If the table is large, use online schema change tools like gh-ost or pt-online-schema-change for MySQL, or logical replication for PostgreSQL. Always test in a staging environment with realistic data volumes. Monitor performance metrics during and after the migration.