Skip to content

Commit

Permalink
feat: add is_pushed column to check_statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 12, 2023
1 parent 966b189 commit 50ddbad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions models/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ type CheckStatus struct {
Error string `json:"error,omitempty"`
Detail any `json:"-" gorm:"-"`
CreatedAt time.Time `json:"created_at,omitempty"`
// IsPushed when set to true indicates that the check status has been pushed to upstream.
IsPushed bool `json:"is_pushed,omitempty"`
}

func (s CheckStatus) GetTime() (time.Time, error) {
Expand Down
26 changes: 18 additions & 8 deletions schema/checks.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ table "canaries" {
default = sql("generate_ulid()")
}
column "agent_id" {
null = false
null = false
default = var.uuid_nil
type = uuid
type = uuid
}
column "name" {
null = false
Expand All @@ -31,17 +31,17 @@ table "canaries" {
type = text
}
column "created_at" {
null = true
type = timestamptz
null = true
type = timestamptz
default = sql("now()")
}
column "created_by" {
null = true
type = uuid
}
column "updated_at" {
null = true
type = timestamptz
null = true
type = timestamptz
default = sql("now()")
}
column "deleted_at" {
Expand Down Expand Up @@ -111,6 +111,12 @@ table "check_statuses" {
null = true
type = text
}
column "is_pushed" {
null = false
default = false
type = bool
comment = "is_pushed when set to true indicates that the check status has been pushed to upstream."
}
primary_key {
columns = [column.check_id, column.time]
}
Expand All @@ -124,6 +130,10 @@ table "check_statuses" {
type = BRIN
columns = [column.time]
}
index "check_statuses_is_pushed_idx" {
columns = [column.is_pushed]
where = "is_pushed IS FALSE"
}
}

table "checks" {
Expand All @@ -138,9 +148,9 @@ table "checks" {
type = uuid
}
column "agent_id" {
null = false
null = false
default = var.uuid_nil
type = uuid
type = uuid
}
column "type" {
null = false
Expand Down

0 comments on commit 50ddbad

Please sign in to comment.