From 42d3585df567b93b76bf24ece71a8efad1aeeb97 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Thu, 2 Mar 2017 16:48:54 +0900 Subject: [PATCH] (refs #474)Define DB and models for deploy key support --- .../resources/update/gitbucket-core_4.11.xml | 13 +++++++++ .../gitbucket/core/GitBucketCoreModule.scala | 5 +++- .../gitbucket/core/model/DeployKey.scala | 27 +++++++++++++++++++ .../scala/gitbucket/core/model/Profile.scala | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/update/gitbucket-core_4.11.xml create mode 100644 src/main/scala/gitbucket/core/model/DeployKey.scala diff --git a/src/main/resources/update/gitbucket-core_4.11.xml b/src/main/resources/update/gitbucket-core_4.11.xml new file mode 100644 index 000000000..24f1f430b --- /dev/null +++ b/src/main/resources/update/gitbucket-core_4.11.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala index 4b9c486c3..dd8665d55 100644 --- a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala +++ b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala @@ -28,5 +28,8 @@ object GitBucketCoreModule extends Module("gitbucket-core", new Version("4.9.0", new LiquibaseMigration("update/gitbucket-core_4.9.xml") ), - new Version("4.10.0") + new Version("4.10.0"), + new Version("4.11.0", + new LiquibaseMigration("update/gitbucket-core_4.11.xml") + ) ) diff --git a/src/main/scala/gitbucket/core/model/DeployKey.scala b/src/main/scala/gitbucket/core/model/DeployKey.scala new file mode 100644 index 000000000..829f25624 --- /dev/null +++ b/src/main/scala/gitbucket/core/model/DeployKey.scala @@ -0,0 +1,27 @@ +package gitbucket.core.model + +trait DeployKeyComponent { self: Profile => + import profile.api._ + + lazy val DeployKeys = TableQuery[DeployKeys] + + class DeployKeys(tag: Tag) extends Table[DeployKey](tag, "DEPLOY_KEY") { + val userName = column[String]("USER_NAME") + val repositoryName = column[String]("REPOSITORY_NAME") + val deployKeyId = column[Int]("DEPLOY_KEY_ID", O AutoInc) + val title = column[String]("TITLE") + val publicKey = column[String]("PUBLIC_KEY") + def * = (userName, repositoryName, deployKeyId, title, publicKey) <> (DeployKey.tupled, DeployKey.unapply) + + def byPrimaryKey(userName: String, repositoryName: String, deployKeyId: Int) = + (this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind) + } +} + +case class DeployKey( + userName: String, + repositoryName: String, + deployKeyId: Int = 0, + title: String, + publicKey: String +) diff --git a/src/main/scala/gitbucket/core/model/Profile.scala b/src/main/scala/gitbucket/core/model/Profile.scala index ad01a4c34..332e7ea30 100644 --- a/src/main/scala/gitbucket/core/model/Profile.scala +++ b/src/main/scala/gitbucket/core/model/Profile.scala @@ -54,5 +54,6 @@ trait CoreProfile extends ProfileProvider with Profile with WebHookComponent with WebHookEventComponent with ProtectedBranchComponent + with DeployKeyComponent object Profile extends CoreProfile