这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@scriptonist
Copy link
Contributor

Description

The error messages thrown during a failed metadata apply were not useful, this PR attempts to improve it.

Changelog

  • CHANGELOG.md is updated with user-facing content relevant to this PR. If no changelog is required, then add the no-changelog-required label.

Affected components

  • CLI

Related Issues

close #5513

Solution and Design

Following is a comparison of errors thrown before and after the change.
Before:

FATA[0004] failed to apply metadata: cannot apply metadata on the database: [unexpected] cannot continue due to inconsistent metadata ($.args[1].args)
offending object:

{
  "cron_triggers": [],
  "tables": [
    {
      "array_relationships": [
        {
          "name": "users",
          "using": {
            "foreign_key_constraint_on": {
              "column": "role",
              "table": {
                "name": "users",
                "schema": "public"
              }
            }
          }
        }
      ],
      "is_enum": true,
      "table": {
        "name": "roles",
        "schema": "public"
      }
    },
    {
      "object_relationships": [
        {
          "name": "roleByRole",
          "using": {
            "foreign_key_constraint_on": "role"
          }
        }
      ],
      "table": {
        "name": "users",
        "schema": "public"
      }
    }
  ],
  "version": 2
}
[] :
[] :
[] :

After:

FATA[0004] failed to apply metadata: cannot apply metadata on the database: [unexpected] cannot continue due to inconsistent metadata ($.args[1].args)

reason: the table "roles" cannot be used as an enum because the table must have at least one row
type: table
definition:
{
  "name": "roles",
  "schema": "public"
}

reason: table "roles" does not exist
type: array_relation
definition:
{
  "comment": null,
  "name": "users",
  "table": {
    "name": "roles",
    "schema": "public"
  },
  "using": {
    "foreign_key_constraint_on": {
      "column": "role",
      "table": {
        "name": "users",
        "schema": "public"
      }
    }
  }
}

reason: table "roles" is not tracked
type: object_relation
definition:
{
  "comment": null,
  "name": "roleByRole",
  "table": {
    "name": "users",
    "schema": "public"
  },
  "using": {
    "foreign_key_constraint_on": "role"
  }
}

@hasura-bot
Copy link
Contributor

Review app for commit 7508757 deployed to Heroku: https://hge-ci-pull-5548.herokuapp.com
Docker image for server: hasura/graphql-engine:pull5548-75087576

Copy link
Contributor

@tirumaraiselvan tirumaraiselvan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A changelog is definitely worth it :)

@hasura-bot
Copy link
Contributor

Review app for commit f6f5994 deployed to Heroku: https://hge-ci-pull-5548.herokuapp.com
Docker image for server: hasura/graphql-engine:pull5548-f6f59943

@scriptonist scriptonist marked this pull request as ready for review August 8, 2020 04:58
@scriptonist scriptonist requested review from a team as code owners August 8, 2020 04:58
Copy link
Contributor

@tirumaraiselvan tirumaraiselvan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog

Copy link
Member

@shahidhk shahidhk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shahidhk shahidhk changed the title cli: improve error messages during a metadata apply (close #5513) cli: improve error messages for metadata apply (close #5513) Aug 10, 2020
@shahidhk shahidhk merged commit 2592236 into hasura:master Aug 10, 2020
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-5548.herokuapp.com is deleted

stevefan1999-personal pushed a commit to stevefan1999-personal/graphql-engine that referenced this pull request Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/cli Related to CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hasura Migrate Error - cannot continue due to inconsistent metadata

4 participants