chen-rn / CUA

(no longer maintained) create-universal-app(CUA) is an opinionated template for creating fullstack universal apps (Expo, Next, tRPC, Prisma, Clerk, Solito, Tamagui)

Home Page:https://cua-demo.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Prisma cannot read env var when using `directUrl` with postgresql

alexandruchircu opened this issue · comments

Describe the bug
When using directUrl in prisma datasource, prisma complains that the connection url is empty.

To Reproduce
Steps to reproduce the behavior:

  1. Use a pooling URL for DATABASE_URL (postgresql://user:pass@url.supabase.co:6543/postgres?pgbouncer=true)
  2. Create a DIRECT_URL in .env (postgresql://user:pass@url.supabase.co:5432/postgres)
  3. Add DIRECT_URL to turbo.json
  4. Setup schema.prisma as below:
datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
  shadowDatabaseUrl = env("DIRECT_URL")
}
  1. Run yarn db-push

Log:

root@proj-794877866d-d8trj:/src# yarn db-push
• Packages in scope: @my/api, @my/db, @my/ui, app, expo-app, nextjs
• Running db-push in 6 packages
• Remote caching disabled
@my/db:db-push: cache bypass, force executing 52d000672fac80cc
@my/db:db-push: Prisma schema loaded from prisma/schema.prisma
@my/db:db-push: Datasource "db": PostgreSQL database
@my/db:db-push: 
@my/db:db-push: Error: Connection url is empty. See https://www.prisma.io/docs/reference/database-reference/connection-urls
@my/db:db-push: ERROR: command finished with error: command (/src/packages/db) yarn run db-push exited (1)
command (/src/packages/db) yarn run db-push exited (1)

Expected behavior
Database is populated