Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/build.sbt b/build.sbt
- index 4b6145e9..547fd084 100644
- --- a/build.sbt
- +++ b/build.sbt
- @@ -49,6 +49,7 @@ libraryDependencies ++= Seq(
- "com.h2database" % "h2" % "1.4.196",
- "org.mariadb.jdbc" % "mariadb-java-client" % "2.2.3",
- "org.postgresql" % "postgresql" % "42.1.4",
- + "com.microsoft.sqlserver" % "mssql-jdbc" % "6.4.0.jre8",
- "ch.qos.logback" % "logback-classic" % "1.2.3",
- "com.zaxxer" % "HikariCP" % "2.7.4",
- "com.typesafe" % "config" % "1.3.2",
- diff --git a/src/main/scala/gitbucket/core/util/DatabaseConfig.scala b/src/main/scala/gitbucket/core/util/DatabaseConfig.scala
- index a2f6682e..e7b6f1b1 100644
- --- a/src/main/scala/gitbucket/core/util/DatabaseConfig.scala
- +++ b/src/main/scala/gitbucket/core/util/DatabaseConfig.scala
- @@ -5,10 +5,15 @@ import java.io.File
- import Directory._
- import ConfigUtil._
- -import com.github.takezoe.slick.blocking.{BlockingH2Driver, BlockingJdbcProfile, BlockingMySQLDriver}
- +import com.github.takezoe.slick.blocking.{
- + BlockingH2Driver,
- + BlockingJdbcProfile,
- + BlockingMySQLDriver,
- + BlockingSQLServerDriver
- +}
- import gitbucket.core.util.SyntaxSugars.defining
- import liquibase.database.AbstractJdbcDatabase
- -import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
- +import liquibase.database.core.{H2Database, MSSQLDatabase, MySQLDatabase, PostgresDatabase}
- import org.apache.commons.io.FileUtils
- import scala.reflect.ClassTag
- @@ -77,14 +82,12 @@ sealed trait DatabaseType {
- object DatabaseType {
- def apply(url: String): DatabaseType = {
- - if (url.startsWith("jdbc:h2:")) {
- - H2
- - } else if (url.startsWith("jdbc:mysql:")) {
- - MySQL
- - } else if (url.startsWith("jdbc:postgresql:")) {
- - PostgreSQL
- - } else {
- - throw new IllegalArgumentException(s"${url} is not supported.")
- + url match {
- + case _ if url.startsWith("jdbc:h2:") => H2
- + case _ if url.startsWith("jdbc:mysql:") => MySQL
- + case _ if url.startsWith("jdbc:postgresql:") => PostgreSQL
- + case _ if url.startsWith("jdbc:sqlserver:") => MsSQL
- + case _ => throw new IllegalArgumentException(s"$url is not supported.")
- }
- }
- @@ -106,6 +109,12 @@ object DatabaseType {
- val liquiDriver = new PostgresDatabase()
- }
- + object MsSQL extends DatabaseType {
- + val jdbcDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
- + val slickDriver = BlockingSQLServerDriver
- + val liquiDriver = new MSSQLDatabase
- + }
- +
- object BlockingPostgresDriver extends slick.jdbc.PostgresProfile with BlockingJdbcProfile {
- override def quoteIdentifier(id: String): String = {
- val s = new StringBuilder(id.length + 4) append '"'
Add Comment
Please, Sign In to add comment