Adding a new column to a production database can be fast or it can cause hours of downtime. The difference is in how you plan, execute, and roll out the change. Whether it’s PostgreSQL, MySQL, or another relational system, the steps are the same: define the schema change, apply it safely, and verify the data path.
First, decide the column type, constraints, and default values. Adding NOT NULL with a default will rewrite the table, which can block writes on large datasets. To avoid that, create the column as nullable, then backfill in small batches. When the data is ready, add constraints in a second migration.
Second, ensure your application is forward-compatible. Deploy code that can handle both old and new versions of the schema before running the migration. This prevents errors when multiple app instances talk to the database during rollout.