GitLab upgrade from 14.3.6 to 14.9.5 failed at '20210301200959_init_schema.rb' migration task

Hi everyone,

I would like to upgrade gitlab-ce from 13.6.2 to 15.9.2 using the regular upgrade path.
My setup is a VM running CentOS 8.
I use Ansible role from Galaxy (Ansible Galaxy) and it works very well.

The problem came with migration from 14.3.6 to 14.9.5.
More precisely, it came with migration from 14.6.7 to 14.7.0. I used snapshots to rollback the VM to a previous state to know the version having a problem.

The command “gitlab-ctl reconfigure” (as well as “gitlab-rake db:migrate”) gives the following error:

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateSchema: ERROR:  schema "gitlab_partitions_dynamic" already exists
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20210301200959_init_schema.rb:7:in `up'

Why does the migration process want to run the init_structure.sql file (called by /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20210301200959_init_schema.rb)?
Is there a way to bypass this step?
I also saw this post: https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5952
I dropped the 2 schemas and the view but I encounter other errors later (duplicate function set_has_external_issue_tracker).

I even tried to update this SQL script to ignore existing objects, like this:

sed -i "s/CREATE TABLE /CREATE TABLE IF NOT EXISTS /g" init_structure.sql
sed -i "s/CREATE SEQUENCE /CREATE SEQUENCE IF NOT EXISTS /g" init_structure.sql
sed -i "s/CREATE VIEW /CREATE OR REPLACE VIEW /g" init_structure.sql
sed -i "s/CREATE FUNCTION /CREATE OR REPLACE FUNCTION /g" init_structure.sql

but it doesn’t work due to other errors (multiple primary keys not allowed).
Now I’m stuck on this version 14.6.7 and I can’t go further.

Did anyone have an idea about what to do?
Thank you.

Hi,

It’s OK now, I forgot to run gitlab-rake db:migrate between two version upgrades…