-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SWEP-51] Session 테이블 수정 및 마이그레이션 추가 #57
Conversation
fix: Session 테이블 수정 및 마이그레이션 파일 추가
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했습니다
[P1] 어떤 문제가 발생했는지, 원인이 뭐였는지도 PR 내용에 있으면 좋겠습니다. |
핵심 사항에 추가로 원인과 해결예시를 좀더 자세하게 설명해두었습니다 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
완벽합니다! 이해가 잘되네요~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋아요 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
새롭게 알게 된 내용이 많네요 타입 에러 해결하시느라 수고하셨습니다!!
마이그레이션 적용 시켰습니다 |
[SWEP-51] Session 테이블 수정 및 마이그레이션 추가
Sweepic Server PR List
close #55
⚒️develop의 최신 커밋을 pull 받았나요?
🔍️ 이 PR을 통해 해결하려는 문제가 무엇인가요?
로그인 기능 추가시 Session에서 타입이 맞지않아 발생 하는 오류 해결
schema.prisma에서 정의한 Session 모델과 @quixo/prisma-session-store 모듈의 PrismaSessionStore() 생성자에서 요구하는 Session에 대한 모델이 달라서 타입오류가 발생
✨ 이 PR에서 핵심적으로 변경된 사항은 무엇일까요? (핵심 작업 내용)
schema.prisma에서 Session 모델 수정

schema.prisma에서 User 모델 수정

위와 같이 바꾼 이유는 @quixo3/prisma-session-store를 이용하려면 아래와 같이 Session 테이블의 형태를 유지해줘야 타입에러가 발생하지 않음

아래는 공식문서에서의 내용입니다.
https://www.npmjs.com/package/@quixo3/prisma-session-store
예를 들어

공식문서상에는 sid에 @unique 어노테이션 들어가있지만 안들어간 상태로 만들경우
yarn prisma generate를 통해 prisma client를 만들때
여기서 만들어진 Session의 타입으로 prisma client의 타입을 정의 하게되고
이러한 타입의 정의는 node_modules/.prisma/client/index.d.ts 에 생성된다.
위의 사진처럼 node_modules/.prisma/client/index.d.ts 파일 안에
Prisma에 의해 자동 생성된 타입인 SessionWhereUniqueInput 이라는 타입이 정의 되어있는데
prisma-session-store에서 요구하는 건 sid?: string 인데 자동생성된 prisma client는 sid?: StringFilter<"Session"> | string 이렇게 정의가 되어있다.
그러나 @unique 어노테이션을 넣으면

다음과 같이 sid?: string으로 타입이 되어있기 때문에 이는 prisma-sesssion-store가 요구하는 타입과 맞아
yarn compile을 통과하게 된다.
이처럼 공식문서가 요구하는 Session 모델과 다를 경우 타입에러가 발생하며
이를 막기위해 schema.prisma의 session 모델을 수정했다.
🤚 동작 확인
🔖 핵심 변경 사항 외에 추가적으로 변경된 부분이 있나요?
🙏 Reviewer 분들이 이런 부분을 신경써서 봐 주시면 좋겠어요
🩺 이 PR에서 테스트 혹은 검증이 필요한 부분이 있을까요?
📌 PR 진행 시 이러한 점들을 참고해 주세요
📝 Assignee를 위한 CheckList