diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-10-11 06:40:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 18:40:03 -0400 |
commit | c5c88f2f18d99a188357e0bcb837f94c9c41e79a (patch) | |
tree | ccdd155112a7ebedc93f0eb0310db860fd38b2d2 /models/migrations | |
parent | ff9a8a22312a653702342ce0a4073ae8fde2b1d4 (diff) | |
download | gitea-c5c88f2f18d99a188357e0bcb837f94c9c41e79a.tar.gz gitea-c5c88f2f18d99a188357e0bcb837f94c9c41e79a.zip |
Save and view issue/comment content history (#16909)
* issue content history
* Use timeutil.TimeStampNow() for content history time instead of issue/comment.UpdatedUnix (which are not updated in time)
* i18n for frontend
* refactor
* clean up
* fix refactor
* re-format
* temp refactor
* follow db refactor
* rename IssueContentHistory to ContentHistory, remove empty model tags
* fix html
* use avatar refactor to generate avatar url
* add unit test, keep at most 20 history revisions.
* re-format
* syntax nit
* Add issue content history table
* Update models/migrations/v197.go
Co-authored-by: 6543 <6543@obermui.de>
* fix merge
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v198.go | 33 |
2 files changed, 35 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 6f6296dabf..ef0c071417 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -348,6 +348,8 @@ var migrations = []Migration{ NewMigration("Add Color to ProjectBoard table", addColorColToProjectBoard), // v197 -> v198 NewMigration("Add renamed_branch table", addRenamedBranchTable), + // v198 -> v199 + NewMigration("Add issue content history table", addTableIssueContentHistory), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v198.go b/models/migrations/v198.go new file mode 100644 index 0000000000..e3c31460a9 --- /dev/null +++ b/models/migrations/v198.go @@ -0,0 +1,33 @@ +// 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 ( + "fmt" + + "code.gitea.io/gitea/modules/timeutil" + + "xorm.io/xorm" +) + +func addTableIssueContentHistory(x *xorm.Engine) error { + type IssueContentHistory struct { + ID int64 `xorm:"pk autoincr"` + PosterID int64 + IssueID int64 `xorm:"INDEX"` + CommentID int64 `xorm:"INDEX"` + EditedUnix timeutil.TimeStamp `xorm:"INDEX"` + ContentText string `xorm:"LONGTEXT"` + IsFirstCreated bool + IsDeleted bool + } + + sess := x.NewSession() + defer sess.Close() + if err := sess.Sync2(new(IssueContentHistory)); err != nil { + return fmt.Errorf("Sync2: %v", err) + } + return sess.Commit() +} |