From 11547ee713c1804c0f89b650c406b817807768af Mon Sep 17 00:00:00 2001 From: Daniel Aschwanden Date: Wed, 31 Jan 2024 14:15:36 +0100 Subject: [PATCH] feat(map): adds hasura configuration layers and features --- .../Postgres/tables/public_features.yaml | 52 +++++++++++++++++++ .../Postgres/tables/public_incidents.yaml | 7 +++ .../Postgres/tables/public_layers.yaml | 42 +++++++++++++++ .../databases/Postgres/tables/tables.yaml | 2 + metadata/opentelemetry.yaml | 1 + .../down.sql | 1 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 1 + 11 files changed, 112 insertions(+) create mode 100644 metadata/databases/Postgres/tables/public_features.yaml create mode 100644 metadata/databases/Postgres/tables/public_layers.yaml create mode 100644 metadata/opentelemetry.yaml create mode 100644 migrations/Postgres/1706705955292_create_table_public_layers/down.sql create mode 100644 migrations/Postgres/1706705955292_create_table_public_layers/up.sql create mode 100644 migrations/Postgres/1706706252027_create_table_public_features/down.sql create mode 100644 migrations/Postgres/1706706252027_create_table_public_features/up.sql create mode 100644 migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/down.sql create mode 100644 migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/up.sql diff --git a/metadata/databases/Postgres/tables/public_features.yaml b/metadata/databases/Postgres/tables/public_features.yaml new file mode 100644 index 00000000..391ed347 --- /dev/null +++ b/metadata/databases/Postgres/tables/public_features.yaml @@ -0,0 +1,52 @@ +table: + name: features + schema: public +object_relationships: + - name: layer + using: + foreign_key_constraint_on: layer_id +insert_permissions: + - role: editor + permission: + check: {} + columns: + - created_at + - geometry + - id + - layer_id + - properties +select_permissions: + - role: editor + permission: + columns: + - created_at + - deleted_at + - geometry + - id + - layer_id + - properties + - updated_at + filter: {} + - role: viewer + permission: + columns: + - created_at + - deleted_at + - geometry + - id + - layer_id + - properties + - updated_at + filter: {} +update_permissions: + - role: editor + permission: + columns: + - created_at + - deleted_at + - geometry + - id + - properties + - updated_at + filter: {} + check: null diff --git a/metadata/databases/Postgres/tables/public_incidents.yaml b/metadata/databases/Postgres/tables/public_incidents.yaml index 34e791b2..9138ed88 100644 --- a/metadata/databases/Postgres/tables/public_incidents.yaml +++ b/metadata/databases/Postgres/tables/public_incidents.yaml @@ -20,6 +20,13 @@ array_relationships: table: name: journals schema: public + - name: layers + using: + foreign_key_constraint_on: + column: incident_id + table: + name: layers + schema: public insert_permissions: - role: editor permission: diff --git a/metadata/databases/Postgres/tables/public_layers.yaml b/metadata/databases/Postgres/tables/public_layers.yaml new file mode 100644 index 00000000..e48e7c3c --- /dev/null +++ b/metadata/databases/Postgres/tables/public_layers.yaml @@ -0,0 +1,42 @@ +table: + name: layers + schema: public +object_relationships: + - name: incident + using: + foreign_key_constraint_on: incident_id +array_relationships: + - name: features + using: + foreign_key_constraint_on: + column: layer_id + table: + name: features + schema: public +insert_permissions: + - role: editor + permission: + check: {} + columns: + - incident_id + - name +select_permissions: + - role: editor + permission: + columns: + - id + - name + filter: {} + - role: viewer + permission: + columns: + - id + - name + filter: {} +update_permissions: + - role: editor + permission: + columns: + - name + filter: {} + check: null diff --git a/metadata/databases/Postgres/tables/tables.yaml b/metadata/databases/Postgres/tables/tables.yaml index 05b5109c..37c9aba9 100644 --- a/metadata/databases/Postgres/tables/tables.yaml +++ b/metadata/databases/Postgres/tables/tables.yaml @@ -1,6 +1,8 @@ - "!include public_divisions.yaml" +- "!include public_features.yaml" - "!include public_incidents.yaml" - "!include public_journals.yaml" +- "!include public_layers.yaml" - "!include public_locations.yaml" - "!include public_medium.yaml" - "!include public_message_division.yaml" diff --git a/metadata/opentelemetry.yaml b/metadata/opentelemetry.yaml new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/metadata/opentelemetry.yaml @@ -0,0 +1 @@ +{} diff --git a/migrations/Postgres/1706705955292_create_table_public_layers/down.sql b/migrations/Postgres/1706705955292_create_table_public_layers/down.sql new file mode 100644 index 00000000..0e741625 --- /dev/null +++ b/migrations/Postgres/1706705955292_create_table_public_layers/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."layers"; diff --git a/migrations/Postgres/1706705955292_create_table_public_layers/up.sql b/migrations/Postgres/1706705955292_create_table_public_layers/up.sql new file mode 100644 index 00000000..4a867c81 --- /dev/null +++ b/migrations/Postgres/1706705955292_create_table_public_layers/up.sql @@ -0,0 +1,2 @@ +CREATE TABLE "public"."layers" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "incident" uuid NOT NULL, "name" text NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("incident") REFERENCES "public"."incidents"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("id")); +CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/migrations/Postgres/1706706252027_create_table_public_features/down.sql b/migrations/Postgres/1706706252027_create_table_public_features/down.sql new file mode 100644 index 00000000..4929f4c7 --- /dev/null +++ b/migrations/Postgres/1706706252027_create_table_public_features/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."features"; diff --git a/migrations/Postgres/1706706252027_create_table_public_features/up.sql b/migrations/Postgres/1706706252027_create_table_public_features/up.sql new file mode 100644 index 00000000..d0a89212 --- /dev/null +++ b/migrations/Postgres/1706706252027_create_table_public_features/up.sql @@ -0,0 +1,2 @@ +CREATE TABLE "public"."features" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "layer_id" uuid NOT NULL, "properties" jsonb NOT NULL, "geometry" jsonb NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id") , FOREIGN KEY ("layer_id") REFERENCES "public"."layers"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("id"));COMMENT ON TABLE "public"."features" IS E'Features GeoJSON'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/down.sql b/migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/down.sql new file mode 100644 index 00000000..0f64b85b --- /dev/null +++ b/migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/down.sql @@ -0,0 +1 @@ +alter table "public"."layers" rename column "incident_id" to "incident"; diff --git a/migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/up.sql b/migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/up.sql new file mode 100644 index 00000000..e80e9ba8 --- /dev/null +++ b/migrations/Postgres/1706706423383_alter_table_public_layers_alter_column_incident/up.sql @@ -0,0 +1 @@ +alter table "public"."layers" rename column "incident" to "incident_id";