Add PostgreSQL support

This commit is contained in:
Naoki Takezoe
2016-04-14 11:39:42 +09:00
parent 8cb1ac734d
commit f37b5fa682
3 changed files with 15 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ libraryDependencies ++= Seq(
"com.novell.ldap" % "jldap" % "2009-10-07",
"com.h2database" % "h2" % "1.4.190",
"mysql" % "mysql-connector-java" % "5.1.38",
"org.postgresql" % "postgresql" % "9.4.1208",
"ch.qos.logback" % "logback-classic" % "1.1.1",
"com.zaxxer" % "HikariCP" % "2.4.5",
"com.typesafe" % "config" % "1.3.0",

View File

@@ -0,0 +1,5 @@
db {
url = "jdbc:postgresql://192.168.99.100:32768/gitbucket"
user = "test"
password = "test"
}

View File

@@ -4,7 +4,7 @@ import com.typesafe.config.ConfigFactory
import java.io.File
import Directory._
import liquibase.database.AbstractJdbcDatabase
import liquibase.database.core.{MySQLDatabase, H2Database}
import liquibase.database.core.{PostgresDatabase, MySQLDatabase, H2Database}
import org.apache.commons.io.FileUtils
object DatabaseConfig {
@@ -50,6 +50,8 @@ object DatabaseType {
H2
} else if(url.indexOf("mysql") >= 0){
MySQL
} else if(url.indexOf("postgresql") >= 0){
PostgreSQL
} else {
throw new IllegalArgumentException(s"${url} is not supported.")
}
@@ -66,4 +68,10 @@ object DatabaseType {
val slickDriver = slick.driver.MySQLDriver
val liquiDriver = new MySQLDatabase()
}
object PostgreSQL extends DatabaseType {
val jdbcDriver = "org.postgresql.Driver"
val slickDriver = slick.driver.PostgresDriver
val liquiDriver = new PostgresDatabase()
}
}