Adding a new column in a production database is simple in theory, dangerous in practice. Done wrong, it locks tables, blocks writes, and slows every request. Done right, it’s invisible to users and keeps the system fast under load.
First, define the column in your migration with an explicit type. Always set nullability and defaults with care—defaults on large tables can trigger a full rewrite. If the column does not need an immediate default value, add it later in a separate step to avoid downtime.
Run migrations during low-traffic windows or with online schema change tools. In MySQL, ALTER TABLE ... ADD COLUMN can still lock the table; use pt-online-schema-change or gh-ost to run it without blocking. In PostgreSQL, adding a column without a default is usually instant, but adding a default with a non-null constraint rewrites data—plan accordingly.