diff options
author | Lauris BH <lauris@nix.lv> | 2018-02-19 04:39:26 +0200 |
---|---|---|
committer | Bo-Yi Wu <appleboy.tw@gmail.com> | 2018-02-19 10:39:26 +0800 |
commit | 58893384e848b54687c21d6d2ca38b70b3036ae2 (patch) | |
tree | 343c231b40e378ccd089fc7796401f1459fdc1a2 /models/migrations | |
parent | fb2c176491ebc0f18e6ef25038ca84db561539e2 (diff) | |
download | gitea-58893384e848b54687c21d6d2ca38b70b3036ae2.tar.gz gitea-58893384e848b54687c21d6d2ca38b70b3036ae2.zip |
Add issue closed time column to fix activity closed issues list (#3537)
Signed-off-by: Lauris Bukšis-Haberkorns <lauris@nix.lv>
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v57.go | 30 |
2 files changed, 32 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index d79d403712..dfaef2c78d 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -166,6 +166,8 @@ var migrations = []Migration{ NewMigration("add writable deploy keys", addModeToDeploKeys), // v56 -> v57 NewMigration("remove is_owner, num_teams columns from org_user", removeIsOwnerColumnFromOrgUser), + // v57 -> v58 + NewMigration("add closed_unix column for issues", addIssueClosedTime), } // Migrate database to current version diff --git a/models/migrations/v57.go b/models/migrations/v57.go new file mode 100644 index 0000000000..3a79a5cca7 --- /dev/null +++ b/models/migrations/v57.go @@ -0,0 +1,30 @@ +// Copyright 2017 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" + + "code.gitea.io/gitea/modules/util" + + "github.com/go-xorm/xorm" +) + +func addIssueClosedTime(x *xorm.Engine) error { + // Issue see models/issue.go + type Issue struct { + ClosedUnix util.TimeStamp `xorm:"INDEX"` + } + + if err := x.Sync2(new(Issue)); err != nil { + return fmt.Errorf("Sync2: %v", err) + } + + if _, err := x.Exec("UPDATE `issue` SET `closed_unix` = `updated_unix` WHERE `is_closed` = ?", true); err != nil { + return err + } + + return nil +} |