Howto fix the Gitlab upgrade Error PG::DuplicateColumn: ERROR: column "encrypted_token" of relation "chat_names" already exists

Howto fix the Gitlab upgrade Error PG::DuplicateColumn: ERROR: column "encrypted_token" of relation "chat_names" already exists

Please contact us if anything is not clearly described, does not work, seems incorrect or if you require support.

While upgrading from the apt installed omnibus gitlab Version 16.6.4-ce.0 on Debian 12, I encountered the following error message:


PG::DuplicateColumn: ERROR:  column "encrypted_token" of relation "chat_names" already exists

Note that even though the apt upgrade failed, apt is displaying the target version to be installed already:


apt-cache policy gitlab-ce|head
gitlab-ce:
  Installed: 16.7.2-ce.0
  Candidate: 16.7.2-ce.0
  Version table:
 *** 16.7.2-ce.0 500
        500 https://packages.gitlab.com/gitlab/gitlab-ce/debian buster/main amd64 Packages
        100 /var/lib/dpkg/status
     16.7.0-ce.0 500
        500 https://packages.gitlab.com/gitlab/gitlab-ce/debian buster/main amd64 Packages
[...]

The following postgresql will adjust the column name as required:


gitlab-psql

gitlabhq_production=# ALTER TABLE chat_names RENAME COLUMN encrypted_token_iv TO encrypted_token_iv_old;
ALTER TABLE

gitlabhq_production=# ALTER TABLE chat_names RENAME COLUMN encrypted_token TO encrypted_token_old;
ALTER TABLE

gitlabhq_production=# exit

To continue the upgrade, use the following command:


apt -f install gitlab-ce

Questions? Requests? Suggestions?

We are looking forward to hearing from you!

Are you looking for
Linux Emergency Support,
Linux Consulting for Projects,
Linux Managed Hosting,
Qubes OS Consulting and Support or
Linux Trainings and Workshops?