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

72 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
ID int
Name string `gorm:"uniqueIndex"`
}
type GitRepo struct {
ID int
Name string `gorm:"uniqueIndex"`
}
2024-12-13 07:10:12 +00:00
type RPMFile struct {
2024-12-12 20:36:38 +00:00
TaskID int
Name string
2024-12-13 07:10:12 +00:00
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
ID int
Status TaskStatus
2024-12-12 20:51:13 +00:00
Type TaskType
2024-12-12 20:36:38 +00:00
RepoID int
Repo GitRepo
ALTRepoID int
ALTRepo ALTRepo
2024-12-13 07:10:12 +00:00
Files []RPMFile
2024-12-12 20:36:38 +00:00
}
type GitRepoAltRepoTask struct {
gorm.Model
ID int
RepoID int `gorm:"uniqueIndex:idx_gr_ar_gitaltrepotask"`
Repo GitRepo
ALTRepoID int `gorm:"uniqueIndex:idx_gr_ar_gitaltrepotask"`
ALTRepo ALTRepo
TaskID int
Task Task
}