Add field IsAllRepositories to team
This commit is contained in:
parent
d29d97d91c
commit
0b8e90e39b
4 changed files with 45 additions and 16 deletions
|
@ -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
Normal file
25
models/migrations/v85.go
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -151,11 +151,12 @@ func CreateOrganization(org, owner *User) (err error) {
|
||||||
|
|
||||||
// Create default owner team.
|
// Create default owner team.
|
||||||
t := &Team{
|
t := &Team{
|
||||||
OrgID: org.ID,
|
OrgID: org.ID,
|
||||||
LowerName: strings.ToLower(ownerTeamName),
|
LowerName: strings.ToLower(ownerTeamName),
|
||||||
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)
|
||||||
|
|
|
@ -21,17 +21,18 @@ const ownerTeamName = "Owners"
|
||||||
|
|
||||||
// Team represents a organization team.
|
// Team represents a organization team.
|
||||||
type Team struct {
|
type Team struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
OrgID int64 `xorm:"INDEX"`
|
OrgID int64 `xorm:"INDEX"`
|
||||||
LowerName string
|
LowerName string
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
Authorize AccessMode
|
Authorize AccessMode
|
||||||
Repos []*Repository `xorm:"-"`
|
Repos []*Repository `xorm:"-"`
|
||||||
Members []*User `xorm:"-"`
|
Members []*User `xorm:"-"`
|
||||||
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…
Reference in a new issue