1

I want to import the hasura metadata from CI/CD pipeline. I have tried using cli-migrations-v2 image. I am getting following error when it tries to import the metadata.

 ... level=fatal msg="failed to apply metadata: cannot apply metadata on the database: [parse-failed] expected 1 or 2, encountered 0 ($[1].version)"

The command I am using is as follows-

sudo docker run -d -p 8080:8080 --net=host --name=hasura-metadata-v2 -v /home/hasura_migrations/metadata:/hasura-metadata     -e HASURA_GRAPHQL_DATABASE_URL=postgres://hasurauser:hasurauser@localhost:5432/new_db_migration        -e HASURA_GRAPHQL_ENABLE_CONSOLE=true   hasura/graphql-engine:v1.2.1.cli-migrations-v2

It is same as the one mentioned in the hasura documentation https://hasura.io/docs/1.0/graphql/manual/migrations/advanced/auto-apply-migrations.html#auto-apply-migrations

S.K
  • 480
  • 1
  • 4
  • 19

1 Answers1

0

It seems that when you upgraded your project to use config-v2, a version.yaml was created in /home/hasura_migrations/metadata path. The version in your file seems to be 0. Just update it to 2 to use config-v2 and try again.

Expected content:

~$ cat /home/hasura_migrations/metadata/version.yaml
version: 2

It worked for me.