From 9c267a071af97270ba07baf5c8f69e12fb521a15 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 19 Mar 2017 16:54:12 -0300 Subject: [PATCH] Create issue_watch table --- models/issue_watch.go | 20 ++++++++++++++++++++ models/models.go | 1 + 2 files changed, 21 insertions(+) create mode 100644 models/issue_watch.go diff --git a/models/issue_watch.go b/models/issue_watch.go new file mode 100644 index 000000000..96e080136 --- /dev/null +++ b/models/issue_watch.go @@ -0,0 +1,20 @@ +package models + +import ( + "time" +) + +// IssueWatch is connection request for receiving issue notification. +type IssueWatch struct { + ID int64 `xorm:"pk autoincr"` + UserID int64 `xorm:"UNIQUE(watch) NOT NULL"` + IssueID int64 `xorm:"UNIQUE(watch) NOT NULL"` + IsWatching bool `xorm:"NOT NULL"` + Created time.Time `xorm:"-"` + CreatedUnix int64 `xorm:"NOT NULL"` +} + +// BeforeInsert is invoked from XORM before inserting an object of this type. +func (iw *IssueWatch) BeforeInsert() { + iw.CreatedUnix = time.Now().Unix() +} diff --git a/models/models.go b/models/models.go index 2ae6e355f..a1332ac23 100644 --- a/models/models.go +++ b/models/models.go @@ -117,6 +117,7 @@ func init() { new(ExternalLoginUser), new(ProtectedBranch), new(UserOpenID), + new(IssueWatch), ) gonicNames := []string{"SSL", "UID"}