diff --git a/src/main/scala/model/Collaborator.scala b/src/main/scala/model/Collaborator.scala index 0232365..7e8c3de 100644 --- a/src/main/scala/model/Collaborator.scala +++ b/src/main/scala/model/Collaborator.scala @@ -5,6 +5,8 @@ object Collaborators extends Table[Collaborator]("COLLABORATOR") with BasicTemplate { def collaboratorName = column[String]("COLLABORATOR_NAME") def * = userName ~ repositoryName ~ collaboratorName <> (Collaborator, Collaborator.unapply _) + + def byPrimaryKey = byRepository _ } case class Collaborator( diff --git a/src/main/scala/model/Issue.scala b/src/main/scala/model/Issue.scala index 402fce7..b9e63c2 100644 --- a/src/main/scala/model/Issue.scala +++ b/src/main/scala/model/Issue.scala @@ -4,6 +4,7 @@ object IssueId extends Table[(String, String, Int)]("ISSUE_ID") with IssueTemplate { def * = userName ~ repositoryName ~ issueId + def byPrimaryKey = byRepository _ } object Issues extends Table[Issue]("ISSUE") with IssueTemplate with Functions { @@ -16,6 +17,8 @@ def registeredDate = column[java.util.Date]("REGISTERED_DATE") def updatedDate = column[java.util.Date]("UPDATED_DATE") def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _) + + def byPrimaryKey = byIssue _ } case class Issue( diff --git a/src/main/scala/model/IssueComment.scala b/src/main/scala/model/IssueComment.scala index 38beae6..400d5c5 100644 --- a/src/main/scala/model/IssueComment.scala +++ b/src/main/scala/model/IssueComment.scala @@ -11,6 +11,7 @@ def * = userName ~ repositoryName ~ issueId ~ commentId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate <> (IssueComment, IssueComment.unapply _) def autoInc = userName ~ repositoryName ~ issueId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate returning commentId + def byPrimaryKey(commentId: Int) = this.commentId is commentId.bind } case class IssueComment( diff --git a/src/main/scala/model/IssueLabels.scala b/src/main/scala/model/IssueLabels.scala index 16a7469..e26da33 100644 --- a/src/main/scala/model/IssueLabels.scala +++ b/src/main/scala/model/IssueLabels.scala @@ -4,6 +4,8 @@ object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") with IssueTemplate with LabelTemplate { def * = userName ~ repositoryName ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _) + def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) = + byIssue(owner, repository, issueId) && (this.labelId is labelId.bind) } case class IssueLabel( diff --git a/src/main/scala/model/Labels.scala b/src/main/scala/model/Labels.scala index 188af73..005e83b 100644 --- a/src/main/scala/model/Labels.scala +++ b/src/main/scala/model/Labels.scala @@ -8,6 +8,7 @@ def * = userName ~ repositoryName ~ labelId ~ labelName ~ color <> (Label, Label.unapply _) def ins = userName ~ repositoryName ~ labelName ~ color + def byPrimaryKey = byLabel _ } case class Label( diff --git a/src/main/scala/model/Milestone.scala b/src/main/scala/model/Milestone.scala index 334b014..ebb7d13 100644 --- a/src/main/scala/model/Milestone.scala +++ b/src/main/scala/model/Milestone.scala @@ -11,6 +11,9 @@ 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) } case class Milestone( diff --git a/src/main/scala/model/Repository.scala b/src/main/scala/model/Repository.scala index 0ef8a0a..79a42fb 100644 --- a/src/main/scala/model/Repository.scala +++ b/src/main/scala/model/Repository.scala @@ -10,6 +10,8 @@ def updatedDate = column[java.util.Date]("UPDATED_DATE") def lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE") def * = userName ~ repositoryName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _) + + def byPrimaryKey = byRepository _ } case class Repository(