Adding a new column to a database table should be simple. In reality, it can introduce downtime, lock tables, and break production code. The safe way to add a new column depends on your database engine, schema evolution strategy, and deployment process.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast when the column includes no default value or constraints. Adding a default and NOT NULL can trigger a full table rewrite. In MySQL, some storage engines allow instant column addition, while others require a table copy. Tools like pt-online-schema-change or gh-ost can reduce lock time, but they add operational complexity.
When designing migrations, always introduce a new column in stages. First, add it as nullable without a default. Deploy code that can read and write the column, but does not require it. Backfill data in small batches to avoid locking. Finally, enforce the constraint when the application no longer depends on null values.