Adding a new column is one of the most common schema changes in any database. It sounds simple, but it has real consequences for performance, deployment, and code stability. The wrong approach can lock tables, block writes, or take down critical APIs. The right approach makes the change seamless, even in production.
First, decide the column type. Choose data types that match the stored values as closely as possible. Smaller types save space and increase cache efficiency. Define default values with care—defaults can cause full-table writes if not handled properly.
Second, run the schema change in a way that avoids downtime. In PostgreSQL, ADD COLUMN with a default value in old versions rewrites the table. In MySQL, a simple ALTER TABLE can lock the entire dataset. Use non-blocking migrations when possible. For Postgres, add the column without a default, then backfill in small batches. For MySQL, use online DDL if your version supports it, or tools like gh-ost or pt-online-schema-change.