Skip to content

feat!: migrate yates to Prisma 7 with nested transaction support#136

Open
LucianBuzzo wants to merge 1 commit into
masterfrom
lucianbuzzo/upgrade-yates-to-latest-prisma-breaking-for-performance
Open

feat!: migrate yates to Prisma 7 with nested transaction support#136
LucianBuzzo wants to merge 1 commit into
masterfrom
lucianbuzzo/upgrade-yates-to-latest-prisma-breaking-for-performance

Conversation

@LucianBuzzo

Copy link
Copy Markdown
Contributor

🐦‍⬛ Co-authored with Gravious.

Summary

This PR upgrades Yates to Prisma 7 and removes the legacy transaction workaround path in favor of Prisma 7-compatible behavior, while preserving Yates RLS guarantees.

Highlights

  • Upgrade to Prisma 7 (prisma, @prisma/client)
  • Adopt Prisma Postgres adapter (@prisma/adapter-pg + pg)
  • Migrate Prisma config to prisma.config.ts (primary + secondary schemas)
  • Replace legacy custom batching/transaction internals with Prisma 7-compatible extension flow
  • Restore/correct nested transaction semantics with Yates enabled
  • Add dedicated extension tests and expand nested transaction coverage
  • Fix Prisma 7 compatibility issues in expression tokenization and pg catalog raw-query handling
  • Normalize brittle test assertions for Prisma 7 error-message wording
  • Fix Jest open-handle warning by ensuring test client teardown + adapter idle-exit behavior

Migration Guide

A full migration guide is included in this PR:

  • MIGRATION.md

It covers:

  • required dependency upgrades
  • Prisma 7 datasource/config migration (prisma.config.ts)
  • adapter-based Prisma client construction
  • transaction behavior notes
  • validation checklist and troubleshooting

Breaking Changes

  • Yates now targets Prisma 7+
  • PostgreSQL client setup requires Prisma’s Postgres adapter

Validation

  • npm run lint
  • npm run test:types
  • npm run test:integration ✅ (all suites passing)

Summary
- Upgrade Yates to Prisma 7 and migrate runtime/client setup to the Prisma Postgres adapter.
- Replace legacy transaction workaround paths with Prisma 7-compatible extension behavior.
- Add a migration guide and refresh README prerequisites/example for Prisma 7.
- Expand integration coverage for nested interactive transaction scenarios and extension behavior.

Why
- Prisma 7 provides performance improvements and supports nested transactions needed by Yates.
- Existing internals relied on older Prisma private/runtime behavior and became brittle or incompatible.
- Consumers need a clear migration path for adapter config, Prisma config files, and test expectations.

Details
- Dependencies: upgraded `prisma` + `@prisma/client` to v7 and added `@prisma/adapter-pg` + `pg`.
- Added `prisma.config.ts` for primary/secondary schemas and moved datasource URLs out of schema blocks.
- Introduced `src/prisma-client.ts` factory using `PrismaPg` adapter.
- Updated Yates transaction execution path to correctly reuse interactive transaction context.
- Removed middleware-focused integration test and added extension-focused integration tests.
- Added/expanded nested transaction tests (rollback, deep nesting, sequential nested tx, concurrent top-level tx with nested children).
- Fixed Prisma 7 compatibility issues:
  - relation filter tokenization shape changes in expressions
  - pg_catalog raw query deserialization with explicit casts/selects
  - brittle exact error-message assertions in tests
- Added `MIGRATION.md` and linked it from README.
- Fixed Jest open-handle warning by ensuring test-created Prisma clients are tracked/disconnected and adapter config allows idle exit in test flows.

Testing
- npm run lint
- npm run test:types
- npm run test:integration
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedprisma@​5.1.0 ⏵ 7.7.075 -11009798100
Added@​prisma/​client-runtime-utils@​7.7.010010077100100
Added@​prisma/​adapter-pg@​7.7.01001008398100
Updated@​prisma/​client@​5.11.0 ⏵ 7.7.099 +610085 +298100
Addedpg@​8.20.0991009989100

View full report

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