https://www.erdcloud.com/d/tSXQkMbPGrZthuhzi
enum userType {
customer
mover
}
enum serviceType {
small
home
office
}
// USER
model user {
id String @id @default(uuid())
userType uesrType @default(customer)
email String @unique
name String
phoneNumber String ('010-1111-1234') @unique
created_at Date
updated_at Date
notification notification[]
social_login social_login?
customerRequest customer? @relation("Customer")
moverRequest mover? @relation("Mover")
}
유저-소셜로그인 관계 (1:1) / 전화번호 기준으로 다른 소셜 로그인 방지
// USER - 고객 프로필 정보
model customer {
id Int @id @default(autoincrement())
serviceType serviceType[]
liveArea String
profileImage String?
user user @relation("Customer", fields: [userId], references: [id])
userId String @unique
favorite favorite[]
movingInfo movingInfo[]
estimate estimate[]
review review[]
estimateRequest estimateRequest[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// USER - 이사 전문가 프로필 정보
model mover {
id Int @id @default(autoincrement())
profileImage String?
career String
confirmedCount Int @default(0)
serviceArea String
servieType serviceType[]
user user @relation("Mover", fields: [userId], references: [id])
userId String @unique
favorite favorite[]
estimate estimate[]
review review[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// USER - 알람
model notification {
id Int @id @default(autoincrement())
notificationType String
isRead Boolean @default(false)
createdAt DateTime @default(now())
user user @relation(fields: [userId], references: [id])
userId String
}
// 고객 - 찜하기
model favorite {
id Int @id @default(autoincrement())
customerId customer @relation(fields: [customerRequestId], references: [id])
moverId mover @relation(fields: [moverRequestId], references: [id])
customerRequestId Int
moverRequestId Int
createdAt DateTime @default(now())
}
// 고객 - 이사 정보
model movingInfo {
id Int @id @default(autoincrement())
movingType String
movingDate DateTime
startAddress String
endAddress String
customerId customer @relation(fields: [customerRequestId], references: [id])
customerRequestId Int
estimate estimate[]
review review[]
estimateRequest estimateRequest[]
confirmEstimate confirmEstimate? @relation("ConfirmEstimateMovingInfo")
}
// 이사전문가 - 견적
model estimate {
id Int @id @default(autoincrement())
price Int
comment String?
customer customer @relation(fields: [customerId], references: [id])
movingInfo movingInfo @relation(fields: [movingInfoId], references: [id])
mover mover @relation(fields: [moverId], references: [id])
moverId Int
movingInfoId Int
customerId Int
review review[]
estimateRequest estimateRequest @relation("Estimate", fields: [estimateRequestId], references: [id])
estimateRequestId Int @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
confirmEstimate confirmEstimate? @relation("ConfirmEstimate")
}
// 확정된 견적서를 어떻게 처리 할까 생각하다가 테이블을 하나 만드는게 좋다고 생각하여 작성했습니다.
model confirmEstimate {
id Int @id @default(autoincrement())
movingInfo movingInfo @relation("ConfirmEstimateMovingInfo", fields: [movingInfoId], references: [id])
estimate estimate @relation("ConfirmEstimate", fields: [estimateId], references: [id])
estimateId Int @unique
movingInfoId Int @unique
createdAt DateTime @default(now()) // 확정 시간
updatedAt DateTime @updatedAt // 확정 취소시 시간
}
// 이사전문가 - 견적 요청
model estimateRequest {
id Int @id @default(autoincrement())
isDesignted Boolean
customer customer @relation(fields: [customerId], references: [id])
movingInfo movingInfo @relation(fields: [movingInfoId], references: [id])
estimate estimate? @relation("Estimate")
customerId Int
movingInfoId Int
createdAt DateTime @default(now())
}
// 이사전문가 - 견적서 - 리뷰
model review {
id Int @id @default(autoincrement())
rating Int
comment String?
mover mover @relation(fields: [moverId], references: [id])
customer customer @relation(fields: [customerId], references: [id])
movingInfo movingInfo @relation(fields: [movingInfoId], references: [id])
estimate estimate @relation(fields: [estimateId], references: [id])
estimateId Int
moverId Int
customerId Int
movingInfoId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
스키마 짜봤는데 혹시 보시고 수정할 부분 생기시면 알려주세요,
코드잇 erd를 보고 작성했습니다.
확정된 견적서를 어떻게 처리 할건지 의문이 들어 생각해보다가 따로 테이블을 생성해 저장하려고 생각했습니다.