import { PrismaClient } from "@prisma/client";
import { migrateYates } from "@cerebruminc/yates";
const prisma = new PrismaClient();
// Deploy job: apply roles, grants, and RLS policies
await migrateYates({
prisma,
customAbilities,
getRoles,
});
await prisma.$disconnect();Cerebrum Yates · Open source
Row-level security,enforced by the database.
Yates is our open-source module for role-based access control with Prisma and PostgreSQL. Define abilities once as Prisma expressions; Postgres enforces them on every query, for every client, forever.
MIT
Open-source license
Prisma 7+
Client extension based
Postgres
Row-level security
npm
@cerebruminc/yates
From abilities to enforcement in four moves.
- 01
Define abilities
Access rules are plain Prisma where clauses — insertOwnPost, readOwnOrganization — with the request context available to each expression.
- 02
Generate the manifest
Yates derives CRUD abilities for every model in your schema, creates a Postgres role per ability, and compiles the row-level security policies to match.
- 03
Migrate at deploy
migrateYates applies roles, grants, and policies from a deploy job, right after Prisma migrations — so stale pods can never downgrade database policy.
- 04
Run with context
createYatesClient validates the applied manifest and returns a drop-in Prisma client. Per request, your getContext function sets the role; Postgres does the rest.
Built for production, not demos.
Enforced below the app
Policies live in PostgreSQL itself. A buggy query, a forgotten where clause, or a new service cannot leak rows the role cannot see.
Drop-in Prisma client
The Yates client shares the Prisma Client API and connection pool. Existing queries keep working; the enforcement is invisible until it saves you.
Fail-fast validation
validateYatesSetup and createYatesClient refuse to run against an unapplied manifest, catching deploy drift at startup instead of at audit.
Open by default
MIT licensed and developed in the open. The same module guards Cerebrum’s own production data — we eat the cooking.
Ready to integrate trust?
Get complete access to the Cerebrum platform and start verifying users in minutes.
