Schema.scala 4.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
package nl.lumc.sasc.biopet.utils.summary.db

import java.sql.Blob

import slick.driver.H2Driver.api._

/**
  * Created by pjvan_thof on 27-1-17.
  */
object Schema {

  class Runs(tag: Tag) extends Table[(Int, String)](tag, "Runs") {
    def runId = column[Int]("runId", O.PrimaryKey)
Peter van 't Hof's avatar
Peter van 't Hof committed
14
    def runName = column[String]("runName")
15 16 17 18 19

    def * = (runId, runName)
  }
  val runs = TableQuery[Runs]

Peter van 't Hof's avatar
Peter van 't Hof committed
20
  class Samples(tag: Tag) extends Table[(Int, String, Option[Blob])](tag, "Samples") {
Peter van 't Hof's avatar
Peter van 't Hof committed
21 22
    def sampleId = column[Int]("id", O.PrimaryKey)
    def sampleName = column[String]("name")
Peter van 't Hof's avatar
Peter van 't Hof committed
23
    def tags = column[Option[Blob]]("tags")
24

Peter van 't Hof's avatar
Peter van 't Hof committed
25
    def * = (sampleId, sampleName, tags)
26 27 28
  }
  val samples = TableQuery[Samples]

Peter van 't Hof's avatar
Peter van 't Hof committed
29 30 31 32 33 34 35 36 37
  class SamplesRuns(tag: Tag) extends Table[(Int, Int)](tag, "SamplesRuns") {
    def sampleId = column[Int]("sampleId")
    def runId = column[Int]("runId")

    def * = (sampleId, runId)

    def idx = index("idx_samples_runs", (sampleId, runId), unique = true)
  }
  val samplesRuns = TableQuery[SamplesRuns]
38

Peter van 't Hof's avatar
Peter van 't Hof committed
39
  class Libraries(tag: Tag) extends Table[(Int, String, Int, Option[Blob])](tag, "Libraries") {
Peter van 't Hof's avatar
Peter van 't Hof committed
40 41
    def libraryId = column[Int]("id", O.PrimaryKey)
    def libraryName = column[String]("name")
42
    def sampleId = column[Int]("sampleId")
Peter van 't Hof's avatar
Peter van 't Hof committed
43
    def tags = column[Option[Blob]]("tags")
44 45 46 47 48

    def * = (libraryId, libraryName, sampleId, tags)
  }
  val libraries = TableQuery[Libraries]

Peter van 't Hof's avatar
Peter van 't Hof committed
49 50 51 52 53 54 55 56 57 58
  class LibrariesRuns(tag: Tag) extends Table[(Int, Int)](tag, "LibrariesRuns") {
    def libraryId = column[Int]("libraryId")
    def runId = column[Int]("runId")

    def * = (libraryId, runId)

    def idx = index("idx_libraries_runs", (libraryId, runId), unique = true)
  }
  val librariesRuns = TableQuery[LibrariesRuns]

Peter van 't Hof's avatar
Peter van 't Hof committed
59 60 61
  class PipelineNames(tag: Tag) extends Table[(Int, String)](tag, "PipelineNames") {
    def id = column[Int]("id", O.PrimaryKey)
    def name = column[String]("name")
62

Peter van 't Hof's avatar
Peter van 't Hof committed
63
    def * = (id, name)
64
  }
Peter van 't Hof's avatar
Peter van 't Hof committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
  val pipelineNames = TableQuery[PipelineNames]

  class ModuleNames(tag: Tag) extends Table[(Int, String)](tag, "ModuleNames") {
    def id = column[Int]("id", O.PrimaryKey)
    def name = column[String]("name")

    def * = (id, name)
  }
  val moduleNames = TableQuery[ModuleNames]


  class Stats(tag: Tag) extends Table[(Int, Int, Option[Int], Option[Int], Option[Int], Blob, Option[String])](tag, "Stats") {
    def pipelineId = column[Int]("pipelineId")
    def runId = column[Int]("runId")
    def moduleId = column[Option[Int]]("moduleId")
    def sampleId = column[Option[Int]]("sampleId")
    def libraryId = column[Option[Int]]("libraryId")
    def stats = column[Blob]("stats")
    def schema = column[Option[String]]("schema")

    def * = (pipelineId, runId, moduleId, sampleId, libraryId, stats, schema)

Peter van 't Hof's avatar
Peter van 't Hof committed
87
    def idx = index("idx_stats", (pipelineId, runId, moduleId, sampleId, libraryId), unique = true)
Peter van 't Hof's avatar
Peter van 't Hof committed
88 89 90
  }
  val stats = TableQuery[Stats]

Peter van 't Hof's avatar
Peter van 't Hof committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
  class Settings(tag: Tag) extends Table[(Int, Int, Option[Int], Option[Int], Option[Int], Blob, Option[String])](tag, "Settings") {
    def pipelineId = column[Int]("pipelineId")
    def runId = column[Int]("runId")
    def moduleId = column[Option[Int]]("moduleId")
    def sampleId = column[Option[Int]]("sampleId")
    def libraryId = column[Option[Int]]("libraryId")
    def stats = column[Blob]("stats")
    def schema = column[Option[String]]("schema")

    def * = (pipelineId, runId, moduleId, sampleId, libraryId, stats, schema)

    def idx = index("idx_settings", (pipelineId, runId, moduleId, sampleId, libraryId), unique = true)
  }
  val settings = TableQuery[Settings]

Peter van 't Hof's avatar
Peter van 't Hof committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
  class Files(tag: Tag) extends Table[(Int, Int, Option[Int], Option[Int], Option[Int], String, String)](tag, "Files") {
    def pipelineId = column[Int]("pipelineId")
    def runId = column[Int]("runId")
    def moduleId = column[Option[Int]]("moduleId")
    def sampleId = column[Option[Int]]("sampleId")
    def libraryId = column[Option[Int]]("libraryId")
    def path = column[String]("path")
    def md5 = column[String]("md5")

    def * = (pipelineId, runId, moduleId, sampleId, libraryId, path, md5)

    def idx = index("idx_files", (pipelineId, runId, sampleId, libraryId, path), unique = true)
  }
  val files = TableQuery[Files]

Peter van 't Hof's avatar
Peter van 't Hof committed
121
  class Executables(tag: Tag) extends Table[(Int, String, Option[String], Option[String], Option[String], Option[String])](tag, "Executables") {
Peter van 't Hof's avatar
Peter van 't Hof committed
122
    def runId = column[Int]("runId")
Peter van 't Hof's avatar
Peter van 't Hof committed
123 124 125 126 127 128 129
    def toolName = column[String]("toolName")
    def version = column[Option[String]]("version")
    def javaVersion = column[Option[String]]("javaVersion")
    def exeMd5 = column[Option[String]]("exeMd5")
    def javaMd5 = column[Option[String]]("javaMd5")

    def * = (runId, toolName, version, javaVersion, exeMd5, javaMd5)
Peter van 't Hof's avatar
Peter van 't Hof committed
130

Peter van 't Hof's avatar
Peter van 't Hof committed
131
    def idx = index("idx_executables", (runId, toolName), unique = true)
Peter van 't Hof's avatar
Peter van 't Hof committed
132 133
  }
  val executables = TableQuery[Executables]
134
}