mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
8357142001
- add [page](https://deploy-preview-814--hasura-docs-mono.netlify.app/graphql/core/databases/connect-db.html) on connecting databases - add [page](https://deploy-preview-814--hasura-docs-mono.netlify.app/graphql/cloud/projects/move-project-v2.html) to move 1.3 cloud projects to 2.0 - add [section](https://deploy-preview-814--hasura-docs-mono.netlify.app/graphql/core/migrations/upgrade-v3.html#continue-using-config-v2) on continue using config v2 with v2.0 projects GitOrigin-RevId: 5353466425f1c33d987037b739213a30e87e0efa
119 lines
2.1 KiB
ReStructuredText
119 lines
2.1 KiB
ReStructuredText
.. meta::
|
|
:description: Manage databases with the Hasura metadata API
|
|
:keywords: hasura, docs, metadata API, API reference, database, source
|
|
|
|
.. _metadata_api_sources:
|
|
|
|
Metadata API Reference: Databases (v2.0 and above)
|
|
==================================================
|
|
|
|
.. contents:: Table of contents
|
|
:backlinks: none
|
|
:depth: 1
|
|
:local:
|
|
|
|
Introduction
|
|
------------
|
|
|
|
Add/remove databases in Hasura GraphQL engine.
|
|
|
|
.. admonition:: Supported from
|
|
|
|
The metadata API is supported for versions ``v2.0.0`` and above and replaces the older
|
|
:ref:`schema/metadata API <schema_metadata_apis>`.
|
|
|
|
.. _pg_add_source:
|
|
|
|
pg_add_source
|
|
-------------
|
|
|
|
``pg_add_source`` is used to connect a Postgres database to Hasura.
|
|
|
|
Add a database with name ``pg1``:
|
|
|
|
.. code-block:: http
|
|
|
|
POST /v1/metadata HTTP/1.1
|
|
Content-Type: application/json
|
|
X-Hasura-Role: admin
|
|
|
|
{
|
|
"type": "pg_add_source",
|
|
"args": {
|
|
"name": "pg1",
|
|
"configuration": {
|
|
"connection_info": {
|
|
"database_url": {
|
|
"from_env": "<DB_URL_ENV_VAR>"
|
|
},
|
|
"pool_settings": {
|
|
"max_connections": 50,
|
|
"idle_timeout": 180,
|
|
"retries": 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.. _pg_add_source_syntax:
|
|
|
|
Args syntax
|
|
^^^^^^^^^^^
|
|
|
|
.. list-table::
|
|
:header-rows: 1
|
|
|
|
* - Key
|
|
- Required
|
|
- Schema
|
|
- Description
|
|
* - name
|
|
- true
|
|
- :ref:`SourceName <SourceName>`
|
|
- Name of the Postgres database
|
|
* - configuration
|
|
- true
|
|
- :ref:`PGConfiguration <PGConfiguration>`
|
|
- Database connection configuration
|
|
|
|
.. _pg_drop_source:
|
|
|
|
pg_drop_source
|
|
--------------
|
|
|
|
``pg_drop_source`` is used to remove a Postgres database from Hasura.
|
|
|
|
Remove a database with name ``pg1``:
|
|
|
|
.. code-block:: http
|
|
|
|
POST /v1/metadata HTTP/1.1
|
|
Content-Type: application/json
|
|
X-Hasura-Role: admin
|
|
|
|
{
|
|
"type": "pg_drop_source",
|
|
"args": {
|
|
"name": "pg1"
|
|
}
|
|
}
|
|
|
|
.. _pg_drop_source_syntax:
|
|
|
|
Args syntax
|
|
^^^^^^^^^^^
|
|
|
|
.. list-table::
|
|
:header-rows: 1
|
|
|
|
* - Key
|
|
- Required
|
|
- Schema
|
|
- Description
|
|
* - name
|
|
- true
|
|
- :ref:`SourceName <SourceName>`
|
|
- Name of the Postgres database
|
|
|