Skip to content

Migrations that don't lock the table.

The most dangerous file in the repository is also the one with the least review, because it is short, it is boring, and it worked on the laptop. This is a database in your browser — a real lock manager, a cost model that knows a rewrite from a metadata change, and a workload that does not stop while your migration runs.

Correct SQL. Passes the test database.
ALTER TABLE orders
ALTER COLUMN customer_id TYPE bigint;
 
ACCESS EXCLUSIVE on orders
41,000,000 rows rewritten · 5m 58s simulated
every read and every write queued behind it, start to finish

The defect is not in the syntax. It is in the lock, the rewrite and the deploy window, and none of the three is visible without a model of the database under load. So there is one here.

Eight tracks

  • Locks

    What is waiting behind your migration?

  • Rewrite or metadata

    Is this statement copying every row?

  • Indexes

    How do you build one without stopping writes?

  • Constraints

    How do you add a rule to a table already full of rows?

  • Expand and contract

    How do you change a column the running code still reads?

  • Backfills

    How do you touch ten million rows without anybody noticing?

  • Schemaless drift

    Where does the schema go when there isn't one?

  • Reading a generated migration

    What will this do to production?

Everything you do here stays in this browser.Part of liter8.sh