Skip to content

Upgrade Prisma to 7.10.0 and make document types accountable #198

Description

@HMarzban

Goal

Raise @docs.plus/hocuspocus from Prisma 6.19.3 to 7.10.0. Make the Prisma schema the only owner of document row types. Keep Zod as the write contract. Keep webapp and admin on wire types only.

Facts (2026-08-27)

  • Pins today: prisma, @prisma/client, and @prisma/adapter-pg at ^6.19.3. Lock resolves 6.19.3.
  • Latest generally available Prisma is 7.10.0 (npm dist-tag prev). 7.10.0 · Upgrade to v7
  • npm latest is Prisma 8 RC (8.0.0-rc.12 on this date). Do not take 8. Pin 7.10.0. Never write prisma@latest.
  • The adapter path is already live. src/lib/prisma.ts constructs PrismaPg and passes adapter into PrismaClient.
  • Generator is still prisma-client-js with previewFeatures = ["fullTextSearchPostgres"]. Prisma 7 wants prisma-client, a required output, and prisma.config.ts.
  • Six sites hardcode bunx prisma@6.19.3: Docker generate, entrypoint, compose migrate, start-production.ts, and fix-migration.ts. scripts/setup.sh still says 6.19.0. Move them together or boot drifts.
  • Settings search uses { search: } on title, keywords, and description. Confirm that filter after the bump.
  • $on('query'|'error'|'warn' as never, …) is a typing workaround. Re-type it on the v7 client.
  • Root deepmerge-ts@8.0.1 exists because Prisma 6's @prisma/config pulled 7.1.5. Drop the pin only after Prisma 7 stays green under bun audit.
  • Inside hocuspocus, production already imports DocumentMetadata from @prisma/client. A hand copy in src/types/document.types.ts omits deletedAt and must go.
  • Zod document.schema.ts is the write contract. keywords is string[] on the wire and String? in Prisma. The service already splits CSV. Keep that transform.
  • Webapp and admin never import @prisma/client. That split stays. fetchDocument.ts still types the slug payload with [key: string]: any. VersionTrigger is copied in webapp types/history.ts.
  • DocumentClientAuthor.clientId is BigInt in Prisma and number on the wire. Document that contract. Do not change it silently.
  • DocumentMetadata.email is the one stale cross-store copy. Dropping it is a later change. Not this ticket.
  • Storage design stays: one full Yjs snapshot per version. @@index([documentId]) stays. See apps/hocuspocus.server/CLAUDE.md.
  • Upgrade Bun to 1.4 and measure test plus backend wins #171 already says do not replace Prisma with Bun.SQL. This ticket is the Prisma bump. Upgrade Bun to 1.4 and measure test plus backend wins #171 is not this work.

Backlog row: O8 in BACKLOG-hocuspocus-backend.md.

What to build

One change. Bump and type accountability land together.

  1. Pin prisma, @prisma/client, and @prisma/adapter-pg to 7.10.0. Add prisma.config.ts. Switch the generator. Point every import at the new client output.
  2. Replace every hardcoded bunx prisma@6.19.3 (and the 6.19.0 setup hint) with the new pin in the same change.
  3. Keep the existing PrismaPg pool. Do not invent a second pool. Strip connection_limit from any URL the CLI migrate path still sees, if 7 rejects it.
  4. Confirm Settings search, persist (a version row), and every P2002 cede still behave. Re-type $on. Re-check Bytes / Uint8Array on FOR UPDATE raw reads.
  5. Delete the hand DocumentMetadata. Use generated Prisma types inside hocuspocus only.
  6. Keep Zod as the only write contract. Deduplicate VersionTrigger so webapp imports the wire union, not a second literal.
  7. Close fetchDocument.ts's index signature. Type the slug-read DTO as the fields the route actually returns.
  8. Re-check deepmerge-ts after the bump. Keep or drop the pin from bun audit, not from a blog.

Out of scope

  • Prisma 8, including a side-by-side @prisma/prisma7 install.
  • Storage redesign, delta snapshots, or dropping @@index([documentId]).
  • A new workspace types package.
  • Importing @prisma/client into webapp or admin.
  • Dropping DocumentMetadata.email.
  • Replacing Prisma with Bun.SQL (that is a Upgrade Bun to 1.4 and measure test plus backend wins #171 ban).
  • Dynamic slugs.

Acceptance criteria

  • prisma -v and @prisma/client are 7.10.0. No prisma@6.19 string remains in Docker, compose, entrypoint, or start scripts.
  • prisma generate and prisma migrate deploy work locally and in the image. REST on :4000, WS, and worker start.
  • Settings search still returns matches. A pad persist still mints a Documents row. A slug P2002 cede still returns.
  • hocuspocus bun test is green. The store-pipeline or versions e2e that you can run locally is green.
  • No hand DocumentMetadata. Webapp and admin still have zero @prisma/client imports.
  • fetchDocument has no [key: string]: any. VersionTrigger has one source.
  • bun audit result for deepmerge-ts / @prisma/config is recorded. The pin is kept or dropped from that result.

Blocked by

None. Can start immediately. Does not depend on #171 or #172. Do not fold this into the Bun soak.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DevOpsdependenciesPull requests that update a dependency fileenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions