prisma-driver-adapter-implementation

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

Updated Jul 27, 2026
One-click install
npx skills add https://github.com/Soares-B/Livia-Lace --skill prisma-driver-adapter-implementation-soares-b
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prisma-driver-adapter-implementation
Source: https://github.com/Soares-B/Livia-Lace/tree/main/livia-lace/.windsurf/skills/prisma-driver-adapter-implementation
Command: npx skills add https://github.com/Soares-B/Livia-Lace --skill prisma-driver-adapter-implementation-soares-b

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 - Adapter Contract Implementation: Guides implementation of SqlDriverAdapterFactory, SqlDriverAdapter, Transaction, and migration-aware shadow database factories. - Transaction & Savepoint Protocol: Enforces one dedicated connection per transaction, lifecycle-only commit/rollback hooks, and connection-local savepoint handling. - Error & Result Mapping: Preserves original database error codes for useful P2039 fallbacks and maps column types, arguments, and result metadata without silent corruption. - Use Case: You are writing a new database driver adapter for Prisma 7 and need to handle nested transactions, shadow databases for Migrate, and structured constraint error mapping without leaking pooled connections. ## Quick Start Ask the AI to implement a Prisma 7 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 do Prisma driver adapter transactions and savepoints work?

startTransaction must acquire one dedicated connection, begin the transaction, and apply the isolation level. commit() and rollback() are lifecycle cleanup hooks that release the connection once, while optional createSavepoint, rollbackToSavepoint, and releaseSavepoint methods handle nested transactions on that same connection.

Why does Prisma throw P2039 with my custom driver adapter?

P2039 surfaces when an unmapped driver error reaches Prisma. Preserve originalCode and originalMessage in your DriverAdapterError conversion so the fallback contains useful details, and map known conditions like unique violations to structured MappedError kinds.

Does a Prisma driver adapter need shadow database support?

Only if you want Prisma Migrate support. Implement SqlMigrationAwareDriverAdapterFactory with connectToShadowDb() that creates an isolated shadow database, connects to it, and drops it during disposal or failure cleanup, never pointing it at the primary database.

What are common mistakes when writing a Prisma driver adapter?

Common mistakes include sharing connections across parallel transactions, issuing duplicate SQL COMMIT/ROLLBACK in lifecycle hooks, splitting migration scripts naively on semicolons, truncating 64-bit integers, and replacing all unknown errors with fabricated GenericJs ids instead of rethrowing genuine programming bugs.