Manager: let Gorm create an index on Task.LastTouchedAt

It's used in timeout queries, and there could be tens or hundreds of
thousands of tasks in the database.
This commit is contained in:
Sybren A. Stüvel 2022-06-13 12:30:11 +02:00
parent c3525c3b1a
commit 67562856d3

View File

@ -46,7 +46,7 @@ type Task struct {
// Which worker is/was working on this.
WorkerID *uint
Worker *Worker `gorm:"foreignkey:WorkerID;references:ID;constraint:OnDelete:CASCADE"`
LastTouchedAt time.Time // Should contain UTC timestamps.
LastTouchedAt time.Time `gorm:"index"` // Should contain UTC timestamps.
// Dependencies are tasks that need to be completed before this one can run.
Dependencies []*Task `gorm:"many2many:task_dependencies;constraint:OnDelete:CASCADE"`