prisma-driver-adapter-implementation

Implements Prisma ORM 7 SQL driver adapters with transaction, savepoint, and error-mapping contracts.

Updated Aug 20, 2026
One-click install
npx skills add https://github.com/rhorba/RestoLedger --skill prisma-driver-adapter-implementation-rhorba
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prisma-driver-adapter-implementation
Source: https://github.com/rhorba/RestoLedger/tree/main/api/.windsurf/skills/prisma-driver-adapter-implementation
Command: npx skills add https://github.com/rhorba/RestoLedger --skill prisma-driver-adapter-implementation-rhorba

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @prisma/driver-adapter-utils.

What problem does it solve? Building a Prisma SQL driver adapter is error-prone: type-compatible code can still corrupt values, leak connections, break transactions, or lose original database error details. This Skill provides the exact contract, priority rules, and verification checklist for implementing adapters against @prisma/driver-adapter-utils in Prisma ORM 7. ## Core Features & Use Cases - Contract Implementation: Guides implementation of SqlDriverAdapterFactory, SqlDriverAdapter, Transaction, and optional savepoint hooks with correct connection lifecycle. - Result & Error Mapping: Covers argument mapping, column type mapping to ColumnTypeEnum, and DriverAdapterError conversion that preserves original database error codes for useful P2039 fallbacks. - Transaction Safety: Enforces one dedicated connection per transaction, lifecycle-only commit/rollback hooks, and connection-local savepoint handling. - Use Case: You are adding a new database driver to Prisma. Use this Skill to implement the adapter, map driver errors correctly, support nested transactions via savepoints, and validate shadow database behavior for Migrate. ## Quick Start Ask the AI to implement a Prisma driver adapter for your database driver following this guide, including transaction lifecycle, savepoint support, and error mapping.

Frequently Asked Questions about prisma-driver-adapter-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a Prisma driver adapter for a new database?

Implement SqlDriverAdapterFactory and SqlDriverAdapter from @prisma/driver-adapter-utils, providing queryRaw, executeRaw, executeScript, and startTransaction. Map arguments using both value and ArgType, return column metadata in array row mode, and wrap driver errors in DriverAdapterError.

How do Prisma driver adapter transactions and savepoints work?

startTransaction must acquire one dedicated connection, issue BEGIN, apply the isolation level, and return a Transaction bound to that connection. commit and rollback are lifecycle cleanup hooks only; Prisma issues the SQL COMMIT or ROLLBACK itself, and savepoints are optional methods on the Transaction object.

Does the Prisma driver adapter support nested transactions?

Yes, through optional createSavepoint, rollbackToSavepoint, and releaseSavepoint methods on the Transaction object. Implement them only where the provider supports savepoints, validate identifiers, and never track transaction depth on the shared adapter.

Why does my Prisma adapter throw P2039 errors?

P2039 surfaces when an unmapped driver error reaches Prisma. Preserve originalCode and originalMessage in your DriverAdapterError conversion so the fallback remains useful, and rethrow genuinely unexpected non-driver errors instead of fabricating GenericJs ids.

What is a shadow database in Prisma driver adapters?

A shadow database is an isolated database used by Prisma Migrate, created via connectToShadowDb on SqlMigrationAwareDriverAdapterFactory. It must use cryptographically unique quoted names, never point at the primary database, and be dropped during disposal or failure cleanup.