Adding a new column is simple. Doing it the wrong way can cost uptime, break contracts, or flood logs with errors. The right approach depends on your database engine, your schema migration strategy, and the scale of your production data.
In SQL-based systems, the ALTER TABLE command is the starting point. For small tables, a blocking alter is usually fine. On large, high-traffic tables, blocking can lock writes for minutes or hours. Use online schema change tools like pt-online-schema-change for MySQL or ALTER TABLE ... ADD COLUMN with ONLINE or CONCURRENTLY options when available. In PostgreSQL, adding a column with a default value before version 11 rewrote the whole table; now, defaults are stored in the metadata for cheaper migrations.
When creating a new column, define nullability and default values up front. Avoid backfilling large datasets in a single transaction; batch updates prevent lock contention. Index the column only if needed, as index creation can be just as expensive as adding the column itself.
In NoSQL systems like MongoDB, adding a field is schema-less by default. The challenge shifts to application code: all read and write paths must handle both the old and the new document shapes. Feature flags and staged rollouts help manage this transition.