Adding a column in a production database is simple in syntax but heavy with impact. The change touches schema, storage, indexes, and every query that runs against it. Done right, it scales. Done wrong, it locks rows, stalls API calls, and sends error logs pouring in.
First, define the column with precision. A clear name, correct data type, and proper constraints prevent migrations from turning into rewrites. Common column types like INTEGER, VARCHAR, or TIMESTAMP cover most needs, but avoid defaults that hide bad data. Nullability must be a deliberate choice.
Second, plan the migration path. In PostgreSQL, ALTER TABLE ADD COLUMN is fast if you don’t set a default value; otherwise it can trigger a full table rewrite. MySQL can behave differently depending on the engine—InnoDB handles some operations online, others block. For massive datasets, online schema change tools like gh-ost or pt-online-schema-change can add a new column without downtime.