Adding a new column seems simple. In production, it is not. Schema changes carry risk. If the database is large, blocking writes or reads is expensive. A poorly planned ALTER TABLE can lock rows for minutes or hours. Downtime follows.
To add a new column safely, start small. Write an idempotent migration script. If you use Postgres, add the column with ALTER TABLE ... ADD COLUMN in a transaction when possible. For massive datasets, break the change into steps. Deploy the empty column first. Backfill data in batches with a low lock timeout. Then set defaults and constraints after the backfill.
Nullability matters. Adding a NOT NULL column without a default will fail if existing rows don’t comply. Adding a default may rewrite the table depending on the database engine. Check your server version. Modern Postgres versions can set a constant default instantly, older ones cannot.
For MySQL, watch out for storage engine differences. InnoDB often rewrites the entire table on schema change. Use tools like pt-online-schema-change or gh-ost to run the migration without downtime. Monitor replication lag if you use read replicas.