Browse Source

Add field IsAllRepositories to team

pull/6791/head
Nicolas Gourdon 6 years ago
parent
commit
0b8e90e39b
  1. 2
      models/migrations/migrations.go
  2. 25
      models/migrations/v85.go
  3. 1
      models/org.go
  4. 1
      models/org_team.go

2
models/migrations/migrations.go

@ -223,6 +223,8 @@ var migrations = []Migration{
NewMigration("add uploader id for table attachment", addUploaderIDForAttachment), NewMigration("add uploader id for table attachment", addUploaderIDForAttachment),
// v84 -> v85 // v84 -> v85
NewMigration("add table to store original imported gpg keys", addGPGKeyImport), NewMigration("add table to store original imported gpg keys", addGPGKeyImport),
// v85 -> v86
NewMigration("add is_all_repositories to teams", addTeamIsAllRepositories),
} }
// Migrate database to current version // Migrate database to current version

25
models/migrations/v85.go

@ -0,0 +1,25 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package migrations
import (
"github.com/go-xorm/xorm"
)
func addTeamIsAllRepositories(x *xorm.Engine) error {
type Team struct {
ID int64 `xorm:"pk autoincr"`
IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
}
if err := x.Sync2(new(Team)); err != nil {
return err
}
_, err := x.Exec("UPDATE team SET is_all_repositories = ? WHERE name=?",
true, "Owners")
return err
}

1
models/org.go

@ -156,6 +156,7 @@ func CreateOrganization(org, owner *User) (err error) {
Name: ownerTeamName, Name: ownerTeamName,
Authorize: AccessModeOwner, Authorize: AccessModeOwner,
NumMembers: 1, NumMembers: 1,
IsAllRepositories: true,
} }
if _, err = sess.Insert(t); err != nil { if _, err = sess.Insert(t); err != nil {
return fmt.Errorf("insert owner team: %v", err) return fmt.Errorf("insert owner team: %v", err)

1
models/org_team.go

@ -32,6 +32,7 @@ type Team struct {
NumRepos int NumRepos int
NumMembers int NumMembers int
Units []*TeamUnit `xorm:"-"` Units []*TeamUnit `xorm:"-"`
IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
} }
// ColorFormat provides a basic color format for a Team // ColorFormat provides a basic color format for a Team

Loading…
Cancel
Save