prisma-driver-adapter-implementation

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

Updated Aug 7, 2026
One-click install
npx skills add https://github.com/samu412/Development_kisan_basket --skill prisma-driver-adapter-implementation-samu412
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prisma-driver-adapter-implementation
Source: https://github.com/samu412/Development_kisan_basket/tree/main/category_kisan_basket/.agents/skills/prisma-driver-adapter-implementation
Command: npx skills add https://github.com/samu412/Development_kisan_basket --skill prisma-driver-adapter-implementation-samu412

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Building a Prisma 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 Prisma ORM 7 SQL driver adapters correctly. ## Core Features & Use Cases - Adapter Contract Reference: Defines SqlDriverAdapterFactory, SqlDriverAdapter, Transaction, and migration-aware factory interfaces with correct lifecycle semantics. - Transaction & Savepoint Protocol: Enforces one dedicated connection per transaction, commit/rollback as cleanup hooks, and connection-local savepoint handling. - Error & Result Mapping: Preserves original database error codes for P2039 fallback and maps column types, arguments, and native types without silent corruption. - Use Case: When adding a new database driver to Prisma or debugging P2039 errors, transaction leaks, or shadow-database failures in an existing adapter, follow this guide to implement and verify the adapter against the target @prisma/driver-adapter-utils version. ## Quick Start Ask the AI to implement a Prisma SQL driver adapter for your database driver following the transaction, savepoint, 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, 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 should transactions work in a Prisma driver adapter?

startTransaction must acquire one dedicated connection, begin the transaction, apply the isolation level, and return a Transaction bound to that connection. The commit() and rollback() methods are lifecycle cleanup hooks that release the connection once; Prisma issues the actual SQL COMMIT or ROLLBACK through executeRaw.

Does Prisma support nested transactions and savepoints in driver adapters?

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 since parallel transactions make global depth 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 conversion so P2039 carries useful details, map known conditions to structured MappedError kinds, 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.