From 34a5d0b2b767520cd3f187685ff4b5d5ce82cb72 Mon Sep 17 00:00:00 2001 From: Morgan Mccauley Date: Mon, 7 Aug 2023 11:27:50 +1200 Subject: [PATCH 1/3] feat: Init hasura CLI --- hasura/config.yaml | 6 ++++++ hasura/metadata/actions.graphql | 0 hasura/metadata/actions.yaml | 6 ++++++ hasura/metadata/allow_list.yaml | 1 + hasura/metadata/cron_triggers.yaml | 1 + hasura/metadata/databases/databases.yaml | 1 + hasura/metadata/query_collections.yaml | 1 + hasura/metadata/remote_schemas.yaml | 1 + hasura/metadata/version.yaml | 1 + 9 files changed, 18 insertions(+) create mode 100644 hasura/config.yaml create mode 100644 hasura/metadata/actions.graphql create mode 100644 hasura/metadata/actions.yaml create mode 100644 hasura/metadata/allow_list.yaml create mode 100644 hasura/metadata/cron_triggers.yaml create mode 100644 hasura/metadata/databases/databases.yaml create mode 100644 hasura/metadata/query_collections.yaml create mode 100644 hasura/metadata/remote_schemas.yaml create mode 100644 hasura/metadata/version.yaml diff --git a/hasura/config.yaml b/hasura/config.yaml new file mode 100644 index 000000000..725c8005e --- /dev/null +++ b/hasura/config.yaml @@ -0,0 +1,6 @@ +version: 3 +endpoint: http://localhost:8080 +metadata_directory: metadata +actions: + kind: synchronous + handler_webhook_baseurl: http://localhost:3000 diff --git a/hasura/metadata/actions.graphql b/hasura/metadata/actions.graphql new file mode 100644 index 000000000..e69de29bb diff --git a/hasura/metadata/actions.yaml b/hasura/metadata/actions.yaml new file mode 100644 index 000000000..1edb4c2ff --- /dev/null +++ b/hasura/metadata/actions.yaml @@ -0,0 +1,6 @@ +actions: [] +custom_types: + enums: [] + input_objects: [] + objects: [] + scalars: [] diff --git a/hasura/metadata/allow_list.yaml b/hasura/metadata/allow_list.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/metadata/allow_list.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/cron_triggers.yaml b/hasura/metadata/cron_triggers.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/metadata/cron_triggers.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/databases/databases.yaml b/hasura/metadata/databases/databases.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/metadata/databases/databases.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/query_collections.yaml b/hasura/metadata/query_collections.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/metadata/query_collections.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/remote_schemas.yaml b/hasura/metadata/remote_schemas.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/metadata/remote_schemas.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/version.yaml b/hasura/metadata/version.yaml new file mode 100644 index 000000000..0a70affa4 --- /dev/null +++ b/hasura/metadata/version.yaml @@ -0,0 +1 @@ +version: 3 From 452f06996afa2d83ecdf97dbb824ea28680a3712 Mon Sep 17 00:00:00 2001 From: Morgan Mccauley Date: Mon, 7 Aug 2023 11:29:31 +1200 Subject: [PATCH 2/3] feat: Add initial hasura metadata config --- hasura/config.yaml | 1 + hasura/metadata/databases/databases.yaml | 15 ++++++++- .../tables/public_indexer_log_entries.yaml | 23 ++++++++++++++ .../default/tables/public_indexer_state.yaml | 31 +++++++++++++++++++ .../databases/default/tables/tables.yaml | 2 ++ hasura/metadata/rest_endpoints.yaml | 1 + 6 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 hasura/metadata/databases/default/tables/public_indexer_log_entries.yaml create mode 100644 hasura/metadata/databases/default/tables/public_indexer_state.yaml create mode 100644 hasura/metadata/databases/default/tables/tables.yaml create mode 100644 hasura/metadata/rest_endpoints.yaml diff --git a/hasura/config.yaml b/hasura/config.yaml index 725c8005e..d13faa054 100644 --- a/hasura/config.yaml +++ b/hasura/config.yaml @@ -1,5 +1,6 @@ version: 3 endpoint: http://localhost:8080 +admin_secret: myadminsecretkey metadata_directory: metadata actions: kind: synchronous diff --git a/hasura/metadata/databases/databases.yaml b/hasura/metadata/databases/databases.yaml index fe51488c7..65a11b202 100644 --- a/hasura/metadata/databases/databases.yaml +++ b/hasura/metadata/databases/databases.yaml @@ -1 +1,14 @@ -[] +- name: default + kind: postgres + configuration: + connection_info: + database_url: + from_env: HASURA_GRAPHQL_DATABASE_URL + isolation_level: read-committed + pool_settings: + connection_lifetime: 600 + idle_timeout: 180 + max_connections: 50 + retries: 1 + use_prepared_statements: true + tables: "!include default/tables/tables.yaml" diff --git a/hasura/metadata/databases/default/tables/public_indexer_log_entries.yaml b/hasura/metadata/databases/default/tables/public_indexer_log_entries.yaml new file mode 100644 index 000000000..c95174150 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_indexer_log_entries.yaml @@ -0,0 +1,23 @@ +table: + name: indexer_log_entries + schema: public +insert_permissions: +- permission: + check: {} + columns: + - block_height + - function_name + - message + - timestamp + - id + role: append +select_permissions: +- permission: + columns: + - block_height + - function_name + - message + - timestamp + - id + filter: {} + role: append diff --git a/hasura/metadata/databases/default/tables/public_indexer_state.yaml b/hasura/metadata/databases/default/tables/public_indexer_state.yaml new file mode 100644 index 000000000..51084d5a3 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_indexer_state.yaml @@ -0,0 +1,31 @@ +table: + name: indexer_state + schema: public +insert_permissions: +- permission: + check: {} + columns: + - function_name + - current_block_height + - current_historical_block_height + - status + role: append +select_permissions: +- permission: + columns: + - function_name + - current_block_height + - current_historical_block_height + - status + filter: {} + role: append +update_permissions: +- permission: + check: {} + columns: + - function_name + - current_block_height + - current_historical_block_height + - status + filter: {} + role: append diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml new file mode 100644 index 000000000..fb74b4277 --- /dev/null +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -0,0 +1,2 @@ +- "!include public_indexer_log_entries.yaml" +- "!include public_indexer_state.yaml" diff --git a/hasura/metadata/rest_endpoints.yaml b/hasura/metadata/rest_endpoints.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/metadata/rest_endpoints.yaml @@ -0,0 +1 @@ +[] From abb650e308a87320dc7a5211d7d3104c6b7453b7 Mon Sep 17 00:00:00 2001 From: Morgan Mccauley Date: Mon, 7 Aug 2023 11:34:54 +1200 Subject: [PATCH 3/3] feat: Add initial hasura migration --- .../default/1691364619300_init/down.sql | 2 ++ .../default/1691364619300_init/up.sql | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 hasura/migrations/default/1691364619300_init/down.sql create mode 100644 hasura/migrations/default/1691364619300_init/up.sql diff --git a/hasura/migrations/default/1691364619300_init/down.sql b/hasura/migrations/default/1691364619300_init/down.sql new file mode 100644 index 000000000..9ba2f7739 --- /dev/null +++ b/hasura/migrations/default/1691364619300_init/down.sql @@ -0,0 +1,2 @@ +DROP TABLE public.indexer_log_entries; +DROP TABLE public.indexer_state; diff --git a/hasura/migrations/default/1691364619300_init/up.sql b/hasura/migrations/default/1691364619300_init/up.sql new file mode 100644 index 000000000..9b7f5dd94 --- /dev/null +++ b/hasura/migrations/default/1691364619300_init/up.sql @@ -0,0 +1,18 @@ +SET check_function_bodies = false; +CREATE TABLE public.indexer_log_entries ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + function_name text NOT NULL, + block_height numeric NOT NULL, + "timestamp" timestamp without time zone DEFAULT CURRENT_TIMESTAMP, + message text +); +CREATE TABLE public.indexer_state ( + function_name character varying NOT NULL, + current_block_height numeric(21,0) NOT NULL, + status text, + current_historical_block_height numeric(21,0) +); +ALTER TABLE ONLY public.indexer_log_entries + ADD CONSTRAINT indexer_log_entries_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.indexer_state + ADD CONSTRAINT indexer_state_pkey PRIMARY KEY (function_name);