a year ago
Hello, I am using 2 postgres dbs and have followed -https://www.prisma.io/docs/guides/multiple-databases guide to set them up.
On running yarn dev I am getting the following error - Error validating datasource db: the URL must start with the protocol prisma:// or prisma+postgres://
Not sure what is wrong, please help.
22 Replies
a year ago
That guide is specifically for Vercel. Mind explaining what your goal is here?
My goal is to use one database for app related user info, another for custom content
a year ago
All the resources I can find online seem very hands on with editing the filesystem, not ideal for Railway. Is there a reason why you don’t want to just run two database clients? Or store all your tables in one database under different datasets?
a year ago
If you’re willing to run just one database, or two separate database services, setup will be much much easier
I am building a word-learning app, so I have separated the lesson content (words, quiz questions) from the user content (progress, personal info). I thought this would be a more decoupled architecture.
I have two postgres dbs (prisma-app-db, prisma-modules-db) and have created two db clients
`import { PrismaClient } from "../../../prisma-app-database/app-database-client-types"
const getPrisma = () => new PrismaClient()
const globalForAppDBPrismaClient = global as unknown as {
appDBPrismaClient: ReturnType
}
export const appDBPrismaClient =
globalForAppDBPrismaClient.appDBPrismaClient || getPrisma()
if (process.env.NODE_ENV !== "production")
globalForAppDBPrismaClient.appDBPrismaClient = appDBPrismaClient
`
a year ago
Running two databases is unnecessary, those two topics could easily be different datasets. That’s how I recommend you should proceed here
a year ago
there’s no point in doubling your database spend for very little benefit
Noob question - please can you tell me in what scenario would it be necessary to have multiple databases vs multiple tables in the same database?
a year ago
Security reasons, mostly. If you absolutely have to have sensitive data stored in a secure place, it could make sense to have two databases
a year ago
but realistically, in most cases you can just apply security changes to the less sensitive data too and you’ll be fine
a year ago
usually there are dataset/table/column level security options. all the more reason to keep all your data in one place
a year ago
Ah scaling is also a reason. If you’re hitting your database very hard with a ton of queries, it could make sense to have replicas to ease the load
a year ago
No problem!
a year ago
!s
Status changed to Solved adam • 11 months ago

