티스토리 뷰

반응형

[prisma+PlanetScale]database connect 데이터베이스 구성 및 접속하기

 

primsa 셋팅 - https://gofogo.tistory.com/133

 

[prisma/orm] prisma 설치 및 테스트

[prisma/orm] prisma 설치 및 테스트 기존에 typeORM을 쓰다가 좀 더 효율적인 ORM으로 교체를 위해 시도해보았다. #설치 및 초기화 npm install prisma -D npx prisma init #db를 선택하여 넣는다. generator..

gofogo.tistory.com

 

PlanetScale(cli) 셋팅 - https://gofogo.tistory.com/135

 

[PlanetScale/scoop/windows]윈도우에서 PlanetScale cli 설치(scoop)

[PlanetScale/scoop/windows]윈도우에서 PlanetScale cli 설치(scoop) #1.power shell ISE 실행 #2.권한 얻기 $ Set-ExecutionPolicy RemoteSigned -scope CurrentUser #3.Scoop 설치(https://scoop.sh/) $ Inv..

gofogo.tistory.com

pscale은 참 재밌는 개념이다,

기존에 .env에 환경 설정 파일을 설정 해둔 후 github에서 제외하여 각각 환경에 맞는 config를 사용했는데,

pscale를 사용하여 한번 더 캡슐화(security tunnel)가 되어, 로컬로 서버를 돌려 pscale 서버를 인증하는 방식이라

.env에는 그저 localhost:3306으로 저장되어 보안적으로 아주 유용하다, dev랑 prod가 나눠져야한다면 각각 정보에 맞는 정보로 connect하면된다.

 

#pscale 접속

$ pscale auth login

 

#DB 생성 (도쿄서버에 admin-cms DB 생성)

$ pscale database create admin-cms --region ap-northeast

 

#서버 접속

$ pscale connect admin-cms

 

#.env 설정

DATABASE_URL="mysql://127.0.0.1:3306/admin-cms"

 

#scheme.prisma

generator client {
  provider = "prisma-client-js"
  //forign key 구현
  previewFeatures = ["referentialIntegrity"]
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
  //forign key 구현
  referentialIntegrity = "prisma"
}

 

 

#prisma #PlanetScale #scheme.prisma #referentialIntegrity #db #pscale

반응형
댓글
반응형