Adding a new column in a production database is simple in theory, but doing it safely under load requires precision. The wrong step can lock tables, break queries, or corrupt analytics. The right step keeps your application online without a single failed request.
First, identify the exact column name and data type. Use consistent naming rules to avoid guesswork later. Second, choose a default value only if it is lightweight to set. Heavy defaults trigger a full table rewrite in many engines, which blocks writes and slows reads.
On PostgreSQL, ALTER TABLE ADD COLUMN is fast for nullable columns without defaults. For MySQL with large tables, use tools like pt-online-schema-change or native ALTER TABLE ... ALGORITHM=INPLACE when supported. These approaches reduce locking and keep transactions moving.