Prisma schema - Data source

hwisaac·2023년 2월 16일
0

Prisma

목록 보기
2/2

https://www.prisma.io/docs/concepts/components/prisma-schema/data-sources

Data sources

데이터 소스는 Prisma가 데이터베이스를 연결하는 방법을 결정하며, Prisma schema에서 데이터 소스 블록으로 표시됩니다.

아래 데이터 소스는 postgresql 공급자를 사용하며 connection URL을 포함합니다:

datasource db {
  provider = "postgresql"
  url      = "postgresql://johndoe:mypassword@localhost:5432/mydb?schema=public"
}
  • 프리즈마 스키마는 데이터 소스를 하나만 가질 수 있습니다.
  • 그러나 당신은 다음을 수행할 수 있습니다:
    1. PrismaClient를 생성할 때 프로그램적으로 데이터 소스 URL을 덮어쓰기.
    2. cloud-hosted development DB로 작업하는 경우, Prisma Migrate의 shadow db에 대한 다른 URL 지정하기 참고

참고: 2.22.0 버전부터 multiple provider 지원이 제거되었습니다. 참고: Deprecation of provider array notation

Securing databse connection

일부 데이터 소스 공급자에서는 SSL/TLS와의 연결을 구성하고 URL에 대한 매개 변수를 제공하여 인증서 위치를 지정할 수 있습니다.

  1. Configuring an SSL connection with PostgreSQL
  2. Configuring an SSL connection with MySQL
  3. Configure a TLS connection with Microsoft SQL Server
  • Prisma./prisma 디렉토리와 관련된 SSL 인증서를 확인합니다.
  • 인증서 파일이 해당 디렉토리 외부에 있는 경우(e.g. 프로젝트 루트 디렉터리) 인증서에 상대 경로 사용합니다.
datasource db {
  provider = "postgresql"
  url      = "postgresql://johndoe:mypassword@localhost:5432/mydb?schema=public&sslmode=require&sslcert=../server-ca.pem&sslidentity=../client-identity.p12&sslpassword=<REDACTED>"
}

0개의 댓글