Prisma1: Implicit `prisma generate` via `prisma deploy`

Created on 21 Nov 2018  路  6Comments  路  Source: prisma/prisma1

prisma deploy should always implicitly run prisma generate. You almost always want to have your client updated after you migrated your datamodel - this is the common case and everything else should be treaded as an edge case.

At the same time, it should be possible to opt-out of the client generation, so I suggest introducing a --no-generate flag that indicates that you don't want prisma generate happen after a deploy.

kinfeature arecli rf1-draft

All 6 comments

FWIW having this flag would also help prevent client regeneration when a user only wants to update event subscriptions.

This can be achieved with the following behavior:

  1. with respect to deploy
    It should run after deploy and only run if the deploy was a success

  2. with respect to hooks
    We only have a post-deploy hook right now and it should run after that hook because of point 1 but the behavior needs to specced out for future hooks

  3. with respect to seed
    This should run before the seeding workflow as we might use client for the seeding workflow itself, see https://github.com/prisma/prisma/issues/3596

  4. with respect to dry-run
    This should not be executed when the deploy command is invoked with dry run flag as this command actually mutates the project environment i.e. client code

  5. If the prisma generate command already exists in hooks, then it should emit a warning suggesting that the client is being generated twice and suggest that user should remove the command from hooks.

  6. A new flag --no-generate (wording needs review) should be added to omit implicit client generation

Warning: The `prisma generate` command was executed twice. Since Prisma 1.X, the Prisma client is generated automatically after running `prisma deploy`. It is not necessary to generate it via a `post-deploy` hook any more, you can therefore remove the hook if you do not need it otherwise.

This is implemented the the latest alpha, 1.31.0-alpha.3, please install it via npm install -g prisma@alpha

This is available in the latest stable 1.31.1. Please install this via npm install -g prisma.

I am closing this issue, please open a new issue again if necessary.

I seem to be getting a false positive now with the upgrade to 1.31.1

Warning: The `prisma generate` command was executed twice. Since Prisma 1.31, the Prisma client is generated automatically after running `prisma deploy`. It is not necessary to generate it via a `post-deploy` hook any more, you can therefore remove the hook if you do not need it otherwise.

This is my prisma.yml

endpoint: ${env:PRISMA_ENDPOINT}
secret: ${env:PRISMA_SECRET}

datamodel: datamodel.prisma

generate:
  - generator: typescript-client
    output: ./generated/prisma-client/

hooks:
  post-deploy:
    - npx nexus-prisma-generate --output ./generated/nexus-prisma
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sorenbs picture sorenbs  路  3Comments

marktani picture marktani  路  3Comments

marktani picture marktani  路  3Comments

MitkoTschimev picture MitkoTschimev  路  3Comments

schickling picture schickling  路  3Comments