You need: more than one Worker.
Sharing is the default, not a mode
The data layer is what sits on top, migrations is what runs once across the set, pithy migrate is the command, and adding a second Worker is how you get two in the first place.
Two Workers that declare the same binding name share one database. There is nothing to switch on. Not sharing is the one thing you declare, below.
Most capabilities default to DB, the shared app database, precisely so that an admin Worker and an API Worker read the same rows without wiring.
Prefixes are what make it safe
Every capability’s tables are pithy_<name>_*.
That prefix is the same segment that is the pithy add argument, the migration namespace, the error-code domain, the audit-action domain and the catalog key — one rule, five places, so one capability’s tables cannot collide with another’s or with yours.
Your own tables carry no pithy_ prefix, which is what keeps them yours.
Migrations run per database, not per Worker
pithy migrate--worker narrows what is reported and which databases are visited. It never narrows the registry a visited database runs — because a shared database’s ledger holds both Workers’ migrations, and a partial provider reads as corrupted state.
The registry, the ordering and the per-database runs are identical everywhere. Only the driver differs: locally through Miniflare against the same store wrangler dev reads; remotely over the D1 API against the database that environment’s config names. You pass no ids.
Ownership is stamped
A database carries an ownership stamp, so a second project pointed at somebody else’s database is caught rather than migrated into.
worker is the only thing telling events apart
Two Workers sharing a database write audit rows into one table.
project, environment and worker are stamped by the recorder from the Worker’s own vars — never by the emitter, which has no way to set them and no way to override them.
Without worker, two Workers’ events are indistinguishable. With it, what did the admin Worker do is a query.
Which capability composes where
Each Worker has its own config and composes its own capabilities.
A capability composed on one Worker and not the other still has its tables in the shared database — the tables are a property of the database, and the routes are a property of the Worker.
So an admin Worker can read payments’ tables through its own routes without composing payments at all, if that is what you want. It just does not get payments’ routes, its middleware, or its entitlement resolver.
When to give something its own database
When the isolation is the point.
The secrets capability keeps a per-environment database of its own, because the master key that opens its rows is per environment.
Email’s suppression database is deliberately shared across a project’s environments — because an unsubscribe has to apply everywhere, and somebody who opted out in prod has not agreed to receive staging’s mail either.
Two answers to one question, and each is about what the data means rather than about tidiness.
For one of your own Workers, the switch is ownBindings. List a binding in that Worker’s pithy.worker.jsonc and it gets a resource of its own, while every other Worker keeps the shared one:
// apps/billing/pithy.worker.jsonc
{
"ownBindings": ["DB"]
}Its code still reads env.DB. pithy provision creates <project>-<env>-billing---db beside the shared <project>-<env>-db, and it works the same way for KV, R2 and queues. A scope: "global" binding, such as email’s suppressions, cannot be owned. Naming rules and limits has the shape.
Owning a binding a kit host binds gives the Worker that host to itself. A capability’s prebuilt host Worker, such as email’s sender, audit’s checkpointer, storage’s sweep or the secrets manager, runs its jobs against the database they were written to. So apps/billing owning DB and composing email and audit gets <project>-<env>-billing---email and <project>-<env>-billing---audit, built from its own database, origin, email theme and catalogs, with its Workflows named the same way, while every other Worker keeps the shared <project>-<env>-email and <project>-<env>-audit. pithy provision --env points each Worker’s Workflow bindings at the host that reads its database, and pithy deploy uploads it. A host that binds nothing the Worker owns stays shared. Naming rules and limits has the names.
A bucket keyed to the database’s rows follows the database. Storage’s sweep deletes every file with no row in the database it reads, and audit’s checkpoints never name the database. So a Worker that owns storage’s DB and shares STORAGE_BUCKET, or owns audit’s database and shares AUDIT_CHECKPOINTS, is refused by pithy provision, pithy deploy and pithy dev, naming the binding to add to ownBindings. Owning AUDIT_CHECKPOINTS while sharing audit’s database is refused too.
A project deployed before Worker-owned hosts existed still points the owning Worker at the shared host, which reads the other database: that Worker’s sign-in emails never send and its audit chain is never checkpointed. pithy doctor’s Kit host bindings: block names each such binding, and pithy provision --env <env> then pithy deploy --env <env> moves it to the right host.
Listing a binding later moves no rows. The Worker’s stanza still points at the shared database, so pithy provision --env refuses until you pass --repoint, and the shared database keeps its data. Copy what should follow yourself first.
Two things still treat the project as one database. The dashboard connects to one app database per environment, never per Worker, so with a Worker owning DB it covers one of the two databases, not both. And pithy remove --drop still refuses while any sibling wires the capability, even when that sibling owns its own DB.
The parameter ceiling is shared too
D1 allows 100 bound parameters per query. That is a property of the database, not of a Worker — so a shared database does not raise it, and a query built by concatenating two Workers’ filters can hit it.
Leaderboard’s 80-member segment cap is exactly this arithmetic: 100, less the 10 the my-rank path spends on filters and the tiebreak.