Advertisement
mitrakov

Slick Auto Generate DDL

Sep 26th, 2018
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.45 KB | None | 0 0
  1. // Slick Auto-generating DDL
  2. // Slick allows to use a Stand-Alone generator, or integrate DDL-generating phase into alive project
  3. // Here we'll write a Stand-Alone generator
  4.  
  5. // Create sbt project with the following settings:
  6. // build.sbt:
  7. name := "slick-gen"
  8. version := "1.0.0"
  9. scalaVersion := "2.12.6"
  10.  
  11. libraryDependencies += "com.typesafe.slick" %% "slick-codegen" % "3.2.0"
  12. libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.39"       // change this line to your DBMS driver!
  13.  
  14. // project/assembly.sbt:
  15. addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.7") // to generate FAT jar
  16.  
  17. // Main.scala:
  18. object Main extends App {
  19.   if (args.length != 7) println("Please specify 7 parameters:\n\nprofile      - Fully qualified name of the profile class, e.g. “slick.jdbc.MySQLProfile”\njdbcDriver   - Fully qualified name of the JDBC driver class, e.g. “com.mysql.jdbc.Driver”\nurl          - JDBC url, e.g. “jdbc:mysql://localhost/test?useSSL=false”\noutputFolder - Place where the package folder structure should be put\npkg          - Scala package the generated code should be places in\nuser         - database connection user name\npassword     - database connection password")
  20.   else SourceCodeGenerator.main(args)
  21. }
  22.  
  23.  
  24.  
  25. // run "sbt assembly" to build a fat jar
  26. // usage:
  27. java -jar slick-gen-assembly-1.0.0.jar slick.jdbc.MySQLProfile com.mysql.jdbc.Driver "jdbc:mysql://localhost/mydb?useSSL=false" /Users/mitrakov/out/ dao root 1234
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement