feat(db): add lidarr_quarantine + actions schema (migration 0011)

This commit is contained in:
2026-04-30 16:48:33 -04:00
parent 0806a37a42
commit a8df73fe42
5 changed files with 623 additions and 0 deletions
+109
View File
@@ -11,6 +11,94 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
type LidarrQuarantineActionKind string
const (
LidarrQuarantineActionKindResolved LidarrQuarantineActionKind = "resolved"
LidarrQuarantineActionKindDeletedFile LidarrQuarantineActionKind = "deleted_file"
LidarrQuarantineActionKindDeletedViaLidarr LidarrQuarantineActionKind = "deleted_via_lidarr"
)
func (e *LidarrQuarantineActionKind) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = LidarrQuarantineActionKind(s)
case string:
*e = LidarrQuarantineActionKind(s)
default:
return fmt.Errorf("unsupported scan type for LidarrQuarantineActionKind: %T", src)
}
return nil
}
type NullLidarrQuarantineActionKind struct {
LidarrQuarantineActionKind LidarrQuarantineActionKind
Valid bool // Valid is true if LidarrQuarantineActionKind is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullLidarrQuarantineActionKind) Scan(value interface{}) error {
if value == nil {
ns.LidarrQuarantineActionKind, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.LidarrQuarantineActionKind.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullLidarrQuarantineActionKind) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.LidarrQuarantineActionKind), nil
}
type LidarrQuarantineReason string
const (
LidarrQuarantineReasonBadRip LidarrQuarantineReason = "bad_rip"
LidarrQuarantineReasonWrongFile LidarrQuarantineReason = "wrong_file"
LidarrQuarantineReasonWrongTags LidarrQuarantineReason = "wrong_tags"
LidarrQuarantineReasonDuplicate LidarrQuarantineReason = "duplicate"
LidarrQuarantineReasonOther LidarrQuarantineReason = "other"
)
func (e *LidarrQuarantineReason) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = LidarrQuarantineReason(s)
case string:
*e = LidarrQuarantineReason(s)
default:
return fmt.Errorf("unsupported scan type for LidarrQuarantineReason: %T", src)
}
return nil
}
type NullLidarrQuarantineReason struct {
LidarrQuarantineReason LidarrQuarantineReason
Valid bool // Valid is true if LidarrQuarantineReason is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullLidarrQuarantineReason) Scan(value interface{}) error {
if value == nil {
ns.LidarrQuarantineReason, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.LidarrQuarantineReason.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullLidarrQuarantineReason) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.LidarrQuarantineReason), nil
}
type LidarrRequestKind string
const (
@@ -167,6 +255,27 @@ type LidarrConfig struct {
UpdatedAt pgtype.Timestamptz
}
type LidarrQuarantine struct {
UserID pgtype.UUID
TrackID pgtype.UUID
Reason LidarrQuarantineReason
Notes *string
CreatedAt pgtype.Timestamptz
}
type LidarrQuarantineAction struct {
ID pgtype.UUID
TrackID pgtype.UUID
TrackTitle string
ArtistName string
AlbumTitle *string
Action LidarrQuarantineActionKind
AdminID pgtype.UUID
LidarrAlbumMbid *string
AffectedUsers int32
CreatedAt pgtype.Timestamptz
}
type LidarrRequest struct {
ID pgtype.UUID
UserID pgtype.UUID