package model import ( "time" "gorm.io/gorm" ) type StatusCode string const ( StatusOK StatusCode = "ok" // Means - response ok, service is alive StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched StatusUncheck StatusCode = "unchecked" // Means - no data ) type Status struct { ID int `gorm:"primary_key;auto_increment" json:"id"` ServiceID int `gorm:"one" json:"-"` Status StatusCode `gorm:"size:255;not null" json:"status"` Description *string `gorm:"size:255" json:"description"` CreatedAt time.Time `json:"createdAt"` } func (Status) TableName() string { return "statuses" } func (s *Status) BeforeCreate(*gorm.DB) error { s.CreatedAt = time.Now() return nil }