Migration conflict after upgrading from metadata v2 to v3

Author: raphaeltmCreated Mar 1, 2022Updated Sep 23, 2026
Labelsk/bugc/clic/migrationst/product-platform

Version Information

Server Version: v2.2.1.cli-migrations-v3 Docker CLI Version (for CLI related issue): v2.2.1

Environment

Managed DigitalOcean Kubernetes Docker image from v2.2.1.cli-migrations-v3

What is the expected behaviour?

After running the upgrade steps from https://hasura.io/docs/latest/graphql/core/migrations/upgrade-v3.html#step-1-upgrade-to-the-latest-cli I expected the upgrade to work locally and when deployed to staging/prod.

Keywords

Migrations, Metadata, Postgres

What is the current behaviour?

I ran the steps from https://hasura.io/docs/latest/graphql/core/migrations/upgrade-v3.html#step-1-upgrade-to-the-latest-cli and while everything seemed to work fine locally, I ran into some issues when deploying to a staging env. I am still using HASURA_GRAPHQL_DATABASE_URL, but when I ran hasura scripts update-project-v3 it seems that the development db url was hardcoded into config files. I figured that out and managed to move back to the environment variable.

Once the DB was properly connected using the environment variable, the deployment started to throw errors about migrations not running. A quick glance showed me that Hasura was trying to run all migrations, from the very first one. I'm having a lot more trouble figuring out how to debug and prevent this behaviour. Looking at hdb_catalog.schema_migrations, I can see that all migrations are there, so I'm not sure what the issue is.

How to reproduce the issue?

Not sure. I don't have the time to replicate everything.

Screenshots or Screencast


Please provide any traces or logs that could help here.

ERRO skipping applying migrations on database default, encountered:                                                             
{
  "internal": {
    "statement": "<A BUNCH OF SQL FROM AN EXISTING DATABASE, PRE-HASURA>"
    "prepared": false,
    "error": {
      "exec_status": "FatalError",
      "hint": null,
      "message": "relation \"table_name\" already exists",
      "status_code": "42P07",
      "description": null
    },
    "arguments": []
  },
  "path": "$",
  "error": "query execution failed",
  "code": "postgres-error"
} 

Any possible solutions?

Not sure. The switch to v3 from v2 is preventing hasura from recognizing the migrations logged in the hdb schema. Why exactly, I'm not sure.

Can you identify the location in the source code where the problem exists?

Nope.

If the bug is confirmed, would you be willing to submit a PR?

I wouldn't know where to start (and I don't know Haskell)