enum BADGES {
    P1
    P2
    P3
    D1
    D2
    D3
    DAY1
}

enum PERMISSION {
    ADMIN_EVENT
    ADMIN_USER
    AUDIO_ADMIN
    ADMIN_STATION
    ADMIN_KEYWORD
    AUDIO
    PILOT
    DISPO
}

model User {
    id            String    @id @default(uuid())
    publicId      String    @unique
    firstname     String
    lastname      String
    email         String    @unique
    password      String
    vatsimCid     Int?      @map(name: "vatsim_cid")
    moodleId      Int?      @map(name: "moodle_id")
    emailVerified DateTime? @map(name: "email_verified")

    // Settings:
    settingsNtfyRoom  String? @map(name: "settings_ntfy_room")
    settingsMicDevice String? @map(name: "settings_mic_device")
    settingsMicVolume Int?    @map(name: "settings_mic_volume")

    image                 String?
    badges                BADGES[]                @default([])
    permissions           PERMISSION[]            @default([])
    createdAt             DateTime                @default(now()) @map(name: "created_at")
    updatedAt             DateTime                @default(now()) @map(name: "updated_at")
    isBanned              Boolean                 @default(false) @map(name: "is_banned")
    // relations:
    oauthTokens           OAuthToken[]
    discordAccounts       DiscordAccount[]
    participants          Participant[]
    EventAppointmentUser  EventAppointment[]      @relation("EventAppointmentUser")
    EventAppointment      EventAppointment[]
    SentMessages          ChatMessage[]           @relation("SentMessages")
    ReceivedMessages      ChatMessage[]           @relation("ReceivedMessages")
    SentReports           Report[]                @relation("SentReports")
    ReceivedReports       Report[]                @relation("ReceivedReports")
    ReviewedReports       Report[]                @relation("ReviewedReports")
    Mission               Mission[]
    MissionOnStationUsers MissionOnStationUsers[]
    ConnectedDispatcher   ConnectedDispatcher[]
    ConnectedAircraft     ConnectedAircraft[]
    PositionLog           PositionLog[]

    @@map(name: "users")
}

model DiscordAccount {
    id           Int      @id @default(autoincrement())
    discordId    String   @unique @map(name: "discord_id")
    userId       String   @map(name: "user_id")
    email        String   @map(name: "email")
    username     String   @map(name: "username")
    avatar       String?  @map(name: "avatar")
    globalName   String   @map(name: "global_name")
    verified     Boolean  @default(false)
    accessToken  String   @map(name: "access_token")
    refreshToken String   @map(name: "refresh_token")
    tokenType    String   @map(name: "token_type")
    createdAt    DateTime @default(now()) @map(name: "created_at")
    updatedAt    DateTime @default(now()) @map(name: "updated_at")

    // relations:
    user User @relation(fields: [userId], references: [id]) // Beziehung zu User

    @@map(name: "discord_accounts")
}
