summaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2021-10-09 01:03:04 +0800
committerGitHub <noreply@github.com>2021-10-08 19:03:04 +0200
commitbb393596689ee7c33ecb041806ae2c9e8dc5dfab (patch)
treec6b71f73e53d5d5c1bb1da9e47e917f23538cd3f /models/migrations
parent56d79301b9f212e7801cbced1475238cc61c0748 (diff)
downloadgitea-bb393596689ee7c33ecb041806ae2c9e8dc5dfab.tar.gz
gitea-bb393596689ee7c33ecb041806ae2c9e8dc5dfab.zip
Add a simple way to rename branch like gh (#15870)
- Update default branch if needed - Update protected branch if needed - Update all not merged pull request base branch name - Rename git branch - Record this rename work and auto redirect for old branch on ui Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v197.go20
2 files changed, 22 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 33b094e48c..6f6296dabf 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -346,6 +346,8 @@ var migrations = []Migration{
NewMigration("Add table commit_status_index", addTableCommitStatusIndex),
// v196 -> v197
NewMigration("Add Color to ProjectBoard table", addColorColToProjectBoard),
+ // v197 -> v198
+ NewMigration("Add renamed_branch table", addRenamedBranchTable),
}
// GetCurrentDBVersion returns the current db version
diff --git a/models/migrations/v197.go b/models/migrations/v197.go
new file mode 100644
index 0000000000..3517896a23
--- /dev/null
+++ b/models/migrations/v197.go
@@ -0,0 +1,20 @@
+// Copyright 2021 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 (
+ "xorm.io/xorm"
+)
+
+func addRenamedBranchTable(x *xorm.Engine) error {
+ type RenamedBranch struct {
+ ID int64 `xorm:"pk autoincr"`
+ RepoID int64 `xorm:"INDEX NOT NULL"`
+ From string
+ To string
+ CreatedUnix int64 `xorm:"created"`
+ }
+ return x.Sync2(new(RenamedBranch))
+}