Browse Source

models: remove redundant tags for primary keys

pull/4527/head
Unknwon 8 years ago
parent
commit
ce6e8ed8fe
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      models/access.go
  2. 4
      models/admin.go
  3. 2
      models/attachment.go
  4. 2
      models/comment.go
  5. 6
      models/issue.go
  6. 4
      models/issue_label.go
  7. 8
      models/login_source.go
  8. 2
      models/milestone.go
  9. 2
      models/mirror.go
  10. 2
      models/org.go
  11. 4
      models/org_team.go
  12. 2
      models/pull.go
  13. 2
      models/release.go
  14. 6
      models/repo.go
  15. 2
      models/repo_collaboration.go
  16. 2
      models/repo_editor.go
  17. 4
      models/ssh_key.go
  18. 2
      models/token.go
  19. 4
      models/user.go
  20. 2
      models/user_mail.go
  21. 4
      models/webhook.go
  22. 50
      pkg/bindata/bindata.go

2
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

4
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:"-"`

2
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

2
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:"-"`

6
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"`

4
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)"`
}

8
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)
}

2
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"`

2
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.

2
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

4
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)"`

2
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

2
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

6
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)"`
}

2
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"`

2
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
}

4
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

2
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)"`

4
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)"`
}

2
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

4
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

50
pkg/bindata/bindata.go

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save