Loading...
Loading...
Edit the Prisma Next data contract — add models, fields, relations, indexes, enums, type aliases, polymorphic types (`@@discriminator` / `@@base`), use extension namespaces (`pgvector.Vector(...)`, `cipherstash.EncryptedString(...)`), wire `prisma-next.config.ts` with `defineConfig` from the `@prisma-next/<target>/config` façade, and run `prisma-next contract emit`. Use for schema, models, fields, attributes, soft delete, paranoid, scopes, validations, callbacks, prisma schema, PSL, contract.prisma, contract.ts, contract.json, contract.d.ts, façade imports, `@prisma-next/postgres/config`, `@prisma-next/postgres/contract-builder`, `@prisma-next/postgres/control`, `@prisma-next/mongo/config`, `@prisma-next/mongo/contract-builder`, `extensions:`, `extensionPacks`, pgvector, cipherstash, postgis, paradedb, PN-CLI-4002, PN-CLI-4003, PN-CLI-4011.
npx skill4agent add prisma/prisma-next prisma-next-contractEdit your data contract. Prisma handles the rest.
contract.prismacontract.tsprisma-next-migrationsmigration.tsprisma-next-migrationsprisma-next contract emitprisma-next-buildcontract:prisma-next.config.tscontract.jsondb verifycontract.d.tsContract.d.tspgvector.Vector(length: 1536)cipherstash.EncryptedString({...})extensions: [...]prisma-next.config.tsPN-CLI-4002PN-CLI-4003PN-CLI-4011contract emit@prisma-next/postgres/config@prisma-next/postgres/contract-builderprisma-next-migrationsprisma-next-queriesdb.tsprisma-next-runtimeprisma-next-buildprisma-next-quickstartprisma-next-debugprisma-next-feedback@prisma-next/<target>@prisma-next/postgres/config@prisma-next/postgres/contract-builder@prisma-next/postgres/control@prisma-next/postgres/runtime@prisma-next/mongo/config@prisma-next/mongo/contract-builder@prisma-next/mongo/runtime@prisma-next/extension-pgvector/control@prisma-next/extension-cipherstash/control@prisma-next/extension-postgis/control@prisma-next/extension-paradedb/control@prisma-next/cli/*@prisma-next/family-*@prisma-next/target-*@prisma-next/adapter-*@prisma-next/driver-*@prisma-next/sql-contract-*contract.prismacontract: './<path>/contract.prisma'defineConfig.prismacontract.tsdefineContract({...}, ({ field, model, rel, type }) => ({...}))@prisma-next/postgres/contract-builder@prisma-next/mongo/contract-buildercontract: './<path>/contract.ts'.tsprisma-next.config.tsdefineConfig({...})@prisma-next/postgres/config@prisma-next/mongo/configcontract.prisma.tsdb{ connection?: string }extensionsmigrations{ dir?: string }contract.jsoncontract./src/prisma/contract.prisma./src/prisma/contract.jsonprisma-next contract emit --config <path>?prisma-next.config.tscontract.jsoncontract.d.tspgvector.Vector(length: 1536)cipherstash.EncryptedString({equality: true})extensions: [pgvector]@prisma-next/extension-<name>/controlextensionPacksextensionsdefineContractcontract.tsextensionPacks: { pgvector }@prisma-next/extension-<name>/packprisma-next.config.tsmigrations/prisma-next.config.tssrc/prisma/contract.{prisma,ts}src/prisma/contract.{json,d.ts}src/prisma/db.tsmigrations/app/<timestamp>_<slug>/app/migrations/<extension-space-id>/examples/prisma-next-demoprisma-next initprisma/...prisma-next.config.tssrc/contract.{prisma,ts}prisma/src/contract.{json,d.ts}migrations/<timestamp>_<slug>/migrations/<space-id>.cursor/rules/contract-space-package-layout.mdcdefineConfigcontract:prisma-next contract emitcode| Code | Meaning | Next move |
|---|---|---|
| | Add |
| Source loaded but the Contract IR failed structural validation. | Read |
| The contract uses a namespaced constructor (e.g. | Install the package, import its control descriptor ( |
prisma-next.config.tscontract:extensions: [...]cat prisma-next.config.tscontract:.prisma.tsprisma-next.config.tsprisma-next-quickstart@relation(...)model User {
id Int @id @default(autoincrement())
email String @unique
}
model Post {
id Int @id @default(autoincrement())
title String
authorId Int
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
@@unique([title, authorId])
@@index([authorId])
}pnpm prisma-next contract emitprisma-next-buildonDeleteonUpdateRestricttypes {}types {
Email = String
}
model User {
id Int @id @default(autoincrement())
email Email @unique
}String[]type Address { ... }address AddressdefineContractfieldmodelrelfamilytarget@prisma-next/postgres/family@prisma-next/postgres/targetdefineContract({...}, ({ field, model, rel, type }) => ({...}))field.text()field.id.uuidv7()field.temporal.createdAt()type.sql.String(35)import sqlFamily from '@prisma-next/postgres/family';
import { defineContract } from '@prisma-next/postgres/contract-builder';
import postgresPack from '@prisma-next/postgres/target';
export const contract = defineContract(
{
family: sqlFamily,
target: postgresPack,
},
({ field, model }) => ({
models: {
User: model('User', {
fields: {
id: field.id.uuidv7(),
email: field.text().unique(),
createdAt: field.temporal.createdAt(),
},
}).sql({ table: 'app_user' }),
},
}),
);pnpm prisma-next contract emitfield.<scalar>()field.column(...)field.generated(...)field.namedType(...)@prisma-next/postgres/*@prisma-next/mongo/*indexvalueObjectpgvector.*defineConfig.extensionsdefineContract.extensionPacksprisma-next.config.tsimport pgvector from '@prisma-next/extension-pgvector/control';
import { defineConfig } from '@prisma-next/postgres/config';
export default defineConfig({
contract: './src/prisma/contract.prisma',
extensions: [pgvector],
});src/prisma/contract.prismamodel Document {
id Int @id @default(autoincrement())
content String
embedding pgvector.Vector(length: 1536)
}vector(1536)contract.d.tspgvector.*PN-CLI-4011meta.missingExtensionPacks: ['pgvector']fixextensionsexamples/multi-extension-monorepo/app/prisma-next.config.tsexamples/cipherstash-integration/prisma-next.config.tsexamples/prisma-next-postgis-demo/prisma-next.config.ts@@discriminator@@base@@map(...)@@map@@map("variant_table")model Task {
id Int @id @default(autoincrement())
title String
type String
@@discriminator(type)
@@map("tasks")
}
// STI variant — shares the `tasks` table.
model Bug {
severity String
@@base(Task, "bug")
}
// MTI variant — joins to `tasks` via PK; carries its own `features` table.
model Feature {
priority Int
@@base(Task, "feature")
@@map("features")
}packages/2-sql/2-authoring/contract-psl/test/interpreter.polymorphism.test.tsdiscriminator@prisma-next/mongo/contract-builder@@base@@discriminatorprisma-next-queriesprisma-next contract infer --db <url>contract.prismacontract emitdb signpnpm prisma-next contract infer --db $DATABASE_URL --output ./src/prisma/contract.prisma
pnpm prisma-next contract emitcontract.jsoncontract.d.tsmigration planprisma-next-buildcontract.jsoncontract.d.tsdefineContractfieldmodelrel@prisma-next/postgres/contract-builder@prisma-next/mongo/contract-builderfield.column(...)field.generated(...)field.namedType(...)prisma-next.config.tscontract.tsdb.ts@prisma-next/<target>/<subpath>@prisma-next/extension-<name>/<subpath>@prisma-next/cli/*@prisma-next/family-*@prisma-next/target-*@prisma-next/adapter-*@prisma-next/driver-*@prisma-next/sql-contract-*prisma-next-feedbackexamples/multi-extension-monorepo/app/prisma-next.config.tsexamples/cipherstash-integration/prisma-next.config.tsexamples/prisma-next-postgis-demo/prisma-next.config.tsextensionsextensionPacksdefineConfig({ extensions: [pgvector] })@prisma-next/extension-<name>/controldefineContract({ extensionPacks: { pgvector } })@prisma-next/extension-<name>/packPN-CLI-4011extensionsmigration.tsmigration planprisma-next-migrations@prisma-next/mongo/configdefineConfigcontractdbextensionsmigrations.dirprisma-next-feedback/config/contract-builder@prisma-next/sqlite/runtimeprisma-next-feedback@@rename(old: ..., new: ...)prisma-next-feedback@validates(...)prisma-next-feedbackbeforeSaveafterCreateprisma-next-runtimeprisma-next-feedbackparanoid: truedeletedAt DateTime?prisma-next-feedbackprisma-next-feedbacktype Foo { ... }Jsonprisma-next-feedbackprisma-next-feedbackpnpm prisma-next contract --helppackages/2-sql/2-authoring/contract-psl/README.mdpackages/2-sql/2-authoring/contract-ts/README.mdcontract.prismacontract.jsoncontract.d.tsmigrations/src/prisma/...migrations/app/...examples/prisma-next-demosrc/contract.{prisma,ts}migrations/<timestamp>_<slug>/.cursor/rules/contract-space-package-layout.mdcprisma-next.config.ts.prisma.tsextensions: [...]@prisma-next/<target>/<subpath>@prisma-next/postgres/config@prisma-next/extension-<name>/<subpath>@prisma-next/cli/*@prisma-next/family-*@prisma-next/target-*@prisma-next/adapter-*@prisma-next/driver-*@prisma-next/sql-contract-*contract.prismacontract.ts@prisma-next/extension-<name>/controlextensions: [...]defineConfig({...})defineContract({extensionPacks: {...}})migration.tsmigration planpnpm prisma-next contract emitcontract.jsoncontract.d.tscontract.jsoncontract.d.tsprisma-next-feedback