contract print
contract print loads the contract that contract names in prisma.config.ts and writes it as a Prisma ORM 8 PSL contract. The source can be a Prisma ORM 7 schema, a TypeScript contract, or a PSL contract.
Use it to move from a Prisma ORM 7 schema.prisma, read through prisma7Schema, to a contract file written for Prisma ORM 8.
The command is offline. It does not need a database connection.
bunx prisma contract print [--output <path>]pnpm prisma contract print [--output <path>]yarn prisma contract print [--output <path>]npx prisma contract print [--output <path>]| Option | What it does |
|---|---|
--output <path> |
Writes the PSL to this file. Without it, the command prints the PSL and writes no file. |
--format human |
Prints the PSL to standard output, so you can redirect it to a file. |
--config <path> |
Read this config file instead of ./prisma.config.ts. |
--json |
Prints a machine-readable result, with the PSL in psl.text. |
bunx prisma contract print
bunx prisma contract print --output ./src/prisma/contract.prisma
bunx prisma contract print --jsonpnpm prisma contract print
pnpm prisma contract print --output ./src/prisma/contract.prisma
pnpm prisma contract print --jsonyarn prisma contract print
yarn prisma contract print --output ./src/prisma/contract.prisma
yarn prisma contract print --jsonnpx prisma contract print
npx prisma contract print --output ./src/prisma/contract.prisma
npx prisma contract print --jsonThe file starts with // use prisma-8. When you point contract at the file and run contract emit, you get the same contract as before, with the same hashes, so the database needs no migration and no new db sign.
When a part of the contract has no PSL form, the command names that part, fails, and writes nothing. It also refuses an --output path that is one of the files it reads, prisma.config.ts, or a file contract emit writes.
- Set
contractinprisma.config.tsto the file you wrote, as Configuration shows. - Run
contract emitto writecontract.jsonandcontract.d.tsfrom it.