Choosing an isolation model you can still defend once the fleet grows
There are three common shapes. A shared schema with a tenant column, a schema per tenant, or a database per tenant. Shared is cheapest to operate and carries the highest consequence for a single missing filter. Database per tenant gives clean isolation and easy per customer restore, at the price of painful migrations across a growing fleet. Schema per tenant sits between them and inherits some of both problems. There is no universally correct answer, only one that fits the customers you expect and the guarantees you will have to make.
Whatever is chosen, the enforcement should exist in exactly one place. A tenant filter applied by hand in every query will eventually be forgotten in one of them, and that one will turn out to be a report or an export where the consequence is widest. Row level security in the database, or a mandatory scope in the data access layer that a query cannot bypass, moves the guarantee from discipline to structure. Tests should include a deliberate attempt to read another tenant's data through every entry point.
Background work is where isolation quietly breaks. A request carries a tenant context naturally, because it arrived with one. A queued job, a scheduled task or an administrative script does not, unless somebody designed it to. Most cross tenant incidents originate in a report generator, a nightly export or an internal support tool rather than in the main application path. Those deserve the same enforcement and the same tests, and they are usually written later by someone treating them as throwaway tooling.
- Isolation model chosen against expected customer size, restore needs and compliance promises
- Enforcement placed in one layer, so no individual query can omit the tenant scope
- Background jobs, scheduled tasks and exports carrying explicit tenant context
- Cross tenant access attempted deliberately in tests, through every entry point
- Per tenant restore rehearsed where the isolation model is supposed to make it easy