forked from fabric8-services/fabric8-wit
/
comment_revision.go
49 lines (42 loc) · 1.44 KB
/
comment_revision.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package comment
import (
"time"
uuid "github.com/satori/go.uuid"
)
// RevisionType defines the type of revision for a comment
type RevisionType int
const (
_ RevisionType = iota // ignore first value by assigning to blank identifier
// RevisionTypeCreate a comment creation
RevisionTypeCreate // 1
// RevisionTypeDelete a comment deletion
RevisionTypeDelete // 2
_ // ignore 3rd value
// RevisionTypeUpdate a comment update
RevisionTypeUpdate // 4
)
// Revision represents a version of a comment
type Revision struct {
ID uuid.UUID `gorm:"primary_key"`
// the timestamp of the modification
Time time.Time `gorm:"column:revision_time"`
// the type of modification
Type RevisionType `gorm:"column:revision_type"`
// the identity of author of the comment modification
ModifierIdentity uuid.UUID `sql:"type:uuid" gorm:"column:modifier_id"`
// the id of the comment that changed
CommentID uuid.UUID `gorm:"column:comment_id"`
// the id of the parent of the comment that changed
CommentParentID uuid.UUID `gorm:"column:comment_parent_id"`
// the body of the comment (nil when comment was deleted)
CommentBody *string `gorm:"column:comment_body"`
// the markup used to input the comment body (nil when comment was deleted)
CommentMarkup *string `gorm:"column:comment_markup"`
}
const (
revisionTableName = "comment_revisions"
)
// TableName implements gorm.tabler
func (w Revision) TableName() string {
return revisionTableName
}