Skip to content

Commit ac18821

Browse files
authored
Add DB indexes for key fields (#135)
1 parent f5d756b commit ac18821

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

internal/models/label.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type Label struct {
66
ID int `json:"id" gorm:"primary_key"`
77
Name string `json:"name" gorm:"column:name;not null"`
88
Color string `json:"color" gorm:"type:varchar(7);column:color;not null"`
9-
CreatedBy int `json:"created_by" gorm:"column:created_by;not null"`
9+
CreatedBy int `json:"created_by" gorm:"column:created_by;not null;index:idx_labels_created_by"`
1010
CreatedAt time.Time `json:"-" gorm:"column:created_at;default:CURRENT_TIMESTAMP"`
1111
UpdatedAt *time.Time `json:"-" gorm:"column:updated_at;default:NULL;autoUpdateTime"`
1212

internal/models/notification.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66

77
type Notification struct {
88
ID int `json:"id" gorm:"primaryKey"`
9-
TaskID int `json:"task_id" gorm:"column:task_id;not null"`
10-
UserID int `json:"user_id" gorm:"column:user_id;not null"`
9+
TaskID int `json:"task_id" gorm:"column:task_id;not null;index:idx_notifications_task_id"`
10+
UserID int `json:"user_id" gorm:"column:user_id;not null;index:idx_notifications_user_id"`
1111
Text string `json:"text" gorm:"column:text;not null"`
1212
IsSent bool `json:"is_sent" gorm:"column:is_sent;index;default:false"`
1313
ScheduledFor time.Time `json:"scheduled_for" gorm:"column:scheduled_for;not null;index"`

internal/models/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Task struct {
1111
NextDueDate *time.Time `json:"next_due_date" gorm:"column:next_due_date;index"`
1212
EndDate *time.Time `json:"end_date" gorm:"column:end_date;default:NULL"`
1313
IsRolling bool `json:"is_rolling" gorm:"column:is_rolling;default:false"`
14-
CreatedBy int `json:"-" gorm:"column:created_by;not null"`
14+
CreatedBy int `json:"-" gorm:"column:created_by;not null;index:idx_tasks_created_by"`
1515
IsActive bool `json:"-" gorm:"column:is_active;default:true"`
1616
Notification NotificationTriggerOptions `json:"notification" gorm:"embedded;embeddedPrefix:notification_"`
1717
CreatedAt time.Time `json:"-" gorm:"column:created_at;default:CURRENT_TIMESTAMP"`

0 commit comments

Comments
 (0)