aides-repo-api/internal/models/db.go

78 lines
1.1 KiB
Go
Raw Normal View History

2024-12-12 20:36:38 +00:00
package models
2024-12-13 07:10:12 +00:00
import (
"gorm.io/gorm"
)
2024-12-12 20:36:38 +00:00
type ALTRepo struct {
gorm.Model
Name string `gorm:"uniqueIndex"`
}
type GitRepo struct {
2024-12-13 10:52:15 +00:00
gorm.Model
2024-12-12 20:36:38 +00:00
Name string `gorm:"uniqueIndex"`
}
2024-12-13 07:10:12 +00:00
type RPMFile struct {
2024-12-13 10:52:15 +00:00
gorm.Model
2024-12-12 20:36:38 +00:00
TaskID int
2024-12-13 10:52:15 +00:00
Task Task
Name string
Arch string
2024-12-12 20:36:38 +00:00
}
type TaskStatus int
const (
StatusPending TaskStatus = iota // 0
StatusInProgress // 1
StatusCompleted // 2
StatusFailed // 3
StatusCancelled // 4
)
2024-12-12 20:51:13 +00:00
type TaskType int
const (
// For future purpose
TypeTestOnly TaskType = iota // 0
TypeUpsert // 1
// For future purpose
TypeDelete // 2
)
2024-12-12 20:36:38 +00:00
type Task struct {
gorm.Model
Status TaskStatus
2024-12-12 20:51:13 +00:00
Type TaskType
2024-12-12 20:36:38 +00:00
2024-12-13 10:52:15 +00:00
RepoID uint
Repo *GitRepo
ALTRepoID uint
2024-12-12 20:36:38 +00:00
ALTRepo ALTRepo
2024-12-13 10:52:15 +00:00
FilesRemoved bool
Files []RPMFile
2024-12-12 20:36:38 +00:00
}
type GitRepoAltRepoTask struct {
gorm.Model
2024-12-13 10:52:15 +00:00
RepoID uint `gorm:"uniqueIndex:idx_gr_ar_gitaltrepotask"`
Repo *GitRepo
ALTRepoID uint `gorm:"uniqueIndex:idx_gr_ar_gitaltrepotask"`
ALTRepo *ALTRepo
2024-12-12 20:36:38 +00:00
2024-12-13 20:39:41 +00:00
LastTaskID *uint
2024-12-13 10:52:15 +00:00
LastTask *Task
2024-12-13 20:39:41 +00:00
CurrentTaskID *uint
CurrentTask *Task
2024-12-12 20:36:38 +00:00
}