prisma-driver-adapter-implementation

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

Updated Aug 17, 2026
One-click install
npx skills add https://github.com/Sahil-Showket/ShopSphere --skill prisma-driver-adapter-implementation-sahil-showket
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prisma-driver-adapter-implementation
Source: https://github.com/Sahil-Showket/ShopSphere/tree/main/services/product-service/.windsurf/skills/prisma-driver-adapter-implementation
Command: npx skills add https://github.com/Sahil-Showket/ShopSphere --skill prisma-driver-adapter-implementation-sahil-showket

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 needed to implement adapters that behave correctly under Prisma ORM 7. ## Core Features & Use Cases - Contract Implementation: Guides implementation of SqlDriverAdapterFactory, SqlDriverAdapter, Transaction, and optional savepoint hooks with correct lifecycle semantics. - Error & Result Mapping: Shows how to map driver values, column metadata, and database errors into DriverAdapterError while preserving original codes for useful P2039 fallbacks. - Transaction Safety: Enforces one dedicated connection per transaction, single-release commit/rollback hooks, and isolated shadow databases for migrations. - Use Case: When adding a new database driver to Prisma, follow this guide to implement queryRaw/executeRaw, nested transactions via savepoints, and shadow database support, then validate with the included checklist. ## Quick Start Ask the AI to implement a Prisma driver adapter for your database following the transaction and error-mapping rules in this guide.

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 with a connect() method returning a SqlDriverAdapter that provides queryRaw, executeRaw, executeScript, and startTransaction. Map arguments using both value and ArgType, return column metadata in array row mode, and wrap driver failures 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 hooks that release the connection once; Prisma issues the actual SQL COMMIT/ROLLBACK via executeRaw, and savepoints are optional methods on the Transaction.

Does the Prisma driver adapter support nested transactions?▼

Yes, through optional createSavepoint, rollbackToSavepoint, and releaseSavepoint methods on the Transaction object. Never track transaction depth on the shared adapter, since parallel transactions make adapter-global state incorrect.

Why does my Prisma adapter throw P2039 errors?▼

P2039 surfaces when an unmapped driver error reaches Prisma. Preserve originalCode and originalMessage in your DriverAdapterError so the fallback is useful, map known conditions like unique violations to structured MappedError kinds, and rethrow genuinely unexpected non-driver errors.

What is a shadow database in Prisma driver adapters?▼

A shadow database is an isolated database created by connectToShadowDb() on SqlMigrationAwareDriverAdapterFactory for migration validation. It must use a cryptographically unique quoted name, never point at the primary database, and be dropped during disposal or failure cleanup.