// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
  output   = "../src/generated/prisma"
}

datasource db {
  provider = "sqlite"
}

model RealEstateArticle {
  id             Int     @id @default(autoincrement())
  articleNumber  String  @unique
  articleName    String?
  buildingType   String?
  tradeType      String?
  realEstateType String?
  tradTpNm       String?
  prcInfo        String?
  leasePrc       String?
  tagList        String?
  atclFetrDesc   String?
  atclCfmYmd     String?
  pnu            String?

  // 위치 정보 (address)
  city                String?
  division            String?
  sector              String?
  jibun               String?
  fullAddress         String?
  detailAddress       String?
  isAddressExposed    Boolean?
  xCoordinate         Float?
  yCoordinate         Float?
  legalDivisionNumber String?

  // 가격 정보 (priceInfo)
  dealPrice      String? // 매매가
  warrantyAmount String? // 전세 보증금
  rentAmount     String? // 월세
  loan           String? // 대출
  loanCode       String?
  loanTypeCode   String?

  // 관리비 정보 (maintenanceFee)
  managementFeeAmount       Int?
  managementFeeTypeCode     String?
  managementFeeCriteriaType String?

  // 건물 정보 (buildingInfo, facilityInfo)
  buildingUse                 String?
  buildingConjunctionDate     String?
  buildingConjunctionDateType String?
  approvalElapsedYear         Int?
  totalParkingCount           String?
  isParkingPossible           Boolean?
  isIllegalBuilding           Boolean?

  // 공간 정보 (spaceInfo)
  supplySpace           Float? // 공급면적
  exclusiveSpace        Float? // 전용면적
  landSpace             Float? // 대지지분
  targetFloor           String? // 해당층
  totalFloor            String? // 총층
  groundTotalFloor      String?
  undergroundTotalFloor String?
  floorType             String?
  floorInfo             String?
  residenceType         String?
  roomCount             Int?
  bathRoomCount         Int?
  direction             String?
  directionStandard     String?
  duplex                Boolean?

  // 입주 정보 (movingInInfo)
  movingInNegotiation Boolean?
  movingInDate        String?
  movingInType        String?

  // 중개사 정보 (agent)
  brokerName                 String?
  brokerageName              String?
  brokerId                   String?
  brokerAddress              String?
  brokerPhone                String?
  businessRegistrationNumber String?
  ownerConfirmationSaleCount Int?
  cpId                       String?
  cpNm                       String?

  // 매물 상세 설명
  articleDescription String?
  articleFeature     String?
  isDirectTrade      Boolean?
  isSafeLessorOfHug  Boolean?

  // 미디어 정보
  imageUrl    String?
  imageCount  Int?
  isVrExposed Boolean?

  // 검증/노출 정보 (verificationInfo)
  verificationType     String?
  isAssociationArticle Boolean?
  exposureStartDate    String?
  articleConfirmDate   String?

  // 편의시설 (facilityInfo - JSON 배열로 저장)
  facilityLife     String? // JSON array
  facilitySecurity String? // JSON array
  facilityEtc      String? // JSON array
  facilityAircon   String? // JSON array

  // 원본 JSON 전체 (보존용)
  jsonData Json

  isActive  Boolean @default(true)
  realtorId String?

  // 생성/수정 시간
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  // 랭킹 관련
  ranking       Int?
  cortarNo      String?
  lgeo          String?
  rankCheckDate String?

  @@index([articleNumber])
  @@index([tradeType])
  @@index([realEstateType])
  @@index([city, division])
}
