Switch Slick driver by system property

This commit is contained in:
Naoki Takezoe
2016-04-11 21:29:58 +09:00
parent 443498433d
commit 6c2fce1b16

View File

@@ -28,7 +28,19 @@ trait Profile {
} }
trait ProfileProvider { self: Profile => trait ProfileProvider { self: Profile =>
val profile = slick.driver.H2Driver
private val url = System.getProperty("db.url")
// private val user = System.getProperty("db.user")
// private val password = System.getProperty("db.password")
val profile = if(url.indexOf("h2") >= 0){
slick.driver.H2Driver
} else if(url.indexOf("mysql") >= 0) {
slick.driver.MySQLDriver
} else {
throw new ExceptionInInitializerError(s"${url} is not unsupported.")
}
} }
trait CoreProfile extends ProfileProvider with Profile trait CoreProfile extends ProfileProvider with Profile