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

Netlify deploy does not pick up changes to schema file #6634

Closed
janpio opened this issue Apr 18, 2021 · 4 comments · Fixed by #18437
Closed

Netlify deploy does not pick up changes to schema file #6634

janpio opened this issue Apr 18, 2021 · 4 comments · Fixed by #18437
Labels
Milestone

Comments

@janpio
Copy link
Member

janpio commented Apr 18, 2021

  1. Create a repository with a minimal, mysql Prisma project
  2. Create a model in the schema and migrate the DB to contain the schema (via db push for example)
  3. Create a minimal serverless function netlify/functions/invocation-count.js that reads the empty table for example
  4. Test everything locally via netlify dev
  5. Create a new site in Netlify that connects to this repo
  6. Set a MySQL DATABASE_URL env var and deploy
  7. Test that the deployed function works as expected
  8. Update the Netlify env var to be a PostgreSQL database (that also has the table via db push)
  9. Update the schema.prisma file to use a postgresql provider
  10. Watch Netlify deploy the updated project
  11. Try the function again

I got an error telling me that the env var should have a different protocol, still mysql://.

Somehow it seems that the Client did not generated again when I only changed the schema file in the repository. Deplying again to Netlify with clearing the cache avoided the problem.

Reason probably is that prisma generate by default is only run via npm install, and as cache is used on a normal deploy that is not necessary. But for Prisma it kinda is, for the schema changes to becomes active in a new generated Client.

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: deployment-platform labels Apr 18, 2021
@pantharshit00
Copy link
Contributor

I can reproduce this. I need to Clear cache and redeploy after making a change like this or add prisma generate to postinstall

@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels May 28, 2021
@pantharshit00
Copy link
Contributor

Here is the reproduction: https://serene-shannon-d8288d.netlify.app/.netlify/functions/invocation-count

@Jolg42
Copy link
Member

Jolg42 commented Dec 9, 2022

I think I found why this happens:
It's mentioned in https://answers.netlify.com/t/busting-the-node-modules-cache-when-certain-files-change/45492/2

The code is here
When a project has a package.json, Netlify will create a shasum of it.
https://github.com/netlify/build-image/blob/524714d1a66d1a967316f5c39465e22c77fdd56c/run-build-functions.sh#L287
On the next build the following function will find out that the current hash of the package.json and the previous hash are the same,
https://github.com/netlify/build-image/blob/524714d1a66d1a967316f5c39465e22c77fdd56c/run-build-functions.sh#LL93C9-L93C9
which will skip the npm install
https://github.com/netlify/build-image/blob/524714d1a66d1a967316f5c39465e22c77fdd56c/run-build-functions.sh#L274

This looks specific to npm, yarn and pnpm do not use that install_deps function.

@millsp
Copy link
Member

millsp commented Feb 23, 2023

Related prisma/docs#3590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants