18.5.3 to 18.6.1 ERROR: relation "index_merge_requests_on_assignee_id" does not exist

Problem to solve

I tried to upgrade two GitLab instances (CE and EE) from 18.5.3 to 18.6.1. The upgrade fails on both with the following error:

G::UndefinedTable: ERROR: relation “index_merge_requests_on_assignee_id” does not exist
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers/v2.rb:221:in rename_index_with_schema' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers/swapping.rb:42:in swap_indexes’
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20251016010314_swap_columns_for_merge_requests_bigint_conversion_stage_one.rb:62:in block (2 levels) in swap' /opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20251016010314_swap_columns_for_merge_requests_bigint_conversion_stage_one.rb:60:in each’
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20251016010314_swap_columns_for_merge_requests_bigint_conversion_stage_one.rb:60:in block in swap' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:123:in run_block’
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:134:in `block in run_block_with_lock_timeout’
[…]

First, I tried to upgrade directly from 18.5.2 to 18.6.1, then via the intermediate step to 18.5.3, but that didn’t help.

In the database, I can see that the entry does exist:

sudo gitlab-psql

psql (16.10)
Type “help” for help.

gitlabhq_production=# SELECT indexname, tablename
gitlabhq_production-# FROM pg_indexes
gitlabhq_production-# WHERE tablename=‘merge_requests’ AND indexname=‘index_merge_requests_on_assignee_id’;
indexname | tablename
-------------------------------------±---------------
index_merge_requests_on_assignee_id | merge_requests

Configuration

System information
System:         Debian 11
Current User:   git
Using RVM:      no
Ruby Version:   3.2.8
Gem Version:    3.7.1
Bundler Version:2.7.1
Rake Version:   13.0.6
Redis Version:  7.2.11
Sidekiq Version:7.3.9
Go Version:     unknown

GitLab information
Version:        18.5.3
Revision:       674bb93a1bf
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     16.10
URL:            http s://mydomain
HTTP Clone URL: http s://mydomain/some-group/some-project.git
SSH Clone URL:  git@mydomain:some-group/some-project.git
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers: github, saml

GitLab Shell
Version:        14.45.3
Repository storages:

default:      unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell

Gitaly

default Address:      unix:/var/opt/gitlab/gitaly/gitaly.socket

default Version:      18.5.3

default Git Version:  2.50.1Versions

:check_box_with_check: Self-managed, was 18.5.3-ce.0, new version 18.6.1-ce.0, via apt

I searched the forum and tried my search engines. There is one case with a possibly similar issue:
“18.5.2 to 18.6.1 error: no partition of relation “project_daily_statistics_b8088ecbd2” found for row”

I’m hesitant to make any changes directly in the database.
Does anyone have any advice?