The State of Online Schema Migrations in MySQL — PlanetScale
MySQL's native INPLACE online DDL is unsuitable for non-blocking changes because it is resource-greedy, uninterruptible and blocks replicas, causing replication lag as long as the original ALTER. INSTANT DDL is ideal where supported, but it covers mostly metadata changes plus ADD/DROP COLUMN, and an instant DROP COLUMN destroys data and metadata with no built-in way back. For most ALTER TABLE changes, shadow-table tools such as Vitess, gh-ost, pt-online-schema-change and spirit remain the recommended approach: they throttle against lag, are interruptible and support almost every change type. Vitess and spirit also auto-detect INSTANT-eligible changes, and Vitess adds revertibility that preserves data.
Related posts
- Migrating Data Ingestion Systems at Meta Scale
Meta Engineering mediumAdeptMeta migrated tens of thousands of MySQL-to-warehouse change data capture (CDC) ingestion jobs, together moving several petabytes daily, from customer-owned pipelines to a self-managed warehouse service, and fully retired the legacy system. Each job went through shadow, reverse-shadow and cleanup phases, with promotion gated on matching row counts and checksums plus no regression in landing latency or resource use. Because CDC carries bad data forward into new partitions, bad partitions were flagged in metadata to halt delta landing or fall back to older target partitions, and backfills gave early rollback signals. Automated promotion/demotion tooling, batch selection that excluded jobs with known issues, and reuse of legacy snapshots cut expensive full dumps under limited capacity.
- Faster schema changes for large SQLite databases
Turso mediumAdeptSQLite re-parses the entire sqlite_schema table after every ALTER TABLE, so schema changes cost time proportional to total schema size even when only one table is touched. Turso, a Rust rewrite of SQLite, adds dedicated bytecode instructions (RenameTable, DropColumn, AddColumn, RenameColumn) that mutate the in-memory schema directly and update only the affected table's indexes in batch. Initial schema loading is also sped up by replacing the lemon-generated parser with a handwritten one, while the in-memory schema is shared across connections so later connections skip parsing entirely.
- Migrating Etsy’s database sharding to Vitess
Etsy Code as Craft mediumAdeptEtsy moved shard routing for its ~1,000-table, ~1,000-shard, 425 TB MySQL cluster (1.7M requests/sec) from an ORM that looked up random shard mappings in a single index database to Vitess vindexes, without moving any data. The ORM's shard assignment was switched to match Vitess's hash vindex, and legacy mappings were frozen into a read-only SQLite file copied onto each Vitess server. A custom hybrid vindex picks SQLite lookup or hash based on an id threshold. Tables were ramped incrementally through the experimentation framework with instant rollback, though 27 transaction-coupled models carrying a third of traffic had to move together to preserve per-connection atomicity. The five-year effort removed a single point of failure, cut re-sharding from months to days, and enabled opt-in scatter queries; one query dropped from ~2 s to ~20 ms, and bulk primary-key lookups needed far fewer queries.
- How to Deploy Schema Changes to a Million Databases
Turso mediumAdeptDatabase-per-tenant schema migrations can scale to millions of databases by inverting control: a hosted schema registry stores a versioned catalog of SQL scripts, and each client periodically reports its schema version, pulls the missing migrations and applies them locally. The registry needs only a simple migrations table, with no per-tenant state or distributed locks. Check-in timing (before critical operations, daily, or on user workflows) trades consistency against performance. The pull model suits offline-first apps that reconnect several versions behind, and a proof-of-concept is written in Go with SQLite.
- Safely Adding NOT NULL Columns to Your Database Tables
Shopify Engineering mediumAdeptAdding a NOT NULL column through LHM's shadow-table migration (new table, replication triggers, batched copy, rename) can break writes or silently lose data depending on the DEFAULT clause, an added UNIQUE INDEX and the MySQL SQL mode. Shopify's experiment matrix shows that without a DEFAULT, strict mode makes trigger-propagated INSERT/UPDATE/DELETE fail, while non-strict mode fills rows with implicit defaults such as the empty string. Adding a UNIQUE INDEX in the same migration loses rows on INSERT and UPDATE whenever duplicates exist. Always specify a DEFAULT for new NOT NULL columns, and check for duplicate values before adding a unique index.