Adding a new column to a database is simple in theory, but the wrong approach can lock tables, spike latency, or crash production. The goal is to make schema changes fast, safe, and reversible without breaking the flow of reads and writes.
Start by assessing the database engine you’re using. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward and runs instantly for most column types without rewriting the whole table. In MySQL, adding a column can be blocking depending on storage engine and version. For high-traffic services, online schema change tools like gh-ost or pt-online-schema-change reduce downtime by copying data in the background and swapping tables atomically.
Define the column with care. Choose the smallest data type that fits the requirement. Set default values explicitly to avoid null surprises. Consider constraints and indexes only after the column is in place — adding indexes during the same migration compounds lock time.