Skip to content

Commit

Permalink
Extract getTables.
Browse files Browse the repository at this point in the history
  • Loading branch information
lastland committed Feb 28, 2016
1 parent 72adb24 commit 84e32c1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions migrations/slick/src/main/scala/Codegen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import slick.model.Model
import slick.driver.JdbcProfile
import slick.codegen.SourceCodeGenerator

trait SlickCodegen {
Expand All @@ -22,6 +23,13 @@ trait SlickCodegen {

def tableNames: Seq[String] = List()

def getTables(driver: JdbcProfile) = driver.createModel(Some(
driver.defaultTables.map { s =>
s.filter { t =>
tableNames.contains(t.name.name)
}
}))

def getGenerator(m: Model, version: Int) = {
new SourceCodeGenerator(m) {
override def packageCode(
Expand All @@ -42,12 +50,7 @@ object Version{
return
}
val driver = mm.dbConfig.driver
val action = driver.createModel(Some(
driver.defaultTables.map { s =>
s.filter { t =>
tableNames.contains(t.name.name)
}
})) flatMap { case m =>
val action = getTables(driver).flatMap { case m =>
DBIO.from {
Future {
val latest = mm.latest
Expand Down

0 comments on commit 84e32c1

Please sign in to comment.