Skip to content
Closed

Cyndi2 #2018

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8af8782
RHINENG-21214: create system_inventory table
Dugowitch Oct 15, 2025
b73f9fb
RHINENG-21214: create system_patch table
Dugowitch Oct 15, 2025
89952bf
RHINENG-21214: load data into the new tables
Dugowitch Oct 15, 2025
e1fd07b
RHINENG-21214: update fkeys to refer to system_inventory
Dugowitch Dec 17, 2025
12bfcf8
RHINENG-21214: update sql functions that use system_platform
Dugowitch Oct 15, 2025
b6c9d25
RHINENG-21214: replace old tables with views
Dugowitch Oct 15, 2025
fe135b5
RHINENG-21214: add down migration
Dugowitch Dec 11, 2025
b091f2c
RHINENG-21214: update test data
Dugowitch Nov 14, 2025
59c1629
RHINENG-21214: update create_schema.sql
Dugowitch Dec 17, 2025
d113c5c
RHINENG-21214: remove unused insights_id
MichaelMraka Jan 19, 2026
3decb1c
RHINENG-21214: add models for the new tables
Dugowitch Jan 7, 2026
267557d
wip: fix TestInitDelete
Dugowitch Jan 20, 2026
4d1cdcc
wip: fix TestSystemDelete
Dugowitch Jan 20, 2026
be01b5b
RHINENG-21214: handle inserts/updates to system_platform view
MichaelMraka Jan 21, 2026
aa33bf3
fixup! RHINENG-21214: update create_schema.sql
MichaelMraka Jan 21, 2026
b211442
fixup! RHINENG-21214: handle inserts/updates to system_platform view
MichaelMraka Jan 21, 2026
4d17100
fixup! RHINENG-21214: update test data
MichaelMraka Jan 21, 2026
d3cf891
RHINENG-21214: fix TestTableSizes
MichaelMraka Jan 21, 2026
a2f3daa
fixup! RHINENG-21214: load data into the new tables
MichaelMraka Jan 21, 2026
26bdb46
fixup! RHINENG-21214: update create_schema.sql
MichaelMraka Jan 21, 2026
d231db0
fixup! RHINENG-21214: add models for the new tables
MichaelMraka Jan 21, 2026
eb0fe48
wip: replace save into system_platform with system_{inventory,patch}
MichaelMraka Jan 22, 2026
3250fc1
fixup! RHINENG-21214: add models for the new tables
MichaelMraka Jan 22, 2026
d2d03c1
fixup! wip: replace save into system_platform with system_{inventory,…
MichaelMraka Jan 22, 2026
fc19cca
RHINENG-21214: DoNothing the there are no clumns to update
MichaelMraka Jan 22, 2026
943ebe7
fixup! wip: replace save into system_platform with system_{inventory,…
MichaelMraka Jan 22, 2026
c56c378
wip: save evaluated data
MichaelMraka Jan 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions base/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ func OnConflictUpdateMulti(db *gorm.DB, keys []string, updateCols ...string) *go
for _, key := range keys {
confilctColumns = append(confilctColumns, clause.Column{Name: key})
}
return db.Clauses(clause.OnConflict{
Columns: confilctColumns,
DoUpdates: clause.AssignmentColumns(updateCols),
})
onConflict := clause.OnConflict{Columns: confilctColumns}
if len(updateCols) > 0 {
onConflict.DoUpdates = clause.AssignmentColumns(updateCols)
} else {
onConflict.DoNothing = true
}
return db.Clauses(onConflict)
}

type UpExpr struct {
Expand Down
73 changes: 73 additions & 0 deletions base/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package models

import (
"time"

"github.com/lib/pq"
)

type RhAccount struct {
Expand Down Expand Up @@ -96,6 +98,77 @@ func (s *SystemPlatform) GetInventoryID() string {
return s.InventoryID
}

type SystemInventory struct {
ID int64 `gorm:"primaryKey"`
InventoryID string `gorm:"unique"`
RhAccountID int `gorm:"primaryKey"`
VmaasJSON *string
JSONChecksum *string
LastUpdated *time.Time `gorm:"default:null"`
UnchangedSince *time.Time `gorm:"default:null"`
LastUpload *time.Time `gorm:"default:null"`
Stale bool
DisplayName string
ReporterID *int
YumUpdates []byte `gorm:"column:yum_updates"`
YumChecksum *string `gorm:"column:yum_checksum"`
SatelliteManaged bool `gorm:"column:satellite_managed"`
BuiltPkgcache bool `gorm:"column:built_pkgcache"`
Arch *string
Bootc bool
Tags []byte `gorm:"column:tags"`
Created time.Time
Workspaces pq.StringArray `gorm:"type:text[]"`
StaleTimestamp *time.Time
StaleWarningTimestamp *time.Time
CulledTimestamp *time.Time
OSName *string
OSMajor *int16
OSMinor *int16
RhsmVersion *string
SubscriptionManagerID *string
SapWorkload bool
SapWorkloadSIDs pq.StringArray `gorm:"type:text[];column:sap_workload_sids"`
AnsibleWorkload bool
AnsibleWorkloadControllerVersion *string
MssqlWorkload bool
MssqlWorkloadVersion *string
}

func (SystemInventory) TableName() string {
return "system_inventory"
}

func (s *SystemInventory) GetInventoryID() string {
if s == nil {
return ""
}
return s.InventoryID
}

type SystemPatch struct {
SystemID int64 `gorm:"primaryKey"`
RhAccountID int `gorm:"primaryKey"`
LastEvaluation *time.Time `gorm:"default:null"` // TODO: trigger sets it to current time?
InstallableAdvisoryCountCache int
InstallableAdvisoryEnhCountCache int
InstallableAdvisoryBugCountCache int
InstallableAdvisorySecCountCache int
PackagesInstalled int
PackagesInstallable int
PackagesApplicable int
ThirdParty bool
ApplicableAdvisoryCountCache int
ApplicableAdvisoryEnhCountCache int
ApplicableAdvisoryBugCountCache int
ApplicableAdvisorySecCountCache int
TemplateID *int64 `gorm:"column:template_id"`
}

func (SystemPatch) TableName() string {
return "system_patch"
}

type String struct {
ID []byte `gorm:"primaryKey"`
Value string
Expand Down
Loading
Loading