Skip to content

Commit

Permalink
Merge pull request #250 from NASA-AMMOS/feat/add-hasrua-ui-view-db
Browse files Browse the repository at this point in the history
[AERIE-1946] feat: add UI database to Hasura
  • Loading branch information
camargo authored Jul 19, 2022
2 parents 20b84e8 + a47a382 commit 2a1bf9b
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 38 deletions.
30 changes: 14 additions & 16 deletions deployment/Environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,20 @@ This document provides detailed information about environment variables for each

## Aerie Gateway

| Name | Description | Type | Default |
| ----------------------------- | ---------------------------------------------------------- | -------- | -------------------------------- |
| `GQL_API_URL` | URL of GraphQL API for the GraphQL Playground. | `string` | http://localhost:8080/v1/graphql |
| `LOG_FILE` | Either an output filepath to log to, or 'console'. | `string` | console |
| `LOG_LEVEL` | Logging level for filtering logs. | `string` | warn |
| `PORT` | Port the Gateway server listens on. | `number` | 9000 |
| `POSTGRES_AERIE_MERLIN_DB` | Name of Merlin Postgres database. | `string` | aerie_merlin |
| `POSTGRES_AERIE_SCHEDULER_DB` | Name of scheduler Postgres database. | `string` | aerie_scheduler |
| `POSTGRES_AERIE_UI_DB` | Name of UI Postgres database. | `string` | aerie_ui |
| `POSTGRES_HOST` | Hostname of Postgres instance. | `string` | localhost |
| `POSTGRES_PASSWORD` | Password of Postgres instance. | `string` | aerie |
| `POSTGRES_PORT` | Port of Postgres instance. | `number` | 5432 |
| `POSTGRES_USER` | User of Postgres instance. | `string` | aerie |
| `RATE_LIMITER_FILES_MAX` | Max requests allowed every 15 minutes to file endpoints | `number` | 1000 |
| `RATE_LIMITER_LOGIN_MAX` | Max requests allowed every 15 minutes to login endpoints | `number` | 1000 |
| `RATE_LIMITER_UI_VIEWS_MAX` | Max requests allowed every 15 minutes to UI view endpoints | `number` | 1000 |
| Name | Description | Type | Default |
| ----------------------------- | -------------------------------------------------------- | -------- | -------------------------------- |
| `GQL_API_URL` | URL of GraphQL API for the GraphQL Playground. | `string` | http://localhost:8080/v1/graphql |
| `LOG_FILE` | Either an output filepath to log to, or 'console'. | `string` | console |
| `LOG_LEVEL` | Logging level for filtering logs. | `string` | warn |
| `PORT` | Port the Gateway server listens on. | `number` | 9000 |
| `POSTGRES_AERIE_MERLIN_DB` | Name of Merlin Postgres database. | `string` | aerie_merlin |
| `POSTGRES_AERIE_SCHEDULER_DB` | Name of scheduler Postgres database. | `string` | aerie_scheduler |
| `POSTGRES_HOST` | Hostname of Postgres instance. | `string` | localhost |
| `POSTGRES_PASSWORD` | Password of Postgres instance. | `string` | aerie |
| `POSTGRES_PORT` | Port of Postgres instance. | `number` | 5432 |
| `POSTGRES_USER` | User of Postgres instance. | `string` | aerie |
| `RATE_LIMITER_FILES_MAX` | Max requests allowed every 15 minutes to file endpoints | `number` | 1000 |
| `RATE_LIMITER_LOGIN_MAX` | Max requests allowed every 15 minutes to login endpoints | `number` | 1000 |

## Aerie Merlin

Expand Down
1 change: 0 additions & 1 deletion deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ services:
PORT: 9000
POSTGRES_AERIE_MERLIN_DB: aerie_merlin
POSTGRES_AERIE_SCHEDULER_DB: aerie_scheduler
POSTGRES_AERIE_UI_DB: aerie_ui
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: aerie
POSTGRES_PORT: 5432
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table:
name: view
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- "!include public_view.yaml"
9 changes: 9 additions & 0 deletions deployment/hasura/metadata/databases/databases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@
isolation_level: read-committed
use_prepared_statements: false
tables: "!include AerieCommanding/tables/tables.yaml"
- name: AerieUI
kind: postgres
configuration:
connection_info:
database_url:
from_env: AERIE_UI_DATABASE_URL
isolation_level: read-committed
use_prepared_statements: false
tables: "!include AerieUI/tables/tables.yaml"
8 changes: 0 additions & 8 deletions deployment/postgres-init-db/data/ui/views/example_0.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{
"id": 0,
"meta": {
"owner": "system",
"timeCreated": 1615235211527,
"timeUpdated": 1615235211527,
"version": "0.12.0"
},
"name": "Banananation",
"plan": {
"activityTables": [
{
Expand Down
8 changes: 0 additions & 8 deletions deployment/postgres-init-db/data/ui/views/example_1.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{
"id": 1,
"meta": {
"owner": "system",
"timeCreated": 1615235194748,
"timeUpdated": 1615235194748,
"version": "0.12.0"
},
"name": "InSight",
"plan": {
"activityTables": [
{
Expand Down
4 changes: 2 additions & 2 deletions deployment/postgres-init-db/sql/ui/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ begin;
-- Seed UI View Data.
\set view_0 `cat /docker-entrypoint-initdb.d/data/ui/views/example_0.json`
\set view_1 `cat /docker-entrypoint-initdb.d/data/ui/views/example_1.json`
insert into view values (:'view_0');
insert into view values (:'view_1');
insert into view (definition, name) values (:'view_0', 'Banananation');
insert into view (definition, name) values (:'view_1', 'InSight');
end;
37 changes: 36 additions & 1 deletion deployment/postgres-init-db/sql/ui/tables/view.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
create table view (
view jsonb not null
created_at timestamptz not null default now(),
definition jsonb not null,
id integer generated always as identity,
name text not null,
owner text not null default 'system',
updated_at timestamptz not null default now(),

constraint view_primary_key primary key (id)
);

comment on table view is e''
'View configuration for Aerie UI.';
comment on column view.created_at is e''
'Time the view was created.';
comment on column view.definition is e''
'JSON blob of the view definition that implements the view JSON schema.';
comment on column view.id is e''
'Integer primary key of the view.';
comment on column view.name is e''
'Human-readable name of the view.';
comment on column view.owner is e''
'Username of the view owner.';
comment on column view.updated_at is e''
'Time the view was last updated.';

create or replace function view_set_updated_at()
returns trigger
security definer
language plpgsql as $$begin
new.updated_at = now();
return new;
end$$;

create trigger set_timestamp
before update on view
for each row
execute function view_set_updated_at();
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ services:
PORT: 9000
POSTGRES_AERIE_MERLIN_DB: aerie_merlin
POSTGRES_AERIE_SCHEDULER_DB: aerie_scheduler
POSTGRES_AERIE_UI_DB: aerie_ui
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: aerie
POSTGRES_PORT: 5432
Expand Down
1 change: 0 additions & 1 deletion e2e-tests/docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ services:
PORT: 9000
POSTGRES_AERIE_MERLIN_DB: aerie_merlin
POSTGRES_AERIE_SCHEDULER_DB: aerie_scheduler
POSTGRES_AERIE_UI_DB: aerie_ui
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: aerie
POSTGRES_PORT: 5432
Expand Down

0 comments on commit 2a1bf9b

Please sign in to comment.