Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts/prisma: additional instructions for deploying #1563

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions docs/ts/develop/orms/prisma.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,21 @@ const prisma = new PrismaClient({
const allUsers = prisma.user.findMany();

-- prisma/schema.prisma --
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x"]
}

datasource db {
provider = "postgresql"
url = "<paste connection uri to encore shadow db here>"
}

model User {
id Int @id @default(autoincrement())
name String?
surname String?
name String
surname String
}

```

## Configure Prisma
Expand All @@ -69,6 +78,26 @@ To initialize Prisma, run the following command from within your service folder:
npx prisma init --url <shadow db connection url>
```

To be able to deploy your app via the Encore platform, you also need to configure a postinstall hook in your `package.json` that runs `npx prisma generate`, e.g:

```
{
"scripts": {
"postinstall": "npx prisma generate --schema=users/prisma/schema.prisma"
}
}
```

You also need to configure `binaryTargets` in `schema.prisma` like this:

```
generator client {
fredr marked this conversation as resolved.
Show resolved Hide resolved
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x"]
}

```

## Generate migrations

Run `npx prisma migrate dev` in the same directory as you ran the init (where the prisma folder exist).
Expand Down
Loading