aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-01-05 11:37:00 +0800
committerGitHub <noreply@github.com>2022-01-05 11:37:00 +0800
commit8760af752abd94f050c6014c8cfa3cb6a6c854b7 (patch)
tree2b2afeebc46348eec296a6cd9d086f84a94cf664 /models/migrations
parent12ad6dd0e385fea277f5344d52865c9599232c22 (diff)
downloadgitea-8760af752abd94f050c6014c8cfa3cb6a6c854b7.tar.gz
gitea-8760af752abd94f050c6014c8cfa3cb6a6c854b7.zip
Team permission allow different unit has different permission (#17811)
* Team permission allow different unit has different permission * Finish the interface and the logic * Fix lint * Fix translation * align center for table cell content * Fix fixture * merge * Fix test * Add deprecated * Improve code * Add tooltip * Fix swagger * Fix newline * Fix tests * Fix tests * Fix test * Fix test * Max permission of external wiki and issues should be read * Move team units with limited max level below units table * Update label and column names * Some improvements * Fix lint * Some improvements * Fix template variables * Add permission docs * improve doc * Fix fixture * Fix bug * Fix some bug * fix * gofumpt * Integration test for migration (#18124) integrations: basic test for Gitea {dump,restore}-repo This is a first step for integration testing of DumpRepository and RestoreRepository. It: runs a Gitea server, dumps a repo via DumpRepository to the filesystem, restores the repo via RestoreRepository from the filesystem, dumps the restored repository to the filesystem, compares the first and second dump and expects them to be identical The verification is trivial and the goal is to add more tests for each topic of the dump. Signed-off-by: Loïc Dachary <loic@dachary.org> * Team permission allow different unit has different permission * Finish the interface and the logic * Fix lint * Fix translation * align center for table cell content * Fix fixture * merge * Fix test * Add deprecated * Improve code * Add tooltip * Fix swagger * Fix newline * Fix tests * Fix tests * Fix test * Fix test * Max permission of external wiki and issues should be read * Move team units with limited max level below units table * Update label and column names * Some improvements * Fix lint * Some improvements * Fix template variables * Add permission docs * improve doc * Fix fixture * Fix bug * Fix some bug * Fix bug Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Aravinth Manivannan <realaravinth@batsense.net>
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/migrations.go3
-rw-r--r--models/migrations/v206.go29
2 files changed, 31 insertions, 1 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 4b720c3f02..9423e5c5f6 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -60,7 +60,6 @@ type Version struct {
// If you want to "retire" a migration, remove it from the top of the list and
// update minDBVersion accordingly
var migrations = []Migration{
-
// Gitea 1.5.0 ends at v69
// v70 -> v71
@@ -365,6 +364,8 @@ var migrations = []Migration{
NewMigration("Add key is verified to ssh key", addSSHKeyIsVerified),
// v205 -> v206
NewMigration("Migrate to higher varchar on user struct", migrateUserPasswordSalt),
+ // v206 -> v207
+ NewMigration("Add authorize column to team_unit table", addAuthorizeColForTeamUnit),
}
// GetCurrentDBVersion returns the current db version
diff --git a/models/migrations/v206.go b/models/migrations/v206.go
new file mode 100644
index 0000000000..c6a5dc811c
--- /dev/null
+++ b/models/migrations/v206.go
@@ -0,0 +1,29 @@
+// Copyright 2022 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 (
+ "fmt"
+
+ "xorm.io/xorm"
+)
+
+func addAuthorizeColForTeamUnit(x *xorm.Engine) error {
+ type TeamUnit struct {
+ ID int64 `xorm:"pk autoincr"`
+ OrgID int64 `xorm:"INDEX"`
+ TeamID int64 `xorm:"UNIQUE(s)"`
+ Type int `xorm:"UNIQUE(s)"`
+ AccessMode int
+ }
+
+ if err := x.Sync2(new(TeamUnit)); err != nil {
+ return fmt.Errorf("sync2: %v", err)
+ }
+
+ // migrate old permission
+ _, err := x.Exec("UPDATE team_unit SET access_mode = (SELECT authorize FROM team WHERE team.id = team_unit.team_id)")
+ return err
+}