diff --git a/src/main/scala/gitbucket/core/model/DeployKey.scala b/src/main/scala/gitbucket/core/model/DeployKey.scala index 4f34e45..71b80a2 100644 --- a/src/main/scala/gitbucket/core/model/DeployKey.scala +++ b/src/main/scala/gitbucket/core/model/DeployKey.scala @@ -1,13 +1,11 @@ package gitbucket.core.model -trait DeployKeyComponent { self: Profile => +trait DeployKeyComponent extends TemplateComponent { 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") + class DeployKeys(tag: Tag) extends Table[DeployKey](tag, "DEPLOY_KEY") with BasicTemplate { val deployKeyId = column[Int]("DEPLOY_KEY_ID", O AutoInc) val title = column[String]("TITLE") val publicKey = column[String]("PUBLIC_KEY") diff --git a/src/main/scala/gitbucket/core/service/RepositoryService.scala b/src/main/scala/gitbucket/core/service/RepositoryService.scala index 9b5a1bf..3640f1c 100644 --- a/src/main/scala/gitbucket/core/service/RepositoryService.scala +++ b/src/main/scala/gitbucket/core/service/RepositoryService.scala @@ -73,6 +73,7 @@ val collaborators = Collaborators .filter(_.byRepository(oldUserName, oldRepositoryName)).list val protectedBranches = ProtectedBranches .filter(_.byRepository(oldUserName, oldRepositoryName)).list val protectedBranchContexts = ProtectedBranchContexts.filter(_.byRepository(oldUserName, oldRepositoryName)).list + val deployKeys = DeployKeys .filter(_.byRepository(oldUserName, oldRepositoryName)).list Repositories.filter { t => (t.originUserName === oldUserName.bind) && (t.originRepositoryName === oldRepositoryName.bind) @@ -112,6 +113,7 @@ CommitStatuses .insertAll(commitStatuses.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) ProtectedBranches .insertAll(protectedBranches.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) ProtectedBranchContexts.insertAll(protectedBranchContexts.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) + DeployKeys .insertAll(deployKeys .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) // Update source repository of pull requests PullRequests.filter { t => @@ -126,11 +128,6 @@ userName = newUserName, repositoryName = newRepositoryName )) :_*) - IssueLabels.insertAll(issueLabels.map(x => x.copy( - labelId = newLabelMap(oldLabelMap(x.labelId)), - userName = newUserName, - repositoryName = newRepositoryName - )) :_*) // TODO Drop transfered owner from collaborators? Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*) @@ -168,6 +165,7 @@ Milestones .filter(_.byRepository(userName, repositoryName)).delete WebHooks .filter(_.byRepository(userName, repositoryName)).delete WebHookEvents .filter(_.byRepository(userName, repositoryName)).delete + DeployKeys .filter(_.byRepository(userName, repositoryName)).delete Repositories .filter(_.byRepository(userName, repositoryName)).delete // Update ORIGIN_USER_NAME and ORIGIN_REPOSITORY_NAME