Guest User

Untitled

a guest
Apr 18th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. diff --git a/build.sbt b/build.sbt
  2. index 4b6145e9..547fd084 100644
  3. --- a/build.sbt
  4. +++ b/build.sbt
  5. @@ -49,6 +49,7 @@ libraryDependencies ++= Seq(
  6. "com.h2database" % "h2" % "1.4.196",
  7. "org.mariadb.jdbc" % "mariadb-java-client" % "2.2.3",
  8. "org.postgresql" % "postgresql" % "42.1.4",
  9. + "com.microsoft.sqlserver" % "mssql-jdbc" % "6.4.0.jre8",
  10. "ch.qos.logback" % "logback-classic" % "1.2.3",
  11. "com.zaxxer" % "HikariCP" % "2.7.4",
  12. "com.typesafe" % "config" % "1.3.2",
  13.  
  14.  
  15. diff --git a/src/main/scala/gitbucket/core/util/DatabaseConfig.scala b/src/main/scala/gitbucket/core/util/DatabaseConfig.scala
  16. index a2f6682e..e7b6f1b1 100644
  17. --- a/src/main/scala/gitbucket/core/util/DatabaseConfig.scala
  18. +++ b/src/main/scala/gitbucket/core/util/DatabaseConfig.scala
  19. @@ -5,10 +5,15 @@ import java.io.File
  20.  
  21. import Directory._
  22. import ConfigUtil._
  23. -import com.github.takezoe.slick.blocking.{BlockingH2Driver, BlockingJdbcProfile, BlockingMySQLDriver}
  24. +import com.github.takezoe.slick.blocking.{
  25. + BlockingH2Driver,
  26. + BlockingJdbcProfile,
  27. + BlockingMySQLDriver,
  28. + BlockingSQLServerDriver
  29. +}
  30. import gitbucket.core.util.SyntaxSugars.defining
  31. import liquibase.database.AbstractJdbcDatabase
  32. -import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
  33. +import liquibase.database.core.{H2Database, MSSQLDatabase, MySQLDatabase, PostgresDatabase}
  34. import org.apache.commons.io.FileUtils
  35.  
  36. import scala.reflect.ClassTag
  37. @@ -77,14 +82,12 @@ sealed trait DatabaseType {
  38. object DatabaseType {
  39.  
  40. def apply(url: String): DatabaseType = {
  41. - if (url.startsWith("jdbc:h2:")) {
  42. - H2
  43. - } else if (url.startsWith("jdbc:mysql:")) {
  44. - MySQL
  45. - } else if (url.startsWith("jdbc:postgresql:")) {
  46. - PostgreSQL
  47. - } else {
  48. - throw new IllegalArgumentException(s"${url} is not supported.")
  49. + url match {
  50. + case _ if url.startsWith("jdbc:h2:") => H2
  51. + case _ if url.startsWith("jdbc:mysql:") => MySQL
  52. + case _ if url.startsWith("jdbc:postgresql:") => PostgreSQL
  53. + case _ if url.startsWith("jdbc:sqlserver:") => MsSQL
  54. + case _ => throw new IllegalArgumentException(s"$url is not supported.")
  55. }
  56. }
  57.  
  58. @@ -106,6 +109,12 @@ object DatabaseType {
  59. val liquiDriver = new PostgresDatabase()
  60. }
  61.  
  62. + object MsSQL extends DatabaseType {
  63. + val jdbcDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  64. + val slickDriver = BlockingSQLServerDriver
  65. + val liquiDriver = new MSSQLDatabase
  66. + }
  67. +
  68. object BlockingPostgresDriver extends slick.jdbc.PostgresProfile with BlockingJdbcProfile {
  69. override def quoteIdentifier(id: String): String = {
  70. val s = new StringBuilder(id.length + 4) append '"'
Add Comment
Please, Sign In to add comment