question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v2.0.0-alpha.5: issue applying metadata to hasura cloud instance ("source with name \"default\" [does not exist/is inconsistent]")

See original GitHub issue

Hi team - I am currently using Hasura CLI v2.0.0-alpha.5 and having issue to apply local metadata / migration files to the remote Hasura cloud instance as it keeps saying that "source with name \"default\" does not exist".

I tried the following according to the config v3 documentation as well as other raised issues:

  • create local metadata and migration files with hasura initcommand
  • launch the local console with hasura console (at this stage, the local postgres DB is called default by default with a public schema inside it, not sure if we can change it or if we should not change it, for now I keep it unchanged but just asking out of curiosity)
  • create a random test table, so far so good

Now I want to apply this change to the Hasura cloud instance

  • when creating a new DB via Heroku, it shows a fancy name so I removed it and re-added it by renaming it default so that the database-name matches with my local metadata/migration files, here is a screenshot of the cloud instance: screenshot_1 screenshot_2

  • it matches with local files names: screenshot_3

  • but still, when applying the local changes to the cloud instance I get the following error message: screenshot_4

Highly appreciate if someone can help, thank you very much.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
hubertkuochcommented, Mar 25, 2021

Ok just got it work actually. I think in case of several databases or easy ci/cd with say different .env file we only have to remove the HASURA_GRAPHQL_DATABASE_URL from the docker-compose file and add our own custom var + making sure names are identical between local and remote instances. Tks again and closing the issue.

0reactions
hubertkuochcommented, Mar 25, 2021

@rikinsk Hey no worries. Thank you for your reply. I just tried and it works indeed when I replace the value of HASURA_GRAPHQL_DATABASE_URL in .env file with the value of my cloud instance URL. But still, is there a way to avoid having to change it manually whenever I choose to apply it on cloud instance or local dockerized postgres instance?

Just to be more specific on my issue:

In dev mode, I ran the usual suspect commands: 1 - install hasura locally with curl https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/docker-compose-v2.0.0/docker-compose.yaml -o docker-compose.yml 2 - hasura init to initialize local metadata and migration folders which are empty at that stage 3 - docker-compose up to start local db and hasura graphql engine 4 - hasura console to start making changes that are automatically reflected in local folders/files Important: note at this stage that the metadata/databases/databases.yaml file gets updated with the following config

configuration:
    connection_info:
      database_url:
        from_env: HASURA_GRAPHQL_DATABASE_URL <<< this env var seems needed for local dev
      pool_settings: {}

and that the database is named default automatically.

In prod mode, say I did some changes locally and I want to reflect those on cloud instance: 1 - create a project via hasura website 2 - create a new database say with Heroku 3 - now I want to apply local changes to remote instance using usual commands with creds

hasura migrate apply --endpoint [_ENDPOINT_] --admin-secret [_ADMIN_SECRET_] --database-name default
hasura metadata apply --endpoint [_ENDPOINT_] --admin-secret [_ADMIN_SECRET_]

I will get the errors discussed above: 1 - default does not exist on cloud instance so I have to drop the Heroku database and re-add it manually by giving it the name default 2 - event with that, I will have another error with metadata saying HASURA_GRAPHQL_DATABASE_URL does not exist on cloud instance, indeed, it is called HEROKU_DATABASE_URL as you pointed out. Now I can for sure change manually i.e. plug in the value as you suggested, but then I will have to change it manually back and forth whenever I want to apply on local or remote instance and metadata will never be in sync by doing so.

I also tried using different .env files for local and remote but got the same issue, looks like both environments need to have exactly the same database names and env var names for metadata to apply correctly.

Sorry for this long post, I got pretty confused by the v3 multi-database possibility as this issue did not happen in previous versions as there was only one HASURA_GRAPHQL_DATABASE_URL env var on both local and cloud instances.

(Final note: I read now we have to apply metadata first and then apply migration, am I correct?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hasura Migrate Error - cannot continue due to inconsistent ...
I'm trying to do a migration from data on Hasura cloud to a DigitalOcean droplet. The I'm following the migration guide here exactly: ......
Read more >
Upgrading to Hasura migrations config v3
As we are now applying metadata before migrations, your metadata might be in an inconsistent state after the initial metadata apply till the...
Read more >
Managing Metadata | Hasura GraphQL Docs
Reloading may result in an inconsistent metadata status. You may need to resolve all inconsistent objects manually or delete them.
Read more >
Migrations & Metadata Setup | Hasura GraphQL Docs
This command will apply Migrations and Metadata on the new Hasura instance and make sure that the Metadata is consistent with the underlying...
Read more >
Migrating from Hasura v1.3 to v2.0
With support for multiple databases, you are no more constrained in connecting ... In Hasura Cloud, the metadata database is provisioned and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found