Skip to content

Commit

Permalink
feat(hasura): add health_check_history table
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Mar 8, 2023
1 parent 9bc804f commit 000430c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions hasura/metadata/backend_configs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: health_check_history
schema: public
1 change: 1 addition & 0 deletions hasura/metadata/databases/default/tables/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- "!include public_demux_state.yaml"
- "!include public_endpoint.yaml"
- "!include public_endpoints_by_producer_id.yaml"
- "!include public_health_check_history.yaml"
- "!include public_node.yaml"
- "!include public_node_info.yaml"
- "!include public_producer.yaml"
Expand Down
1 change: 1 addition & 0 deletions hasura/metadata/metrics_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions hasura/metadata/opentelemetry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "public"."health_check_history";
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE "public"."health_check_history" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "date" date NOT NULL, "total_checks" integer NOT NULL DEFAULT 1, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("id") , UNIQUE ("id"), UNIQUE ("date"));
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_health_check_history_updated_at"
BEFORE UPDATE ON "public"."health_check_history"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_health_check_history_updated_at" ON "public"."health_check_history"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
CREATE EXTENSION IF NOT EXISTS pgcrypto;

0 comments on commit 000430c

Please sign in to comment.