Commit ebb1fbbc authored by Peter van 't Hof's avatar Peter van 't Hof

Added dual indexes

parent 2d604261
...@@ -51,8 +51,9 @@ object SummaryToSqlite extends ToolCommand { ...@@ -51,8 +51,9 @@ object SummaryToSqlite extends ToolCommand {
import nl.lumc.sasc.biopet.utils.summary.db.Schema._ import nl.lumc.sasc.biopet.utils.summary.db.Schema._
val setup = DBIO.seq( val setup = DBIO.seq(
(samples.schema ++ libraries.schema) (runs.schema ++ samples.schema ++
.create samplesRuns.schema ++ libraries.schema ++
librariesRuns.schema ++ pipelines.schema).create
) )
val setupFuture = db.run(setup) val setupFuture = db.run(setup)
Await.result(setupFuture, Duration.Inf) Await.result(setupFuture, Duration.Inf)
......
...@@ -17,27 +17,45 @@ object Schema { ...@@ -17,27 +17,45 @@ object Schema {
} }
val runs = TableQuery[Runs] val runs = TableQuery[Runs]
class Samples(tag: Tag) extends Table[(Int, String, Int, Blob)](tag, "Samples") { class Samples(tag: Tag) extends Table[(Int, String, Option[Blob])](tag, "Samples") {
def sampleId = column[Int]("sampleId", O.PrimaryKey) def sampleId = column[Int]("sampleId", O.PrimaryKey)
def sampleName = column[String]("sampleName") def sampleName = column[String]("sampleName")
def runId = column[Int]("runId") def tags = column[Option[Blob]]("tags")
def tags = column[Blob]("tags")
def * = (sampleId, sampleName, runId, tags) def * = (sampleId, sampleName, tags)
} }
val samples = TableQuery[Samples] val samples = TableQuery[Samples]
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]
class Libraries(tag: Tag) extends Table[(Int, String, Int, Blob)](tag, "Libraries") { class Libraries(tag: Tag) extends Table[(Int, String, Int, Option[Blob])](tag, "Libraries") {
def libraryId = column[Int]("libraryId", O.PrimaryKey) def libraryId = column[Int]("libraryId", O.PrimaryKey)
def libraryName = column[String]("libraryName") def libraryName = column[String]("libraryName")
def sampleId = column[Int]("sampleId") def sampleId = column[Int]("sampleId")
def tags = column[Blob]("tags") def tags = column[Option[Blob]]("tags")
def * = (libraryId, libraryName, sampleId, tags) def * = (libraryId, libraryName, sampleId, tags)
} }
val libraries = TableQuery[Libraries] val libraries = TableQuery[Libraries]
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]
class Pipelines(tag: Tag) extends Table[(Int, String)](tag, "Pipelines") { class Pipelines(tag: Tag) extends Table[(Int, String)](tag, "Pipelines") {
def pipelineId = column[Int]("runId", O.PrimaryKey) def pipelineId = column[Int]("runId", O.PrimaryKey)
def pipelineName = column[String]("sampleName") def pipelineName = column[String]("sampleName")
...@@ -45,5 +63,4 @@ object Schema { ...@@ -45,5 +63,4 @@ object Schema {
def * = (pipelineId, pipelineName) def * = (pipelineId, pipelineName)
} }
val pipelines = TableQuery[Pipelines] val pipelines = TableQuery[Pipelines]
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment