Skip to main content

Codemods

The @prisma/codemods package helps you to upgrade your codebase as Prisma ORM evolves.

info

You can checkout the repository, here: https://github.com/prisma/codemods

Usage

  $ npx @prisma/codemods <transform> <path> <...options>
  • <transform> - See Transforms for available choices
  • <path> - The directory of your app. i.e ./my-awesome-project

Options

  • (-f)orce - Bypass Git safety checks and forcibly run codemods
  • (-s)chemaPath - Specify a path to your ./prisma/schema.prisma
  • (-d)ry - Dry run (no changes are made to files)
  • (-p)rint - Print transformed files to your terminal
  • --instanceNames=myClient - Useful when importing an already instantiated client (i.e import myClient from './myClient')

Transforms

<transform>DescriptionExample
namespaceCodemod for @prisma/client namespace changenpx @prisma/codemods namespace ./my-project
findUniqueConverts prisma.x.findOne to prisma.x.findUniquenpx @prisma/codemods findUnique ./my-project
to$to$: Converts deprecated prisma.x methods to prisma.$xnpx @prisma/codemods to$ ./my-project
update-2.12Includes namespace/findUnique/to$npx @prisma/codemods update-2.12 ./my-project