Netlify deployment prisma error

Hello,

I’m trying to upgrade my app from v0.8.2 to v0.16. It’s working locally. I’m trying to deploy it to a Netlify test environment. I got the below error. I notice that my schema.prisma still says sqlite. Do I need to upgrade this to postgresql for production?

Thanks,

2:09:55 PM: $ /opt/build/repo/node_modules/.bin/rw db up --no-db-client
2:09:57 PM: Migrate database up... [started]
2:09:57 PM: $ /opt/build/repo/node_modules/.bin/prisma migrate up --experimental --create-db
2:09:58 PM: Error: Get config {"is_panic":false,"message":"error: Error validating datasource `DS`: The URL for datasource `DS` must start with the protocol `file:`.\n  -->  schema.prisma:3\n   | \n 2 |   provider = \"sqlite\"\n 3 |   url      = env(\"DATABASE_URL\")\n   | \n\nValidation Error Count: 1","meta":{"full_error":"error: Error validating datasource `DS`: The URL for datasource `DS` must start with the protocol `file:`.\n  -->  schema.prisma:3\n   | \n 2 |   provider = \"sqlite\"\n 3 |   url      = env(\"DATABASE_URL\")\n   | \n\nValidation Error Count: 1"},"error_code":"P1012"}
2:09:58 PM: error Command failed with exit code 1.
2:09:58 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2:09:58 PM: Migrate database up... [failed]
2:09:58 PM: → Command failed with exit code 1: yarn prisma migrate up --experimental --create-db
2:09:58 PM: Command failed with exit code 1: yarn prisma migrate up --experimental --create-db

Correct.

We’ll need a database somewhere on the internet to store our data. We’ve been using SQLite locally, but that’s a file-based store meant for single-user. SQLite isn’t really suited for the kind of connection and concurrency requirements a production website will require. For this part of this tutorial, we will use Postgres. (Prisma currently supports SQLite, Postgres and MySQL.) Don’t worry if you aren’t familiar with Postgres, Prisma will do all the heavy lifting. We just need to get a database available to the outside world so it can be accessed by our app.

Please see:

@dthyresson thanks. How do I handle the switch between sqlite (local) and postgresql (production)? I do have a postgresql db and a DATABASE_URL environment variable in my Netlify deployment. Netlify seems to switch that automatically in v0.8.2.

I believe you tell Prisma to consider both:

provider = ["sqlite", "postgresql"]

And then the DATABASE_URL in your Netlify env will inform what to provider to use.

@dthyresson thanks very much! It fixes the error. I suggest to add postgresql to the default new project template.

https://github.com/redwoodjs/redwood/blob/04d16482442a1223fe5be14bee438d45787bc9ae/__fixtures__/new-project/api/prisma/schema.prisma#L2

It may be best to leave that implementation choice to the developer (since they can pick from a number of supported databases) and even now deployment platforms (Netlify, Vercel).

For example:

  • SQLite
  • Postgres
  • MySQL
  • MariaDB
  • AWS Aurora / Serverless

are also supported – and Prisma will likely support other databases in the future – see Prisma’s Public Roadmap giving developers lots of options.

On their roadmap is potential support for MSSQL and MongoDB.

Therefore probably would not want to include all those in the default – it’s sometimes nice to have a little control. :wink:

1 Like