Skip to content

Commit df1b5be

Browse files
authored
Revert "Revert "GAWB-1788 Upgrade to Slick 3.2 (#178)" (#179)"
This reverts commit 7ee59eb.
1 parent 7ee59eb commit df1b5be

File tree

7 files changed

+32
-23
lines changed

7 files changed

+32
-23
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ libraryDependencies ++= Seq(
2626
"com.typesafe.akka" %% "akka-slf4j" % "2.3.11",
2727
"com.typesafe" % "config" % "1.2.1",
2828
"com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
29-
"com.typesafe.slick" %% "slick" % "3.0.0",
29+
"com.typesafe.slick" %% "slick" % "3.2.0",
3030
"com.zaxxer" % "HikariCP" % "2.3.9",
3131
"io.spray" %% "spray-can" % sprayV,
3232
"io.spray" %% "spray-client" % sprayV,

src/main/resources/reference.conf

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,23 @@ akka {
4949

5050
// MySQL example
5151
//sqlDatabase = {
52-
// url = "jdbc:mysql://DB_HOST:DB_PORT/DB_NAME"
53-
// driver = com.mysql.jdbc.Driver
54-
// user = DB_USER
55-
// password = DB_PASSWORD
52+
// profile = "slick.jdbc.MySQLProfile$"
53+
// db {
54+
// url = "jdbc:mysql://DB_HOST:DB_PORT/DB_NAME"
55+
// driver = "com.mysql.jdbc.Driver"
56+
// user = DB_USER
57+
// password = DB_PASSWORD
58+
// }
5659
//}
5760

5861
// H2 example
5962
sqlDatabase = {
60-
url = "jdbc:h2:file:local"
61-
user = root
62-
driver = org.h2.Driver
63-
connectionPool = disabled
64-
keepAliveConnection = true
63+
profile = "slick.jdbc.H2Profile$"
64+
db {
65+
connectionPool = disabled
66+
driver = "org.h2.Driver"
67+
url = "jdbc:h2:file:local"
68+
keepAliveConnection = true
69+
user = root
70+
}
6571
}

src/main/scala/org/broadinstitute/dsde/agora/server/AgoraConfig.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import net.ceedubs.ficus.Ficus._
55
import org.broadinstitute.dsde.agora.server.model.AgoraEntityType
66
import org.broadinstitute.dsde.agora.server.model.AgoraEntityType.EntityType
77
import org.broadinstitute.dsde.agora.server.webservice.routes.{AgoraDirectives, MockAgoraDirectives, OpenIdConnectDirectives}
8-
import slick.jdbc.JdbcBackend.Database
8+
import slick.basic.DatabaseConfig
9+
import slick.jdbc.JdbcProfile
910

1011
object AgoraConfig {
1112

@@ -55,7 +56,7 @@ object AgoraConfig {
5556
lazy val mongoDbDatabase = config.as[Option[String]]("mongodb.db").getOrElse("agora")
5657

5758
// SQL
58-
lazy val sqlDatabase = Database.forConfig("sqlDatabase")
59+
lazy val sqlDatabase = DatabaseConfig.forConfig[JdbcProfile]("sqlDatabase")
5960

6061
// Google Credentials
6162
lazy val gcsProjectId = config.as[String]("gcs.project.id")

src/main/scala/org/broadinstitute/dsde/agora/server/ServerInitializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ServerInitializer extends LazyLogging {
2929
EmbeddedMongo.stopMongo()
3030

3131
println("Closing connection to sql db.")
32-
AgoraConfig.sqlDatabase.close()
32+
AgoraConfig.sqlDatabase.db.close()
3333

3434
stopAndCatchExceptions(stopWebServiceActors())
3535
}

src/main/scala/org/broadinstitute/dsde/agora/server/dataaccess/permissions/PermissionsClient.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ import org.broadinstitute.dsde.agora.server.model.AgoraEntity
88
import scala.concurrent.{Await, Future}
99
import scala.concurrent.ExecutionContext.Implicits.global
1010
import scala.concurrent.duration._
11-
import slick.driver.MySQLDriver.api._
12-
1311
import scala.util.Try
1412

1513
trait PermissionsClient {
14+
import AgoraConfig.sqlDatabase.profile.api._
15+
val db = AgoraConfig.sqlDatabase.db
1616

17-
val db = AgoraConfig.sqlDatabase
1817
val timeout = 10.seconds
1918

2019
def alias(entity: AgoraEntity): String

src/test/resources/reference.conf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ openam {
3434

3535
// Default uses a local h2 database
3636
sqlDatabase = {
37-
url = "jdbc:h2:mem:test1"
38-
driver = org.h2.Driver
39-
connectionPool = disabled
40-
keepAliveConnection = true
37+
profile = "slick.jdbc.H2Profile$"
38+
db {
39+
connectionPool = disabled
40+
driver = "org.h2.Driver"
41+
url = "jdbc:h2:mem:test1"
42+
keepAliveConnection = true
43+
}
4144
}

src/test/scala/org/broadinstitute/dsde/agora/server/AgoraTestFixture.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait AgoraTestFixture {
2020
EmbeddedMongo.startMongo()
2121

2222
println("Connecting to test sql database.")
23-
db = AgoraConfig.sqlDatabase
23+
db = AgoraConfig.sqlDatabase.db
2424
clearDatabases()
2525

2626
val setupFuture = createTableIfNotExists(entities, permissions, users)
@@ -73,7 +73,7 @@ trait AgoraTestFixture {
7373
tables map { table =>
7474
db.run(MTable.getTables(table.baseTableRow.tableName)).flatMap { result =>
7575
if (result.nonEmpty) {
76-
db.run(table.delete)
76+
db.run(sqlu"delete from #${table.baseTableRow.tableName}")
7777
} else {
7878
Future.successful(())
7979
}
@@ -84,7 +84,7 @@ trait AgoraTestFixture {
8484

8585
def ensureSqlDatabaseIsRunning() = {
8686
println("Connecting to test sql database.")
87-
db = AgoraConfig.sqlDatabase
87+
db = AgoraConfig.sqlDatabase.db
8888

8989
println("Populating sql database.")
9090
Await.result(createTableIfNotExists(entities, users, permissions), timeout)

0 commit comments

Comments
 (0)