Skip to content

Commit

Permalink
feat: config_id in components
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Aug 13, 2024
1 parent c9da951 commit d651ffa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions models/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ type Component struct {
UpdatedAt *time.Time `json:"updated_at,omitempty" time_format:"postgres_timestamp" gorm:"autoUpdateTime:false"`
DeletedAt *time.Time `json:"deleted_at,omitempty" time_format:"postgres_timestamp" swaggerignore:"true"`

// ConfigID is the id of the config from which this component is derived
ConfigID *uuid.UUID `json:"config_id,omitempty"`

// statusExpr allows defining a cel expression to evaluate the status of a component
// based on the summary and the related config
StatusExpr string `json:"status_expr,omitempty" gorm:"column:status_expr;default:null"`
Expand Down
10 changes: 10 additions & 0 deletions schema/components.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ table "components" {
null = true
type = uuid
}
column "config_id" {
null = true
type = uuid
}
column "name" {
null = false
type = text
Expand Down Expand Up @@ -334,6 +338,12 @@ table "components" {
on_update = NO_ACTION
on_delete = NO_ACTION
}
foreign_key "components_config_id_fkey" {
columns = [column.config_id]
ref_columns = [table.config_items.column.id]
on_update = NO_ACTION
on_delete = NO_ACTION
}
foreign_key "components_topology_id_fkey" {
columns = [column.topology_id]
ref_columns = [table.topologies.column.id]
Expand Down
3 changes: 2 additions & 1 deletion views/001_alter_deferred_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ BEGIN
-- Create a temporary table to store config_item IDs to ignore
CREATE TEMP TABLE ignored_config_items AS
SELECT DISTINCT config_id FROM evidences
UNION SELECT DISTINCT config_id FROM playbook_runs;
UNION SELECT DISTINCT config_id FROM playbook_runs
UNION SELECT DISTINCT config_id FROM components;

-- Create a temporary table to store config_item IDs to delete
CREATE TEMP TABLE config_items_to_delete AS
Expand Down

0 comments on commit d651ffa

Please sign in to comment.