Adding a new column is one of the most common schema changes in modern systems. It looks simple, but the wrong approach can lock tables, slow queries, or crash production. If you want zero downtime, you need a plan.
First, understand your schema. Check table size, indexes, and related queries. On a large table, adding a column with a default value can rewrite the entire dataset, which may block reads and writes. Avoid defaults on creation unless required. Instead, create the column as nullable, then backfill data in batches.
Next, control migrations. In SQL, the process differs between MySQL, PostgreSQL, and other engines. PostgreSQL can add a nullable column instantly. MySQL may lock depending on storage engine and configuration. Always test your migration in a staging environment with production-like data. Monitor query performance during the test.