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
  googlePrimaryType String?
  googleTypes       String[]          @default([])
  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?
  isAdmin          Boolean           @default(false)
  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
  audioContentBase64 String?
  audioMimeType      String?
  audioAccessToken   String?               @unique
  status             VoiceExperienceStatus @default(UPLOADED)
  transcript         String?
  analysis           Json?
  createdAt          DateTime              @default(now())
  updatedAt          DateTime              @updatedAt
}
