Upgraded metabase container to 0.42 and migrations fail

Hey, so after log4j I took Metabase down on our Kubernetes cluster and have just recently brought it back up - version 0.42 - as the Helm chart is no longer supported and I had to build a deployment manifest manually so the task fell to the side a bit.

When the container starts now, it runs through its startup sequence until it hits the migrations, then crashes with errors like this:
2022-02-21 12:35:26,628 ERROR changelog.ChangeSet :: Change Set migrations/000_migrations.yaml::187::camsaul failed. Error: ERROR: constraint "fk_session_ref_user_id" of relation "core_session" does not exist [Failed SQL: ALTER TABLE public.core_session DROP CONSTRAINT fk_session_ref_user_id]

Can anyone help me work out what's going on here? Do I need to migrate through some other intermediate versions before running 0.42?

Thank you!

Hi @jamsome

Which version of Metabase were you running?
If you are using Kubernetes, then only a single instance should be running during upgrades.

The changeset is from 0.36.0 and was dropping a constraint that was added during the initial creation of the application database, so something is telling me that you have a corruption in your application database.
For reference: https://github.com/metabase/metabase/blob/master/resources/migrations/000_migrations.yaml#L6828-L6835

So the workaround is to create the constraint manually, then try starting Metabase again.

Thanks! We were on 0.33.2, so quite old at that point. Would it be better to run 0.34 or something, then try again?

@jamsome It wouldn't make a difference - you wouldn't be able to get past 0.36.0 until you've manually added the constraint that must have been removed manually at some point or there has been upgrade errors in the past, which perhaps went unnoticed.

Got it. Thanks