@prisma/adapter-pg driver adapter.
Before you start, you need:
- A Neki database with a ready branch.
- An application role for that branch. Use
pg_read_all_datafor read traffic and addpg_write_all_datawhen the application writes rows. These inherited data roles do not grantCREATEorALTER, so application credentials cannot change the schema. - A separate migration role, if you run schema changes against the branch. DDL
requires the
postgresinherited role. Neki restricts execution of the cross-router DDL barrier function__neki.wait_for_ddlto itsneki_viewerrole, so addneki_viewer, which requirespg_read_all_data, to the same role. Keep the migration credentials out of the application’s runtime configuration. - The Primary connection details from the database’s Connect page.
Install and initialize Prisma
Install Prisma, the Postgres adapter, andpg, then initialize Prisma:
Add the connection strings
SetDATABASE_URL to the application role and MIGRATION_DATABASE_URL to the
migration role. Copy both URIs from the Connect page:
.env
Configure Prisma
Use the Postgres provider inprisma/schema.prisma:
prisma/schema.prisma
prisma.config.ts
Create the client
Prisma ORM 7 requires a driver adapter at runtime:src/db.ts
Apply schema changes
Framework migration commands send DDL through a normal Neki connection. The
router fans that DDL out to the managed shards, but it does not create a
managed schema-change workflow. Use a schema-change
workflow when you want Neki to prepare and coordinate
an Online DDL change.
pg_read_all_data and pg_write_all_data
cannot run CREATE or ALTER, so a migration that uses application
credentials fails on its first DDL statement.
Apply migration DDL with psql and the migration role so the client prints
PostgreSQL notices:
NOTICE containing the barrier call
for that transaction:
psql when the framework cannot preserve
the notice. If the notice is lost, its version pair cannot be reconstructed.
Prisma Migrate does not expose the PostgreSQL notice that contains Neki’s DDL
barrier. Create migration files against a local Postgres database, not against
the Neki branch:
psql, run the barrier call printed in the
notice, then record the migration in Prisma’s history:
prisma migrate dev or prisma migrate deploy against Neki because
those commands do not preserve the DDL barrier notice.

