cairn/internal/models/models.go

121 lines
4.0 KiB
Go

package models
import (
"encoding/json"
"time"
)
type Repository struct {
ID uint `gorm:"primaryKey"`
Name string `gorm:"not null;index:idx_repositories_owner_name,unique"`
Owner string `gorm:"not null;index:idx_repositories_owner_name,unique"`
CreatedAt time.Time
UpdatedAt time.Time
}
func (Repository) TableName() string { return "repositories" }
type Commit struct {
ID uint `gorm:"primaryKey"`
RepositoryID uint `gorm:"not null;index:idx_commits_repository_sha,unique"`
SHA string `gorm:"not null;index:idx_commits_repository_sha,unique"`
Author *string
Message *string
Branch *string
CommittedAt *time.Time
CreatedAt time.Time
Repository Repository `gorm:"foreignKey:RepositoryID"`
}
func (Commit) TableName() string { return "commits" }
type Build struct {
ID uint `gorm:"primaryKey"`
RepositoryID uint `gorm:"not null;index"`
CommitID uint `gorm:"not null;index"`
Builder *string
BuildFlags *string
Tags json.RawMessage `gorm:"type:jsonb;default:'{}'"`
CreatedAt time.Time
Repository Repository `gorm:"foreignKey:RepositoryID"`
Commit Commit `gorm:"foreignKey:CommitID"`
}
func (Build) TableName() string { return "builds" }
type Artifact struct {
ID uint `gorm:"primaryKey"`
RepositoryID uint `gorm:"not null;index"`
CommitID uint `gorm:"not null;index"`
BuildID *uint `gorm:"index"`
CampaignID *uint `gorm:"index"`
CrashSignatureID *uint `gorm:"index"`
Type string `gorm:"not null;index"`
BlobKey string `gorm:"not null"`
BlobSize int64 `gorm:"not null"`
CrashMessage *string
StackTrace *string
Tags json.RawMessage `gorm:"type:jsonb;default:'{}'"`
Metadata json.RawMessage `gorm:"type:jsonb;default:'{}'"`
CreatedAt time.Time
Repository Repository `gorm:"foreignKey:RepositoryID"`
Commit Commit `gorm:"foreignKey:CommitID"`
Build *Build `gorm:"foreignKey:BuildID"`
Campaign *Campaign `gorm:"foreignKey:CampaignID"`
Signature *CrashSignature `gorm:"foreignKey:CrashSignatureID"`
}
func (Artifact) TableName() string { return "artifacts" }
type Campaign struct {
ID uint `gorm:"primaryKey"`
RepositoryID uint `gorm:"not null;index"`
Name string `gorm:"not null"`
Type string `gorm:"not null"`
Status string `gorm:"not null;default:running;index"`
StartedAt time.Time `gorm:"not null;autoCreateTime"`
FinishedAt *time.Time
Tags json.RawMessage `gorm:"type:jsonb;default:'{}'"`
Metadata json.RawMessage `gorm:"type:jsonb;default:'{}'"`
CreatedAt time.Time
Repository Repository `gorm:"foreignKey:RepositoryID"`
}
func (Campaign) TableName() string { return "campaigns" }
type CrashSignature struct {
ID uint `gorm:"primaryKey"`
RepositoryID uint `gorm:"not null;index:idx_signatures_repo_fingerprint,unique"`
Fingerprint string `gorm:"not null;index:idx_signatures_repo_fingerprint,unique"`
SampleTrace *string
FirstSeenAt time.Time `gorm:"not null;autoCreateTime"`
LastSeenAt time.Time `gorm:"not null;autoCreateTime"`
OccurrenceCount uint `gorm:"not null;default:1"`
Repository Repository `gorm:"foreignKey:RepositoryID"`
}
func (CrashSignature) TableName() string { return "crash_signatures" }
type CrashGroup struct {
ID uint `gorm:"primaryKey"`
RepositoryID uint `gorm:"not null;index"`
CrashSignatureID uint `gorm:"not null;index"`
Title string `gorm:"not null"`
Status string `gorm:"not null;default:open;index"`
ForgejoIssueID *int
FirstSeenAt time.Time `gorm:"not null;autoCreateTime"`
LastSeenAt time.Time `gorm:"not null;autoCreateTime"`
CreatedAt time.Time
UpdatedAt time.Time
Repository Repository `gorm:"foreignKey:RepositoryID"`
CrashSignature CrashSignature `gorm:"foreignKey:CrashSignatureID"`
}
func (CrashGroup) TableName() string { return "crash_groups" }