package de.kif.backend.database

import de.kif.common.model.Language
import de.kif.common.model.Permission
import org.jetbrains.exposed.sql.Table

object DbTrack : Table() {
    val id = long("id").autoIncrement().primaryKey()
    val name = varchar("name", 2048)
    val color = varchar("color", 32)

    val createdAt = long("createdAt")
    val updatedAt = long("updatedAt")
}

object DbWorkGroup : Table() {
    val id = long("id").autoIncrement().primaryKey()
    val name = varchar("name", 2048)
    val description = text("description")

    val interested = integer("interested")
    val trackId = long("track_id").nullable()
    val projector = bool("projector")
    val resolution = bool("resolution")

    val internet = bool("internet")
    val whiteboard = bool("whiteboard")
    val blackboard = bool("blackboard")
    val accessible = bool("accessible")

    val language = enumeration("language", Language::class)

    val length = integer("length")
    val constraints = text("constraints")

    val createdAt = long("createdAt")
    val updatedAt = long("updatedAt")
}

object DbRoom : Table() {
    val id = long("id").autoIncrement().primaryKey()
    val name = varchar("name", 2048)

    val places = integer("places")
    val projector = bool("projector")

    val internet = bool("internet")
    val whiteboard = bool("whiteboard")
    val blackboard = bool("blackboard")
    val accessible = bool("accessible")

    val createdAt = long("createdAt")
    val updatedAt = long("updatedAt")
}

object DbSchedule : Table() {
    val id = long("id").autoIncrement().primaryKey()
    val workGroupId = long("work_group_id").index()
    val roomId = long("room_id").index()
    val day = integer("day").index()
    val time = integer("time_slot")
    val lookRoom = bool("look_room").default(false)
    val lookTime = bool("look_time").default(false)

    val createdAt = long("createdAt")
    val updatedAt = long("updatedAt")
}

object DbUser : Table() {
    val id = long("id").autoIncrement().primaryKey()
    val username = varchar("username", 64).uniqueIndex()
    val password = varchar("password", 64)

    val createdAt = long("createdAt")
    val updatedAt = long("updatedAt")
}

object DbUserPermission : Table() {
    val userId = long("id").primaryKey(0)
    val permission = enumeration("permission", Permission::class).primaryKey(1)
}

object DbPost : Table() {
    val id = long("id").autoIncrement().primaryKey()
    val name = varchar("name", 2048)

    val content = text("content")
    val url = varchar("url", 64).uniqueIndex()
    val image = varchar("image", 64).nullable()
    val pinned = bool("pinned")
    val hideOnProjector = bool("hideOnProjector")

    val createdAt = long("createdAt")
    val updatedAt = long("updatedAt")
}
