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

datasource db {
  provider = "postgresql"
}

enum VoiceExperienceStatus {
  UPLOADED
  TRANSCRIBING
  TRANSCRIBED
  ANALYZING
  ANALYZED
  FAILED
}

model Place {
  id            String            @id @default(cuid())
  googlePlaceId String            @unique
  name          String
  latitude      Float
  longitude     Float
  experiences   VoiceExperience[]
  createdAt     DateTime          @default(now())
  updatedAt     DateTime          @updatedAt
}

model User {
  id               String            @id @default(cuid())
  telegramId       String            @unique
  username         String?
  firstName        String?
  lastName         String?
  photoUrl         String?
  languageCode     String?
  voiceExperiences VoiceExperience[]
  createdAt        DateTime          @default(now())
  updatedAt        DateTime          @updatedAt
}

model VoiceExperience {
  id              String                @id @default(cuid())
  placeId         String
  place           Place                 @relation(fields: [placeId], references: [id])
  userId          String?
  user            User?                 @relation(fields: [userId], references: [id])
  durationSeconds Int
  audioObjectKey  String
  status          VoiceExperienceStatus @default(UPLOADED)
  transcript      String?
  analysis        Json?
  createdAt       DateTime              @default(now())
  updatedAt       DateTime              @updatedAt
}
