summaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-10-28 19:05:39 +0800
committerGitHub <noreply@github.com>2022-10-28 13:05:39 +0200
commitf337c32e868381c6d2d948221aca0c59f8420c13 (patch)
tree9f86e2a347d13a32abc7e1b1e375f7e47787d58f /models/migrations
parente09025fdce7387a182424af35e63a335297fdc46 (diff)
downloadgitea-f337c32e868381c6d2d948221aca0c59f8420c13.tar.gz
gitea-f337c32e868381c6d2d948221aca0c59f8420c13.zip
Add index for hook_task table (#21545)
Since `hook_id` and `uuid` will become a search condition column. It's better to add some index for them.
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v231.go19
2 files changed, 21 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index f1f943a2c2..31b88a7981 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -423,6 +423,8 @@ var migrations = []Migration{
NewMigration("Update counts of all open milestones", updateOpenMilestoneCounts),
// v230 -> v231
NewMigration("Add ConfidentialClient column (default true) to OAuth2Application table", addConfidentialClientColumnToOAuth2ApplicationTable),
+ // v231 -> v232
+ NewMigration("Add index for hook_task", addIndexForHookTask),
}
// GetCurrentDBVersion returns the current db version
diff --git a/models/migrations/v231.go b/models/migrations/v231.go
new file mode 100644
index 0000000000..34dc72294a
--- /dev/null
+++ b/models/migrations/v231.go
@@ -0,0 +1,19 @@
+// 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 (
+ "xorm.io/xorm"
+)
+
+func addIndexForHookTask(x *xorm.Engine) error {
+ type HookTask struct {
+ ID int64 `xorm:"pk autoincr"`
+ HookID int64 `xorm:"index"`
+ UUID string `xorm:"unique"`
+ }
+
+ return x.Sync(new(HookTask))
+}