Deploy Serverless to Vercel

You first need to change the defined datasource in

db/schema.prisma from SQLite to Postgres

-datasource sqlite {
- provider = "sqlite"
- url = "file:./db.sqlite"
-
+datasource postgresql {
+ provider = "postgresql"
+ url = env("DATABASE_URL")
+}

Assuming you already have a

Vercel account:

  1. You need a production Postgres database. It's straightforward to set this up on Digital Ocean.
  2. You also need a connection pool. This is also relatively straightforward to set up on Digital Ocean.
    1. Read the Digital Ocean docs on setting up your connection pool
    2. Ensure you set your "Pool Mode" to be "Session" instead of "Transaction" (because of a bug in Prisma)
  3. You need your entire database connection string. If you need, read the Prisma docs on this.
    1. Make sure you get the connection string to your connection pool, not directly to the DB.
    2. If using pgBouncer (default connection pool on Digital Ocean), you must add ?pgbouncer=true to the end of your connection string for Prisma to work correctly.
  4. Change your build script in package.json to be blitz db migrate && blitz build so that the production DB will be migrated on each deploy
  5. Add your DB url as a secret environment variable using the UI or by running vercel env add DATABASE_URL
  6. Run git push if using the Git Integration or vercel if using Vercel CLI
Idea for improving this page?Edit it on Github