Adding a new column to a production database can look trivial, but the consequences ripple through every layer of the stack. It changes the schema, triggers application updates, and impacts query performance. The goal is to make the change safe, reversible, and invisible to users until it needs to be visible.
Start by inspecting the existing schema in your database. Identify the table, confirm column names, types, and indexes. Decide whether the new column should allow NULL values or require a default. A default value can protect inserts from failing but may lock tables during migration if applied at scale.
For large datasets, use an online schema change technique. On MySQL, tools like pt-online-schema-change or gh-ost let you add a column without long table locks. On PostgreSQL, adding a nullable column with no default is fast. Adding a default to an existing column rewrites rows, so plan to populate it in small batches after the column exists.
Update your application models and API contracts in parallel. Feature-flag any code paths that depend on the new column so you can deploy without breaking older versions. Keep backwards compatibility until all clients are upgraded.