mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
Fix services to use shortcut method for primary key and foreign keys.
This commit is contained in:
@@ -31,4 +31,14 @@ protected[model] trait LabelTemplate extends BasicTemplate { self: Table[_] =>
|
||||
|
||||
def byLabel(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) =
|
||||
byRepository(userName, repositoryName) && (this.labelId is labelId)
|
||||
}
|
||||
|
||||
protected[model] trait MilestoneTemplate extends BasicTemplate { self: Table[_] =>
|
||||
def milestoneId = column[Int]("MILESTONE_ID")
|
||||
|
||||
def byMilestone(owner: String, repository: String, milestoneId: Int) =
|
||||
byRepository(owner, repository) && (this.milestoneId is milestoneId.bind)
|
||||
|
||||
def byMilestone(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) =
|
||||
byRepository(userName, repositoryName) && (this.milestoneId is milestoneId)
|
||||
}
|
||||
@@ -6,7 +6,8 @@ object Collaborators extends Table[Collaborator]("COLLABORATOR") with BasicTempl
|
||||
def collaboratorName = column[String]("COLLABORATOR_NAME")
|
||||
def * = userName ~ repositoryName ~ collaboratorName <> (Collaborator, Collaborator.unapply _)
|
||||
|
||||
def byPrimaryKey = byRepository _
|
||||
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
||||
byRepository(owner, repository) && (collaboratorName is collaborator.bind)
|
||||
}
|
||||
|
||||
case class Collaborator(
|
||||
|
||||
@@ -7,9 +7,8 @@ object IssueId extends Table[(String, String, Int)]("ISSUE_ID") with IssueTempla
|
||||
def byPrimaryKey = byRepository _
|
||||
}
|
||||
|
||||
object Issues extends Table[Issue]("ISSUE") with IssueTemplate with Functions {
|
||||
object Issues extends Table[Issue]("ISSUE") with IssueTemplate with MilestoneTemplate with Functions {
|
||||
def openedUserName = column[String]("OPENED_USER_NAME")
|
||||
def milestoneId = column[Int]("MILESTONE_ID")
|
||||
def assignedUserName = column[String]("ASSIGNED_USER_NAME")
|
||||
def title = column[String]("TITLE")
|
||||
def content = column[String]("CONTENT")
|
||||
|
||||
@@ -2,8 +2,7 @@ package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
|
||||
object Milestones extends Table[Milestone]("MILESTONE") with BasicTemplate with Functions {
|
||||
def milestoneId = column[Int]("MILESTONE_ID", O AutoInc)
|
||||
object Milestones extends Table[Milestone]("MILESTONE") with MilestoneTemplate with Functions {
|
||||
def title = column[String]("TITLE")
|
||||
def description = column[String]("DESCRIPTION")
|
||||
def dueDate = column[java.util.Date]("DUE_DATE")
|
||||
@@ -11,9 +10,7 @@ object Milestones extends Table[Milestone]("MILESTONE") with BasicTemplate with
|
||||
def * = userName ~ repositoryName ~ milestoneId ~ title ~ description.? ~ dueDate.? ~ closedDate.? <> (Milestone, Milestone.unapply _)
|
||||
|
||||
def autoInc = userName ~ repositoryName ~ title ~ description.? ~ dueDate.? ~ closedDate.? returning milestoneId
|
||||
// TODO create a template?
|
||||
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) =
|
||||
byRepository(owner, repository) && (this.milestoneId is milestoneId.bind)
|
||||
def byPrimaryKey = byMilestone _
|
||||
}
|
||||
|
||||
case class Milestone(
|
||||
|
||||
Reference in New Issue
Block a user