aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/access.go2
-rw-r--r--models/admin.go4
-rw-r--r--models/attachment.go2
-rw-r--r--models/comment.go2
-rw-r--r--models/issue.go6
-rw-r--r--models/issue_label.go4
-rw-r--r--models/login_source.go8
-rw-r--r--models/milestone.go2
-rw-r--r--models/mirror.go2
-rw-r--r--models/org.go2
-rw-r--r--models/org_team.go4
-rw-r--r--models/pull.go2
-rw-r--r--models/release.go2
-rw-r--r--models/repo.go6
-rw-r--r--models/repo_collaboration.go2
-rw-r--r--models/repo_editor.go2
-rw-r--r--models/ssh_key.go4
-rw-r--r--models/token.go2
-rw-r--r--models/user.go4
-rw-r--r--models/user_mail.go2
-rw-r--r--models/webhook.go4
21 files changed, 34 insertions, 34 deletions
diff --git a/models/access.go b/models/access.go
index 0d3259de..54816c7b 100644
--- a/models/access.go
+++ b/models/access.go
@@ -53,7 +53,7 @@ func ParseAccessMode(permission string) AccessMode {
// that is not in this table is the real owner of a repository. In case of an organization
// repository, the members of the owners team are in this table.
type Access struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UserID int64 `xorm:"UNIQUE(s)"`
RepoID int64 `xorm:"UNIQUE(s)"`
Mode AccessMode
diff --git a/models/admin.go b/models/admin.go
index 8816786d..4daf80f6 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -15,8 +15,8 @@ import (
"github.com/go-xorm/xorm"
log "gopkg.in/clog.v1"
- "github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/setting"
+ "github.com/gogits/gogs/pkg/tool"
)
type NoticeType int
@@ -27,7 +27,7 @@ const (
// Notice represents a system notice for admin.
type Notice struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
Type NoticeType
Description string `xorm:"TEXT"`
Created time.Time `xorm:"-"`
diff --git a/models/attachment.go b/models/attachment.go
index 583cb10b..fb4ec88d 100644
--- a/models/attachment.go
+++ b/models/attachment.go
@@ -20,7 +20,7 @@ import (
// Attachment represent a attachment of issue/comment/release.
type Attachment struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UUID string `xorm:"uuid UNIQUE"`
IssueID int64 `xorm:"INDEX"`
CommentID int64
diff --git a/models/comment.go b/models/comment.go
index d18b14df..673ca780 100644
--- a/models/comment.go
+++ b/models/comment.go
@@ -49,7 +49,7 @@ const (
// Comment represents a comment in commit and issue page.
type Comment struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
Type CommentType
PosterID int64
Poster *User `xorm:"-"`
diff --git a/models/issue.go b/models/issue.go
index cf49f173..ea7f3d22 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -16,8 +16,8 @@ import (
api "github.com/gogits/go-gogs-client"
"github.com/gogits/gogs/models/errors"
- "github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/setting"
+ "github.com/gogits/gogs/pkg/tool"
)
var (
@@ -26,7 +26,7 @@ var (
// Issue represents an issue or pull request of repository.
type Issue struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64 `xorm:"INDEX UNIQUE(repo_index)"`
Repo *Repository `xorm:"-"`
Index int64 `xorm:"UNIQUE(repo_index)"` // Index in one repository.
@@ -1007,7 +1007,7 @@ func GetParticipantsByIssueID(issueID int64) ([]*User, error) {
// IssueUser represents an issue-user relation.
type IssueUser struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UID int64 `xorm:"INDEX"` // User ID.
IssueID int64
RepoID int64 `xorm:"INDEX"`
diff --git a/models/issue_label.go b/models/issue_label.go
index 1ce5df07..8c56a7fd 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -54,7 +54,7 @@ func GetLabelTemplateFile(name string) ([][2]string, error) {
// Label represents a label of repository for issues.
type Label struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64 `xorm:"INDEX"`
Name string
Color string `xorm:"VARCHAR(7)"`
@@ -213,7 +213,7 @@ func DeleteLabel(repoID, labelID int64) error {
// IssueLabel represetns an issue-lable relation.
type IssueLabel struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
IssueID int64 `xorm:"UNIQUE(s)"`
LabelID int64 `xorm:"UNIQUE(s)"`
}
diff --git a/models/login_source.go b/models/login_source.go
index 9da9ff94..12db7864 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -103,7 +103,7 @@ func (cfg *PAMConfig) ToDB() ([]byte, error) {
// LoginSource represents an external way for authorizing users.
type LoginSource struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
Type LoginType
Name string `xorm:"UNIQUE"`
IsActived bool `xorm:"NOT NULL DEFAULT false"`
@@ -327,16 +327,16 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
IsActive: true,
IsAdmin: isAdmin,
}
-
+
ok, err := IsUserExist(0, user.Name)
if err != nil {
return user, err
}
-
+
if ok {
return user, UpdateUser(user)
}
-
+
return user, CreateUser(user)
}
diff --git a/models/milestone.go b/models/milestone.go
index dbba0312..544ef826 100644
--- a/models/milestone.go
+++ b/models/milestone.go
@@ -18,7 +18,7 @@ import (
// Milestone represents a milestone of repository.
type Milestone struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64 `xorm:"INDEX"`
Name string
Content string `xorm:"TEXT"`
diff --git a/models/mirror.go b/models/mirror.go
index 778632b4..f48e8efa 100644
--- a/models/mirror.go
+++ b/models/mirror.go
@@ -27,7 +27,7 @@ var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
// Mirror represents mirror information of a repository.
type Mirror struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64
Repo *Repository `xorm:"-"`
Interval int // Hour.
diff --git a/models/org.go b/models/org.go
index 9bf57ad9..c93671cd 100644
--- a/models/org.go
+++ b/models/org.go
@@ -237,7 +237,7 @@ func DeleteOrganization(org *User) (err error) {
// OrgUser represents an organization-user relation.
type OrgUser struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
Uid int64 `xorm:"INDEX UNIQUE(s)"`
OrgID int64 `xorm:"INDEX UNIQUE(s)"`
IsPublic bool
diff --git a/models/org_team.go b/models/org_team.go
index a7fe3a33..1b23f3a3 100644
--- a/models/org_team.go
+++ b/models/org_team.go
@@ -16,7 +16,7 @@ const OWNER_TEAM = "Owners"
// Team represents a organization team.
type Team struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
OrgID int64 `xorm:"INDEX"`
LowerName string
Name string
@@ -406,7 +406,7 @@ func DeleteTeam(t *Team) error {
// TeamUser represents an team-user relation.
type TeamUser struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
OrgID int64 `xorm:"INDEX"`
TeamID int64 `xorm:"UNIQUE(s)"`
UID int64 `xorm:"UNIQUE(s)"`
diff --git a/models/pull.go b/models/pull.go
index cc94ee3e..b2a7b44c 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -43,7 +43,7 @@ const (
// PullRequest represents relation between pull request and repositories.
type PullRequest struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
Type PullRequestType
Status PullRequestStatus
diff --git a/models/release.go b/models/release.go
index 1d387fb4..0307ab69 100644
--- a/models/release.go
+++ b/models/release.go
@@ -22,7 +22,7 @@ import (
// Release represents a release of repository.
type Release struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64
Repo *Repository `xorm:"-"`
PublisherID int64
diff --git a/models/repo.go b/models/repo.go
index 808ef1a4..0aa6afda 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -141,7 +141,7 @@ func NewRepoContext() {
// Repository contains information of a repository.
type Repository struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
OwnerID int64 `xorm:"UNIQUE(s)"`
Owner *User `xorm:"-"`
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
@@ -2055,7 +2055,7 @@ func (repos MirrorRepositoryList) LoadAttributes() error {
// Watch is connection request for receiving repository notification.
type Watch struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UserID int64 `xorm:"UNIQUE(watch)"`
RepoID int64 `xorm:"UNIQUE(watch)"`
}
@@ -2161,7 +2161,7 @@ func NotifyWatchers(act *Action) error {
// \/ \/
type Star struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UID int64 `xorm:"UNIQUE(s)"`
RepoID int64 `xorm:"UNIQUE(s)"`
}
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index 24033409..c3135013 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -14,7 +14,7 @@ import (
// Collaboration represent the relation between an individual and a repository.
type Collaboration struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
UserID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
Mode AccessMode `xorm:"DEFAULT 2 NOT NULL"`
diff --git a/models/repo_editor.go b/models/repo_editor.go
index 3d01de6e..643cc382 100644
--- a/models/repo_editor.go
+++ b/models/repo_editor.go
@@ -307,7 +307,7 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
// Upload represent a uploaded file to a repo to be deleted when moved
type Upload struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UUID string `xorm:"uuid UNIQUE"`
Name string
}
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 18719390..814f0db0 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -43,7 +43,7 @@ const (
// PublicKey represents a user or deploy SSH public key.
type PublicKey struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
OwnerID int64 `xorm:"INDEX NOT NULL"`
Name string `xorm:"NOT NULL"`
Fingerprint string `xorm:"NOT NULL"`
@@ -566,7 +566,7 @@ func RewriteAllPublicKeys() error {
// DeployKey represents deploy key information and its relation with repository.
type DeployKey struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
KeyID int64 `xorm:"UNIQUE(s) INDEX"`
RepoID int64 `xorm:"UNIQUE(s) INDEX"`
Name string
diff --git a/models/token.go b/models/token.go
index 9a69a601..940d76f4 100644
--- a/models/token.go
+++ b/models/token.go
@@ -15,7 +15,7 @@ import (
// AccessToken represents a personal access token.
type AccessToken struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UID int64 `xorm:"INDEX"`
Name string
Sha1 string `xorm:"UNIQUE VARCHAR(40)"`
diff --git a/models/user.go b/models/user.go
index b6e187f7..95462a9e 100644
--- a/models/user.go
+++ b/models/user.go
@@ -44,7 +44,7 @@ const (
// User represents the object of individual and member of organization.
type User struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
LowerName string `xorm:"UNIQUE NOT NULL"`
Name string `xorm:"UNIQUE NOT NULL"`
FullName string
@@ -1087,7 +1087,7 @@ func SearchUserByName(opts *SearchUserOptions) (users []*User, _ int64, _ error)
// Follow represents relations of user and his/her followers.
type Follow struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UserID int64 `xorm:"UNIQUE(follow)"`
FollowID int64 `xorm:"UNIQUE(follow)"`
}
diff --git a/models/user_mail.go b/models/user_mail.go
index 7c1cdd16..e9169d71 100644
--- a/models/user_mail.go
+++ b/models/user_mail.go
@@ -14,7 +14,7 @@ import (
// EmailAdresses is the list of all email addresses of a user. Can contain the
// primary email address, but is not obligatory.
type EmailAddress struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
UID int64 `xorm:"INDEX NOT NULL"`
Email string `xorm:"UNIQUE NOT NULL"`
IsActivated bool
diff --git a/models/webhook.go b/models/webhook.go
index e4e77490..9a5fece3 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -92,7 +92,7 @@ const (
// Webhook represents a web hook object.
type Webhook struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64
OrgID int64
URL string `xorm:"url TEXT"`
@@ -407,7 +407,7 @@ type HookResponse struct {
// HookTask represents a hook task.
type HookTask struct {
- ID int64 `xorm:"pk autoincr"`
+ ID int64
RepoID int64 `xorm:"INDEX"`
HookID int64
UUID string