diff --git a/db/README.md b/db/README.md new file mode 100644 index 0000000..531b11f --- /dev/null +++ b/db/README.md @@ -0,0 +1,3 @@ +# [memo-demo.hasura.app](https://memo-demo.hasura.app) + +https://cloud.hasura.io → "Git Deployment" diff --git a/db/config.yaml b/db/config.yaml new file mode 100644 index 0000000..1ee3d0d --- /dev/null +++ b/db/config.yaml @@ -0,0 +1,6 @@ +version: 3 +endpoint: https://memo-demo.hasura.app +metadata_directory: metadata +actions: + kind: synchronous + handler_webhook_baseurl: http://localhost:3000 diff --git a/db/metadata/actions.graphql b/db/metadata/actions.graphql new file mode 100644 index 0000000..e69de29 diff --git a/db/metadata/actions.yaml b/db/metadata/actions.yaml new file mode 100644 index 0000000..1edb4c2 --- /dev/null +++ b/db/metadata/actions.yaml @@ -0,0 +1,6 @@ +actions: [] +custom_types: + enums: [] + input_objects: [] + objects: [] + scalars: [] diff --git a/db/metadata/allow_list.yaml b/db/metadata/allow_list.yaml new file mode 100644 index 0000000..4ef597f --- /dev/null +++ b/db/metadata/allow_list.yaml @@ -0,0 +1 @@ +- collection: allowed-queries diff --git a/db/metadata/cron_triggers.yaml b/db/metadata/cron_triggers.yaml new file mode 100644 index 0000000..41ef4e9 --- /dev/null +++ b/db/metadata/cron_triggers.yaml @@ -0,0 +1,16 @@ +- name: daily_reset + webhook: https://memo-demo.hasura.app/api/rest/delete_pages + schedule: 0 0 * * * + include_in_metadata: true + payload: {} + headers: + - value: "***" + name: x-hasura-admin-secret +- name: daily_seed + webhook: https://memo-demo.hasura.app/api/rest/seed_page + schedule: 1 0 * * * + include_in_metadata: true + payload: {} + headers: + - value: "***" + name: x-hasura-admin-secret diff --git a/db/metadata/databases/databases.yaml b/db/metadata/databases/databases.yaml new file mode 100644 index 0000000..60a7152 --- /dev/null +++ b/db/metadata/databases/databases.yaml @@ -0,0 +1,35 @@ +- name: default + kind: postgres + tables: + - table: + schema: public + name: pages + insert_permissions: + - role: anonymous + permission: + check: {} + columns: + - id + - content + backend_only: false + select_permissions: + - role: anonymous + permission: + columns: + - id + - content + filter: {} + update_permissions: + - role: anonymous + permission: + columns: + - id + - content + filter: {} + check: {} + configuration: + connection_info: + use_prepared_statements: false + database_url: + from_env: HEROKU_DATABASE_URL + isolation_level: read-committed diff --git a/db/metadata/query_collections.yaml b/db/metadata/query_collections.yaml new file mode 100644 index 0000000..cffe0fd --- /dev/null +++ b/db/metadata/query_collections.yaml @@ -0,0 +1,11 @@ +- name: allowed-queries + definition: + queries: + - name: get page + query: "query getPage($id: Int!) {\n page: pages_by_pk(id: $id) {\n id\n content\n }\n}" + - name: put page + query: "mutation putPage($id: Int, $content: jsonb!) {\n page: insert_pages_one(object: {id: $id, content: $content}, on_conflict: {constraint: pages_pkey, update_columns: content}) {\n id\n content\n }\n}" + - name: seed + query: "mutation seed($scheduled_time: String = \"\", $payload: jsonb = {}, $name: String = \"\", $id: String = \"\") {\n insert_pages_one(object: {id: 1, content: {ops: [{insert: \"メモ帳\\n\", attributes: {header: 1}}, {insert: \"\\nこんにちは!\\nこれは「Hasuraで作るREST API」のデモ用Webアプリです。\\nここに入力した内容は自動的にHasuraに送信されデータベースに保存されます。\\n\\n\"}], scheduled_time: $scheduled_time, payload: $payload, name: $name, id: $id}}) {\n id\n content\n }\n}" + - name: delete all + query: "mutation deleteAll($scheduled_time: String = \"\", $payload: jsonb = {}, $name: String = \"\", $id: String = \"\") {\n delete_pages(where: {id: {_is_null: false}, _or: {content: {_neq: {scheduled_time: $scheduled_time, payload: $payload, name: $name, id: $id}}}}) {\n affected_rows\n }\n}" diff --git a/db/metadata/remote_schemas.yaml b/db/metadata/remote_schemas.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/db/metadata/remote_schemas.yaml @@ -0,0 +1 @@ +[] diff --git a/db/metadata/rest_endpoints.yaml b/db/metadata/rest_endpoints.yaml new file mode 100644 index 0000000..8214d7c --- /dev/null +++ b/db/metadata/rest_endpoints.yaml @@ -0,0 +1,37 @@ +- definition: + query: + collection_name: allowed-queries + query_name: delete all + url: delete_pages + methods: + - POST + - DELETE + name: delete all + comment: null +- definition: + query: + collection_name: allowed-queries + query_name: get page + url: page/:id + methods: + - GET + name: get page + comment: null +- definition: + query: + collection_name: allowed-queries + query_name: put page + url: page/:id + methods: + - PUT + name: put page + comment: null +- definition: + query: + collection_name: allowed-queries + query_name: seed + url: seed_page + methods: + - POST + name: seed + comment: null diff --git a/db/metadata/version.yaml b/db/metadata/version.yaml new file mode 100644 index 0000000..0a70aff --- /dev/null +++ b/db/metadata/version.yaml @@ -0,0 +1 @@ +version: 3