Adding a new column seems simple. It isn’t. In production, the wrong approach will lock tables, block writes, or blow up replication lag. The cost is downtime, angry users, and late nights. The right approach keeps the system online and the data consistent.
First, decide how to define the new column. In SQL, you use ALTER TABLE to add it. On large datasets, this command can be destructive unless the engine supports online schema changes. PostgreSQL 11 and later can add nullable columns with default values almost instantly, but anything more complex—foreign keys, computed values—may trigger a full table rewrite. MySQL’s ALTER TABLE is even trickier without tools like pt-online-schema-change or gh-ost.
Second, set the column properties. Ask if it should be nullable. Adding a non-null column with no default will fail if rows already exist. Adding one with a default might lock the table while retrofilling data. The safer path is to start nullable, backfill asynchronously, and then enforce constraints in a later migration.