package models

import models.profile.api._
import slick.lifted.{MappedProjection, Tag}


case class ExportedVulnerability[T] (vulnerabilityName: String, ticket: T, ticketFormatVersion: Int/*, maintainedAutomatically: Boolean*/)

abstract class ExportedVulnerabilities[T, U](tag: Tag, tableNamePart: String) extends Table[(Int, ExportedVulnerability[T])](tag, s"exported_${tableNamePart}_vulnerabilities"){
  def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
  def vulnerabilityName = column[String]("vulnerability_name")
  def ticketFormatVersion = column[Int]("ticket_format_version")
  //def maintainedAutomatically = column[Boolean]("maintained_automatically")

  def base: MappedProjection[ExportedVulnerability[T], U]// = (vulnerabilityName, ticket, ticketFormatVersion) <> ((ExportedVulnerability.apply[T] _).tupled, ExportedVulnerability.unapply[T])
  def * = (id, base)

  def idx_vulnerabilityName = index(s"idx_${tableName}_vulnerabilityName", vulnerabilityName, unique = true)
}