github.com/decred/politeia@v1.4.0/politeiawww/legacy/codetracker/github/database/cockroachdb/models.go (about) 1 // Copyright (c) 2020 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package cockroachdb 6 7 import ( 8 _ "github.com/jinzhu/gorm/dialects/postgres" 9 ) 10 11 // Version describes the version of a record or plugin that the database is 12 // currently using. 13 type Version struct { 14 ID string `gorm:"primary_key"` // Primary key 15 Version string `gorm:"not null"` // Version 16 Timestamp int64 `gorm:"not null"` // UNIX timestamp of record creation 17 } 18 19 // TableName returns the table name of the versions table. 20 func (Version) TableName() string { 21 return tableNameVersions 22 } 23 24 // PullRequest table has all of the information for a given PullRequest, 25 // this also includes its commits and reviews. 26 type PullRequest struct { 27 ID string `gorm:"primary_key"` 28 Repo string `gorm:"not null"` 29 Organization string `gorm:"not null"` 30 URL string `gorm:"not null"` 31 Number int `gorm:"not null"` 32 Author string `gorm:"not null"` 33 UpdatedAt int64 `gorm:"not null"` 34 ClosedAt int64 `gorm:"not null"` 35 MergedAt int64 `gorm:"not null"` 36 Merged bool `gorm:"not null"` 37 State string `gorm:"not null"` 38 Additions int `gorm:"not null"` 39 Deletions int `gorm:"not null"` 40 MergedBy string `gorm:"not null"` 41 } 42 43 // TableName returns the table name of the pull requests table. 44 func (PullRequest) TableName() string { 45 return tableNamePullRequest 46 } 47 48 // PullRequestReview contains all of the information about reviews of a given 49 // pull request. 50 type PullRequestReview struct { 51 PullRequestURL string `gorm:"not null"` 52 ID int64 `gorm:"primary_key"` 53 Author string `gorm:"not null"` 54 State string `gorm:"not null"` 55 SubmittedAt int64 `gorm:"not null"` 56 CommitID string `gorm:"not null"` 57 Repo string `gorm:"not null"` 58 Number int `gorm:"not null"` 59 } 60 61 // TableName returns the table name of the pull requests review table. 62 func (PullRequestReview) TableName() string { 63 return tableNameReviews 64 } 65 66 type Commit struct { 67 SHA string `gorm:"primary_key"` 68 Repo string `gorm:"repo"` 69 Organization string `gorm:"organization"` 70 Date int64 `gorm:"not null"` 71 Author string `gorm:"not null"` 72 Committer string `gorm:"not null"` 73 Message string `gorm:"not null"` 74 URL string `gorm:"not null"` 75 ParentSHA string `gorm:"not null"` 76 ParentURL string `gorm:"not null"` 77 Additions int `gorm:"not null"` 78 Deletions int `gorm:"not null"` 79 } 80 81 // TableName returns the table name of the commits table. 82 func (Commit) TableName() string { 83 return tableNameCommits 84 }