Upgrade: missing constrain fk_query_table_analysis_id error

I am trying to upgrade metabase, and when I try to do it, the migrations are failing consistently with this error.

Caused by: org.postgresql.util.PSQLException: ERROR: constraint "fk_query_table_analysis_id" of relation "query_table" does not exist

The last time I touched metabase was in September of last year, when I did another upgrade. My guess is that the database got in some bad state.

Any known way to solve this?

Edit: I found that the migration giving us problems is

Migration failed for changeset migrations/056_update_migrations.yaml::v56.2025-06-06T20:11:53::nvoxland:

What version of Metabase are you upgrading from and to?

55.1 to 56.1

I would upgrade to 55.19 first, then upgrade to 56.19. There was a migration issue specifically related to a backported migration between 55 and 56 at the migration version stamp you posted.

Let me try that then. Thanks so much for the info!