Skip to content
0

Upgrade to KatanaKit v3 ​

This guide migrates you from 2.x to 3.x. One breaking change, and it touches the database.

bash
npm install katanakit-js@^3

Breaking 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):

ts
import { usePrisma } from "katanakit-js/prisma";

const db = usePrisma();
const user = await db.public.User.findUnique({ where: { email } });

After (3.x):

ts
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:

sql
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:

bash
npx prisma migrate dev --name rename_users_to_accounts

Prisma 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. Exposes useCan, useHasRole, useCapabilitiesFor, useRegisterRole, useRoles and useResetRoles.
  • Express access guard — useRequireCapability(capability, resolveSubject) in katanakit-js/adapters/express returns 401 for anonymous requests and 403 when the capability is missing. It plugs into the assistant router's existing guard seam and is unwired by default.

Migration checklist ​

  1. Install katanakit-js@^3.
  2. Generate or apply the users → accounts migration.
  3. Rename every db.public.User to db.public.Account.
  4. Run your test suite.

Full detail per release: changelog.

Released under the MIT License.