v2.0.0-alpha.5: issue applying metadata to hasura cloud instance ("source with name \"default\" [does not exist/is inconsistent]")
See original GitHub issueHi 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 init
command - launch the local console with
hasura console
(at this stage, the local postgres DB is calleddefault
by default with apublic
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 thedatabase-name
matches with my local metadata/migration files, here is a screenshot of the cloud instance: -
it matches with local files names:
-
but still, when applying the local changes to the cloud instance I get the following error message:
Highly appreciate if someone can help, thank you very much.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
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.@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 themetadata/databases/databases.yaml
file gets updated with the following configand 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
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 namedefault
2 - event with that, I will have another error with metadata sayingHASURA_GRAPHQL_DATABASE_URL
does not exist on cloud instance, indeed, it is calledHEROKU_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?)