prisma-driver-adapter-implementation

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

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

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, lifecycle rules, and verification checklist needed to implement adapters that behave correctly with Prisma ORM 7. ## Core Features & Use Cases - Adapter Contract Implementation: Guides implementation of SqlDriverAdapterFactory, SqlDriverAdapter, Transaction, and migration-aware shadow database factories. - Transaction & Savepoint Protocol: Enforces one dedicated connection per transaction, correct commit/rollback lifecycle hooks, and connection-local savepoint handling. - Error & Result Mapping: Preserves original database error codes for useful P2039 fallbacks and maps column types, arguments, and native types without silent corruption. - Use Case: When adding a new database driver to Prisma, use this Skill to implement the adapter, wire nested transactions, and validate behavior against the verification checklist before running Prisma Client integration tests. ## Quick Start Ask the AI to implement a Prisma driver adapter for your database following this guide, including transaction lifecycle, savepoints, 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 with a connect method returning a SqlDriverAdapter that provides queryRaw, executeRaw, executeScript, startTransaction, and dispose. Match the exact @prisma/driver-adapter-utils version of your target Prisma release and follow the transaction and error-mapping contracts.

How do Prisma driver adapter transactions and savepoints work?▼

startTransaction acquires one dedicated connection, issues BEGIN, applies the isolation level, and returns a Transaction bound to that connection. commit and rollback are lifecycle cleanup hooks only, while optional createSavepoint, rollbackToSavepoint, and releaseSavepoint methods handle nested transactions.

Does the Prisma driver adapter support shadow databases for migrations?▼

Yes, by implementing SqlMigrationAwareDriverAdapterFactory with connectToShadowDb, which must create an isolated shadow database, connect to it, and drop it during disposal or failure cleanup. Never point the shadow adapter at the primary database.

Why does my Prisma adapter throw P2039 errors?▼

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

What are common mistakes when writing a Prisma driver adapter?▼

Common mistakes include sharing connections across concurrent transactions, issuing duplicate SQL COMMIT or ROLLBACK in lifecycle hooks, tracking savepoint depth globally on the adapter, splitting scripts naively on semicolons, and truncating 64-bit integers during result mapping.