Skip to main content
Version: v2.x

Manage Hasura Metadata (config v2)


If your Postgres schema is already managed with a tool like knex, TypeORM, Django/Rails migrations, you will still need a way to export the actions you performed on the Hasura Console to apply it later on another Hasura instance.

All the actions performed on the Console, like tracking tables/views/custom functions, creating relationships, configuring permissions, creating Event Triggers and Remote Schemas, etc. can be exported as a JSON/yaml Metadata file which can be version controlled. The Metadata file can be later imported to another Hasura instance to get the same configuration. You can also manually edit the Metadata file to add more objects to it and then use it to update the instance.

Exporting Hasura Metadata

Metadata can be exported with the hasura metadata export command.

This will export the Metadata as yaml files in the /metadata directory


The Metadata exported via the console and API will be a single JSON file that can be applied via the Console or the API only.

The Metadata exported via the CLI is broken into multiple YAML files for easier management in version control and CI/CD and can be applied via the CLI or the cli-migrations image only.

Applying/Importing Hasura Metadata

You can apply exported Metadata from one Hasura GraphQL Engine instance to another. You can also apply an older or modified version of an instance's Metadata onto itself.

Importing completely replaces the Metadata on that instance, i.e. you lose any Metadata that was already present before.

Metadata can be applied with the hasura metadata apply command.


All the dependent objects, like tables, views, functions etc. should exist on Postgres before importing the metadata. Otherwise, it will result in an error saying the object does not exist. So, apply the Postgres schema first, before importing the metadata.

Reloading Hasura Metadata

In some cases, the Metadata can be out of sync with the Postgres schema. For example, when a new column has been added to a table via an external tool such as psql.

Metadata can be reloaded with the hasura metadata reload command.


Reloading may result in inconsistent Metadata status. You may need to resolve all inconsistent objects manually or delete them. After that, you need to reload Metadata again.

Resetting Hasura Metadata

Resetting GraphQL Engine's Metadata is an irreversible process. It is recommended to first export the metadata so that it can be reapplied if needed or else that information will be lost and Hasura will have to be configured again from scratch (e.g. tracking tables, relationships, creating triggers, actions, etc.).

Metadata can be reset with the hasura metadata clear command.

Managing Hasura Metadata in CI/CD

In case you need an automated way of applying/importing the metadata, take a look at the cli-migrations Docker image, which can start the GraphQL Engine after automatically importing a mounted Metadata directory.