Skip to content

Commit 75c2752

Browse files
committed
Use own type (smallint on DB) and iota instead of VARCHAR(1)
1 parent b19ec55 commit 75c2752

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

models/notification.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@ import (
44
"time"
55
)
66

7+
type (
8+
NotificationStatus uint8
9+
NotificationSource uint8
10+
)
11+
712
const (
8-
NotificationStatusUnread = "U"
9-
NotificationStatusRead = "R"
13+
NotificationStatusUnread NotificationStatus = iota + 1
14+
NotificationStatusRead
15+
)
1016

11-
NotificationSourceIssue = "I"
12-
NotificationSourcePullRequest = "P"
13-
NotificationSourceCommit = "C"
17+
const (
18+
NotificationSourceIssue NotificationSource = iota + 1
19+
NotificationSourcePullRequest
20+
NotificationSourceCommit
1421
)
1522

1623
type Notification struct {
1724
ID int64 `xorm:"pk autoincr"`
1825
UserID int64 `xorm:"INDEX NOT NULL"`
1926
RepoID int64 `xorm:"INDEX NOT NULL"`
2027

21-
Status string `xorm:"VARCHAR(1) INDEX NOT NULL"`
22-
Source string `xorm:"VARCHAR(1) INDEX NOT NULL"`
28+
Status NotificationStatus `xorm:"SMALLINT INDEX NOT NULL"`
29+
Source NotificationSource `xorm:"SMALLINT INDEX NOT NULL"`
2330

2431
IssueID int64 `xorm:"INDEX NOT NULL"`
2532
PullID int64 `xorm:"INDEX"`

0 commit comments

Comments
 (0)