How to Build a Fullstack App with Next.js, Prisma, and PostgreSQL[And deploy successfully!]

Table of contents

First things first, a very special appreciation to nikolasburk(no link, sad) for this article How to Build a Fullstack App with Next.js, Prisma, and PostgreSQL!(Which is the STEP ONE in this very brief guide) However I didn't manage to run database queries successfully after deploying.

Prisma is a Node.js and TypeScript ORM (jargon for database)

My problem was the commands prisma db push and prisma generate not getting called on Vercel.

STEP TWO

Another very appreciation for this article Deploying to vercel It highlighted what I didn't know; how to fix the database issue: by adding the commands necessary in the file package.json, the scripts section like this:

{
...,
"scripts": {
    ...,
    "vercel-build": "npx prisma db push && next build",
    "prisma:generate": "npx prisma generate",
    "postinstall": "npx prisma generate"
  }
}

Yeah that's literally it, now every time I push to git, deployment and database changes take effect alongside it, that's crazy cool!

I have become curator, modifier of articles ;)