Adding a new column to a database table looks simple. It is not always simple in production. The wrong approach locks tables, stalls writes, or triggers replication lag. The right approach is fast, safe, and predictable.
First, define the new column in your migration file. Use explicit data types. Avoid TEXT or BLOB unless required. Choose NULL or NOT NULL at creation, not later, to prevent table rewrites. If you need a default value, set it in the migration so new rows get the correct data from the start.
Second, measure the migration impact. On small tables, ALTER TABLE ADD COLUMN runs instantly. On large ones, this can cause downtime. Use online DDL tools like pt-online-schema-change for MySQL or ALTER TABLE ... ADD COLUMN IF NOT EXISTS in Postgres with concurrent operations when possible. Test on a cloned production dataset to see exact execution time.
Third, backfill carefully. Do not update all rows in a single transaction on large tables. Batch updates. Commit after each batch to free locks and reduce replication pressure. Monitor CPU, I/O, and replication delay during the process.