Skip to content

refactor(prisma-adapter): separate event/snapshot/view tables#81

Merged
tonyfromundefined merged 2 commits intomainfrom
tony/prisma-adapter-refactor
Mar 22, 2026
Merged

refactor(prisma-adapter): separate event/snapshot/view tables#81
tonyfromundefined merged 2 commits intomainfrom
tony/prisma-adapter-refactor

Conversation

@tonyfromundefined
Copy link
Copy Markdown
Member

Refactors the Prisma adapter to clearly separate three distinct tables: event (append-only log), snapshot (periodic state snapshots for replay optimization), and view (query projection).

Snapshot has a fixed BaseSnapshotRow structure (entityId, entityName, state, version) — no user-defined mapping needed — while view remains flexible via entityToViewRow. A snapshotEvery option controls how often snapshots are written (every N events, in the same transaction). getSnapshot() from the Adapter interface is now implemented. All where clauses use entityId directly, removing the id column mapping assumption.

…apshot structure

- Split the single snapshot table into three tables: event, snapshot, view
- snapshot: periodic state snapshots (every N events via snapshotEvery option) with fixed BaseSnapshotRow structure (entityId, entityName, state, version)
- view: query projection with user-defined entityToViewRow mapping
- Add getSnapshot() implementing Adapter interface using snapshot table
- Use entityId directly in where clauses instead of mapping to id column
- Add $$PrismaSnapshotRow/$$PrismaSnapshotRowInput generics for snapshot table (consistent with event row pattern)
- Rename BaseEventTypeRow → BaseEventRow, SnapshotRow → BaseSnapshotRow

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ventyd Ready Ready Preview, Comment Mar 22, 2026 9:32am

@tonyfromundefined tonyfromundefined merged commit 31c9c89 into main Mar 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant