文档
入门
CLI

Prisma CLI

Prisma CLI 与 Go

Go 客户端的工作方式与正常的 Prisma 工具略有不同。当您使用 Go 客户端时,无论何时看到 Prisma CLI 命令,例如 prisma ...,您应该始终编写 go run github.com/steebchen/prisma-client-go ... 代替。

例如

# just re-generate the Go client
go run github.com/steebchen/prisma-client-go generate
 
# sync the database with your schema for development
go run github.com/steebchen/prisma-client-go db push
 
# create a prisma schema from your existing database
go run github.com/steebchen/prisma-client-go db pull
 
# for production use, create a migration locally
go run github.com/steebchen/prisma-client-go migrate dev
 
# sync your production database with your migrations
go run github.com/steebchen/prisma-client-go migrate deploy

快捷方式

如果您只使用 Go 客户端,并且没有(或不想)安装 NodeJS Prisma CLI,您可以设置一个别名,以便您可以像往常一样编写 prisma 命令,但它将调用实际的本地捆绑的 Prisma CLI。为此,请编辑您的 ~/.bashrc~/.zshrc 并添加

alias prisma="go run github.com/steebchen/prisma-client-go"

现在 prisma generate 和任何其他命令都将起作用,它将在后台运行 1go run github.com/steebchen/prisma-client-go generate