The query arrives. You need a new column in your database, live, without downtime. The product launch clock is ticking.
Adding a new column can be simple or fatal, depending on scale and architecture. A naive ALTER TABLE on a massive table may lock writes and stall services. Choosing the right migration strategy determines whether your system breathes or chokes.
First, define the new column with precise schema changes. For relational databases like PostgreSQL or MySQL, use SQL that fits your table’s existing constraints. For large datasets, default-less additions avoid full-table rewrites. Adding indexes and defaults should be separated into distinct migrations.
Second, stage the change. In production, online schema change tools like pt-online-schema-change, gh-ost, or pg_repack let you add columns without locking the table. For cloud-managed databases, review provider-specific migration guides—behavior differs between platforms.