zdravko/internal/models/models.go

63 lines
1.1 KiB
Go
Raw Normal View History

2024-02-11 10:56:21 +00:00
package models
import (
"time"
"github.com/lib/pq"
"gorm.io/gorm"
)
2024-02-12 08:25:11 +00:00
type OAuth2State struct {
State string `gorm:"primary_key"`
Expiry time.Time
}
type Worker struct {
gorm.Model
Name string `gorm:"unique" validate:"required"`
Slug string `gorm:"unique"`
Group string `validate:"required"`
Status string
}
2024-02-22 16:29:17 +00:00
const (
MonitorSuccess string = "SUCCESS"
MonitorFailure string = "FAILURE"
MonitorError string = "ERROR"
MonitorUnknown string = "UNKNOWN"
2024-02-22 16:29:17 +00:00
)
type Monitor struct {
gorm.Model
Slug string `gorm:"unique"`
Name string `gorm:"unique" validate:"required"`
Schedule string `validate:"required,cron"`
WorkerGroups pq.StringArray `gorm:"type:text[]"`
Script string `validate:"required"`
History []MonitorHistory `gorm:"foreignKey:Monitor"`
}
type Cronjob struct {
gorm.Model
Slug string `gorm:"unique"`
Name string `gorm:"unique"`
Schedule string
Buffer int
2024-02-11 10:56:21 +00:00
}
type MonitorHistory struct {
gorm.Model
Monitor uint
2024-02-22 16:29:17 +00:00
Status string
Note string
}
type CronjobHistory struct {
gorm.Model
Cronjob Cronjob `gorm:"foreignkey:ID"`
Status string
}