Skip to content

Commit

Permalink
Merge pull request #12 from aiji42/braking-change-update-prisma-client
Browse files Browse the repository at this point in the history
Braking change update prisma client
  • Loading branch information
aiji42 authored Jul 5, 2022
2 parents e7ce5ef + 8b2ab48 commit b9d7fae
Show file tree
Hide file tree
Showing 15 changed files with 3,661 additions and 253 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ See [here](./docs/BENCHMARK.md) for details.

## Setup

If you are using `@prsima/client` v3, install `prisma-data-proxy-alt@^1`.
The latest library (v2) suports only `@prima/client` v4.

```bash
yarn add prisma-data-proxy-alt
```
Expand All @@ -46,6 +49,7 @@ yarn add @prisma/client

Give environment variables by creating `.env`, etc.
```
PRISMA_SCHEMA_PATH=/absolute/path/for/your/schema.prisma
DATABASE_URL={database URL scheme e.g. postgresql://postgres:pass@db:5432/postgres?schema=public}
DATA_PROXY_API_KEY={random string for authentication}
PORT={server port e.g. 3000}
Expand Down Expand Up @@ -79,6 +83,7 @@ services:
entrypoint: /app/entrypoint.sh
command: yarn pdp
environment:
PRISMA_SCHEMA_PATH: /app/for/your/schema.prisma
DATABASE_URL: your DATABASE_URL
DATA_PROXY_API_KEY: your DATA_PROXY_API_KEY
PORT: "3000"
Expand Down Expand Up @@ -135,6 +140,8 @@ FROM base
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

ENV PRISMA_SCHEMA_PATH=/app/node_modules/.prisma/client/schema.prisma

USER node

ENTRYPOINT ["/usr/bin/tini", "--"]
Expand Down Expand Up @@ -182,6 +189,8 @@ Set `_REGION`, `_DATABASE_URL`, and `_DATA_PROXY_API_KEY` in the substitution va
- `_DATA_PROXY_API_KEY`: Arbitrary string to be used when connecting data proxy. e.g. `prisma://your.deployed.domain?api_key={DATA_PROXY_API_KEY}`
(do not divulge it to outside parties)

<!--

### Vercel

Create `api/index.js`
Expand Down Expand Up @@ -217,10 +226,12 @@ Then set the `DATABASE_URL` and `DATA_PROXY_API_KEY` as environment variables an

![](./images/vercel.png)

- `_DATABASE_URL`: Connection URL to your data source (mysql, postgres, etc...)
- `_DATA_PROXY_API_KEY`: Arbitrary string to be used when connecting data proxy. e.g. `prisma://your.deployed.domain?api_key={DATA_PROXY_API_KEY}`
- `DATABASE_URL`: Connection URL to your data source (mysql, postgres, etc...)
- `DATA_PROXY_API_KEY`: Arbitrary string to be used when connecting data proxy. e.g. `prisma://your.deployed.domain?api_key={DATA_PROXY_API_KEY}`
(do not divulge it to outside parties)

-->

## For Client (on your application)

On the client side, generate the Prisma client in data proxy mode `--data-proxy`. [official document](https://www.prisma.io/docs/concepts/data-platform/data-proxy#step-4-generate-the-client)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
entrypoint: /app/entrypoint.sh
command: ./wait-for-it.sh https-portal3000:443 --timeout=120 --strict -- yarn dev:server
environment:
PRISMA_SCHEMA_PATH: /app/node_modules/.prisma/client/schema.prisma
DATABASE_URL: postgresql://postgres:pass@db:5432/postgres?schema=public
DATA_PROXY_API_KEY: custometoken
MIGRATE: "true"
Expand Down
2 changes: 2 additions & 0 deletions example/gcp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ FROM base
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

ENV PRISMA_SCHEMA_PATH=/app/node_modules/.prisma/client/schema.prisma

USER node

ENTRYPOINT ["/usr/bin/tini", "--"]
Expand Down
6 changes: 3 additions & 3 deletions example/gcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"license": "MIT",
"private": true,
"dependencies": {
"@prisma/client": "^3.15.1",
"prisma-data-proxy-alt": "v1.2.0"
"@prisma/client": "^4.0.0",
"prisma-data-proxy-alt": "2.0.0-beta.4"
},
"devDependencies": {
"prisma": "^3.15.1"
"prisma": "^4.0.0"
}
}
Loading

1 comment on commit b9d7fae

@vercel
Copy link

@vercel vercel bot commented on b9d7fae Jul 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.