prisma-driver-adapter-implementation

Implements Prisma v7 driver adapters for custom database drivers with transaction and error contracts.

Updated Jun 9, 2026
One-click install
npx skills add https://github.com/dlptho356/TTTN --skill prisma-driver-adapter-implementation-dlptho356
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prisma-driver-adapter-implementation
Source: https://github.com/dlptho356/TTTN/tree/main/DATN/backend/.windsurf/skills/prisma-driver-adapter-implementation
Command: npx skills add https://github.com/dlptho356/TTTN --skill prisma-driver-adapter-implementation-dlptho356

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Implementing a Prisma ORM v7 driver adapter requires contract details that cannot be inferred from existing code examples, such as the transaction lifecycle protocol, error mapping rules, and column type conversions. This Skill provides the complete interface definitions, implementation steps, and verification checklist needed to build a working adapter for any database. ## Core Features & Use Cases - Full Interface Reference: Covers SqlDriverAdapter, Transaction, SqlQueryable, and SqlMigrationAwareDriverAdapterFactory with TypeScript definitions and ColumnTypeEnum values. - Step-by-Step Implementation: Guides creation of the queryable base class, transaction class, adapter class, and factory class, including nested transaction savepoint handling. - Conversion and Error Mapping: Provides argument mapping, row mapping, column type inference, and driver error conversion to MappedError kinds for PostgreSQL, SQLite, and MySQL. - Use Case: You are adding support for a new database to a Prisma-based application. Use this Skill to implement the adapter factory, wire it into PrismaClient, and validate it with unit and E2E tests. ## Quick Start Ask the AI to implement a Prisma v7 driver adapter for your database driver following the interface contracts and checklist in this Skill.

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 v7 driver adapter for a custom database?

Implement four classes: a SqlQueryable base with queryRaw and executeRaw, a Transaction class with commit and rollback lifecycle hooks, a SqlDriverAdapter with executeScript and startTransaction, and a SqlMigrationAwareDriverAdapterFactory with connect and connectToShadowDb. Import all types from @prisma/driver-adapter-utils.

How do Prisma driver adapter transactions work?

The commit and rollback methods are lifecycle hooks only and must not issue SQL, because Prisma sends COMMIT and ROLLBACK via executeRaw on the transaction object. startTransaction issues BEGIN at depth one and SAVEPOINT sp_N for nested transactions.

Does the Prisma driver adapter support nested transactions?

Yes, nested transactions are handled with savepoints. The adapter tracks transaction depth, issuing BEGIN for the first level and SAVEPOINT sp_N for deeper levels, decrementing the depth counter when each transaction releases.

How do I map database errors in a Prisma driver adapter?

Convert driver errors to MappedError kinds and wrap them in DriverAdapterError. For example, PostgreSQL code 23505 maps to UniqueConstraintViolation, 23503 to ForeignKeyConstraintViolation, and 42P01 to TableDoesNotExist, with raw postgres or sqlite kinds as fallbacks.

What type conversions does a Prisma driver adapter require?

Input arguments need string-to-int, string-to-bigint, string-to-float, and base64-to-Buffer conversions. Output rows need bigint-to-string for Int64, Date-to-ISO-string for DateTime, and JSON object stringification, with column types mapped to ColumnTypeEnum values.

How do I test a Prisma driver adapter?

Use unit tests that call queryRaw, executeRaw, and startTransaction directly against the raw database driver without PrismaClient. Then run E2E tests with a real PrismaClient constructed with your adapter factory to verify CRUD operations and transaction rollback behavior.