diff --git a/models/config.go b/models/config.go index 135004bb..0dd53af1 100644 --- a/models/config.go +++ b/models/config.go @@ -456,7 +456,7 @@ type ConfigChange struct { CreatedAt *time.Time `json:"created_at"` // FirstObserved represents the timestamp when this change was first observed. - FirstObserved *time.Time `gorm:"first_observed" json:"first_observed,omitempty"` + FirstObserved *time.Time `gorm:"first_observed;default:now()" json:"first_observed,omitempty"` // Count is the number of occurrences of this change, including duplicates detected by fingerprinting Count int `json:"count"` diff --git a/schema/config.hcl b/schema/config.hcl index f65f8826..5d352e44 100644 --- a/schema/config.hcl +++ b/schema/config.hcl @@ -156,8 +156,9 @@ table "config_changes" { } column "count" { - null = true - type = int + null = false + default = 1 + type = int } column "fingerprint" { @@ -166,11 +167,11 @@ table "config_changes" { } column "first_observed" { - null = true - type = timestamptz + null = false + default = sql("now()") + type = timestamptz } - column "is_pushed" { null = false default = false