diff options
author | Unknwon <u@gogs.io> | 2016-08-26 14:07:21 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-26 14:07:21 -0700 |
commit | bb359a74f124c759a8de1afbf224b658b57760b7 (patch) | |
tree | a2bf45fa59e7c5079762996e43155692af2d82ce /models | |
parent | 6b98d58906e4df063a2af59f97bd74c1c4cc1c84 (diff) | |
download | gitea-bb359a74f124c759a8de1afbf224b658b57760b7.tar.gz gitea-bb359a74f124c759a8de1afbf224b658b57760b7.zip |
migrations: set comment updated as created
Diffstat (limited to 'models')
-rw-r--r-- | models/issue_comment.go | 2 | ||||
-rw-r--r-- | models/migrations/migrations.go | 3 | ||||
-rw-r--r-- | models/migrations/v14.go | 18 |
3 files changed, 22 insertions, 1 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go index c914e0a56f..ccfa765f92 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -358,7 +358,7 @@ func getCommentsByIssueIDSince(e Engine, issueID, since int64) ([]*Comment, erro comments := make([]*Comment, 0, 10) sess := e.Where("issue_id = ?", issueID).Asc("created_unix") if since > 0 { - sess.And("created_unix >= ?", since) + sess.And("updated_unix >= ?", since) } return comments, sess.Find(&comments) } diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 6a1fb2f6df..5f18960769 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -68,6 +68,9 @@ var migrations = []Migration{ NewMigration("generate rands and salt for organizations", generateOrgRandsAndSalt), // V10 -> V11:v0.8.5 NewMigration("convert date to unix timestamp", convertDateToUnix), // V11 -> V12:v0.9.2 NewMigration("convert LDAP UseSSL option to SecurityProtocol", ldapUseSSLToSecurityProtocol), // V12 -> V13:v0.9.37 + + // v13 -> v14:v0.9.87 + NewMigration("set comment updated with created", setCommentUpdatedWithCreated), } // Migrate database to current version diff --git a/models/migrations/v14.go b/models/migrations/v14.go new file mode 100644 index 0000000000..16c497e7e2 --- /dev/null +++ b/models/migrations/v14.go @@ -0,0 +1,18 @@ +// Copyright 2016 The Gogs 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" + + "github.com/go-xorm/xorm" +) + +func setCommentUpdatedWithCreated(x *xorm.Engine) error { + if _, err := x.Exec("UPDATE comment SET updated_unix = created_unix"); err != nil { + return fmt.Errorf("set update_unix: %v", err) + } + return nil +} |