Upgrade to KatanaKit v3
This guide migrates you from 2.x to 3.x. One breaking change, and it touches the database.
npm install katanakit-js@^3Breaking changes
Prisma model User renamed to Account (3.0.0)
In katanakit-js/prisma, the User model is now Account, mapped to the accounts table (@@map("accounts")), and Post.author points at it.
Before (2.x):
import { usePrisma } from "katanakit-js/prisma";
const db = usePrisma();
const user = await db.public.User.findUnique({ where: { email } });After (3.x):
const account = await db.public.Account.findUnique({ where: { email } });The table rename needs a migration
The database table is still called users until you rename it. On Postgres:
ALTER TABLE "users" RENAME TO "accounts";The posts.authorId foreign key keeps working — Postgres rewrites the reference when a table is renamed — but your Prisma migrations must know about it too. If you own the migration history:
npx prisma migrate dev --name rename_users_to_accountsPrisma will detect the drift and generate the migration; if you are applying this to a live database by hand, take the ALTER TABLE above and leave the migration file to the next migrate dev run.
This is the only schema-breaking change in the library
Post.authorId keeps its column name and type, and the other models (Conversation, Message) are untouched. Only users → accounts and every db.public.User reference in your code.
Added in v3
- Access-control service — a pure role/capability registry with hierarchy-based inheritance:
owner>admin>editor>author>member>guest. ExposesuseCan,useHasRole,useCapabilitiesFor,useRegisterRole,useRolesanduseResetRoles. - Express access guard —
useRequireCapability(capability, resolveSubject)inkatanakit-js/adapters/expressreturns 401 for anonymous requests and 403 when the capability is missing. It plugs into the assistant router's existingguardseam and is unwired by default.
Migration checklist
- Install
katanakit-js@^3. - Generate or apply the
users→accountsmigration. - Rename every
db.public.Usertodb.public.Account. - Run your test suite.
Full detail per release: changelog.