~learn.
0:00 / 1:07
W09 · Multi-tenancy and security

A migration failed on tenant schema 4,000 of 10,000

transcript

You run one migration across 10,000 tenants. It fails on number 4,000. Now what state are you in?

Schema per tenant. One database, and each tenant gets its own schema. Each connection points at its tenant. Acme's queries land in Acme's schema. Database-level isolation. Per-tenant backups. Tidy.

The migration loops over every schema, one by one. Set the path. Run the change. 3,999 done. Schema 4,000 fails. The error is raised. And nothing wrapped the whole run in one transaction.

So the first 3,999 tenants have the new structure. The rest don't. Same app, two shapes of tenant.

Go further: a database per tenant. The shared pool held at most 20 connections. Now each tenant gets its own pool of up to 10. Pools can't share across databases. 500 tenants: about 5,000.

Each step up the spectrum isolates more. And costs more. That's what migrations get complex really means.

Full breakdown in the lecture.