aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/Main.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/Main.scala')
-rw-r--r--src/main/scala/Main.scala54
1 files changed, 23 insertions, 31 deletions
diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala
index e71a9e8..eee6c6f 100644
--- a/src/main/scala/Main.scala
+++ b/src/main/scala/Main.scala
@@ -1,18 +1,13 @@
import java.net.URI
-import java.nio.file.Paths
import scala.concurrent.Await
import scala.concurrent.duration.Duration
-import scala.concurrent.ExecutionContext.Implicits.global
-import slick.backend.DatabaseConfig
+import slick.basic.DatabaseConfig
import slick.codegen.SourceCodeGenerator
-import slick.driver.JdbcProfile
+import slick.jdbc.JdbcProfile
trait TableFileGenerator { self: SourceCodeGenerator =>
- def writeTablesToFile(profile: String,
- folder: String,
- pkg: String,
- fileName: String): Unit
+ def writeTablesToFile(profile: String, folder: String, pkg: String, fileName: String): Unit
}
trait RowFileGenerator { self: SourceCodeGenerator =>
@@ -33,9 +28,7 @@ object Generator {
folder: String,
pkg: String,
fileName = s"${camelSchemaName}Tables.scala")
- rowGen.writeRowsToFile(folder: String,
- pkg: String,
- fileName = s"${camelSchemaName}Rows.scala")
+ rowGen.writeRowsToFile(folder: String, pkg: String, fileName = s"${camelSchemaName}Rows.scala")
}
def run(uri: URI,
@@ -57,21 +50,18 @@ object Generator {
def importStatements(imports: List[String]) = imports.map("import " + _).mkString("\n")
try {
- val dbModel: slick.model.Model = Await.result(
- dc.db.run(
- ModelTransformation.createModel(dc.driver, parsedSchemasOpt)),
- Duration.Inf)
+ val dbModel: slick.model.Model =
+ Await.result(dc.db.run(ModelTransformation.createModel(dc.profile, parsedSchemasOpt)), Duration.Inf)
parsedSchemasOpt.getOrElse(Map.empty).foreach {
case (schemaName, tables) =>
val profile =
- s"""slick.backend.DatabaseConfig.forConfig[slick.driver.JdbcProfile]("${uri
- .getFragment()}").driver"""
+ s"""slick.basic.DatabaseConfig.forConfig[slick.jdbc.JdbcProfile]("${uri
+ .getFragment()}").profile"""
- val schemaOnlyModel = Await.result(
- dc.db.run(ModelTransformation
- .createModel(dc.driver, Some(Map(schemaName -> tables)))),
- Duration.Inf)
+ val schemaOnlyModel = Await.result(dc.db.run(ModelTransformation
+ .createModel(dc.profile, Some(Map(schemaName -> tables)))),
+ Duration.Inf)
val rowGenerator = new RowSourceCodeGenerator(
model = schemaOnlyModel,
@@ -85,16 +75,18 @@ object Generator {
)
val tableGenerator =
- new TableSourceCodeGenerator(schemaOnlyModel = schemaOnlyModel,
- headerComment = header,
- imports = importStatements(tablesFileImports),
- schemaName = schemaName,
- fullDatabaseModel = dbModel,
- pkg = pkg,
- manualForeignKeys,
- parentType = parentType,
- idType,
- typeReplacements)
+ new TableSourceCodeGenerator(
+ schemaOnlyModel = schemaOnlyModel,
+ headerComment = header,
+ imports = importStatements(tablesFileImports),
+ schemaName = schemaName,
+ fullDatabaseModel = dbModel,
+ pkg = pkg,
+ manualForeignKeys,
+ parentType = parentType,
+ idType,
+ typeReplacements
+ )
outputSchemaCode(schemaName = schemaName,
profile = profile,