Open janpio opened 3 years ago
Most of this is observation and guesses for now, so it would be good to reproduce this with a repository that includes 2 functions, one using Prisma and one not using Prisma. The generate
and migrate deploy
commands can in theory be replaced with simple outputs of a string. This should be enough to confirm the behavior on Vercel.
Note: this might be a docs problem.
@janpio The docs page you've linked no longer mentions anything about migrate, I think it should (currently working on that and a bit confused). Things which aren't clear to me, which you might want to make clear:
migrate
or generate
first?vercel-build
, but I think that script is now just build
prisma migrate deploy
in build
or in postinstall
?What's working for me (Nuxt + Prisma + Vercel):
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare && prisma migrate deploy && prisma generate"
},
Relevant:
In our Vercel deployment guide we recommend putting
prisma generate
in apostinstall
script, and any Migrations viaprisma migrate deploy
into thevercel-build
script:https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-vercel#vercel-specific-notes
It seems that when your application is deploying multiple functions, some possibly that do not use Prisma, both these scripts are executed for each function instead of once per deployment.
The theory is that Vercel installs dependencies for each serverless function individually instead of just once (to optimize the deployment size of each serverless function), and also executes these scripts each time.
(Reported via private Slack Direct Message)
On the other hand: Both
prisma migrate
andprisma generate
are idempotent usually, so there is no real negative effect of running these multiple times. We should still understand.