Cloudflare Workers with PlanetScale db
See original GitHub issueI want to use prisma with Cloudflare workers and PlanetScale db using JS and not TS.
I have created the webpack config
module.exports = {
entry: './src/index.js',
target: 'webworker',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
// Alias for resolving the Prisma Client properly
alias: {
'@prisma/client$': require.resolve('@prisma/client'),
},
},
devtool: 'none',
}
and schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity", "dataProxy"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model Test {
id Int @id @default(autoincrement())
name String
city String
www String
Now it all trows pleny of errors. When I try to use db push
I get:
% npx prisma db push
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Get config: Schema Parsing P1012
error: Error validating datasource `db`: the URL must start with the protocol `mysql://`.
--> schema.prisma:11
|
10 | provider = "mysql"
11 | url = env("DATABASE_URL")
|
Validation Error Count: 1
Next while using wrangler dev I have a ton of lines mostly around missing modules.
What is more there is a missing step of using npx prisma db push.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Introducing the PlanetScale serverless driver for JavaScript
The ability to store and query data in PlanetScale from environments such as Cloudflare Workers, Vercel Edge Functions, and Netlify Edge ...
Read more >Databases · Cloudflare Workers docs
Use Cloudflare Workers to connect your application to external databases, such as Postgres, MySQL, FaunaDB, Supabase, MongoDB Atlas, ...
Read more >PlanetScale reaches to the edge with serverless driver
The driver creates a new layer to the PlanetScale database that enables ... Edge services, including Cloudflare Workers, have provided users ...
Read more >The PlanetScale serverless driver for JavaScript | Hacker News
Think Cloudflare Workers, Vercel Edge Functions, AWS Lambda, etc. ... Unlike many DB providers, PlanetScale supports nearly unlimited connections.
Read more >PlanetScale on Twitter: "Where do you deploy your serverless ...
If I am not using Vercel (so it isn't NextJS) it is likely a Cloudflare Worker. If for whatever reason I need to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @konradbjk, hey everyone. We have released some changes a few minutes ago in prisma@3.15.0. tl;dr;
PRISMA_CLIENT_ENGINE_TYPE
, useprisma generate --data-proxy
to enable the Data Proxyimport { PrismaClient } from '@prisma/client/edge'
for a Workers-compatible Prisma Client.env
aren’t bundled into the generated Prisma Client any longer (see docs)eval
are now also fixedThanks everyone, and your feedback is welcome.
the URL must start with the protocol mysql://
, I think it could be due to either of two reasons:PRISMA_CLIENT_ENGINE_TYPE=dataproxy npx prisma generate
. Amysql://...
connection string only works for non-dataproxy projects, and Cloudflare Workers needs the dataproxy because Workers can only connect through HTTP which requires a connection string resemblingprisma://...
.DATABASE_URL
env var, it has happened often to me.