Gitlab apt upgrade Error

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

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:


root@gitlab.server ~ # 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:


root@gitlab.server ~ # 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:


root@gitlab.server ~ # apt -f install gitlab-ce



Would you like to learn more about
Self-Hosting Gitlab on Debian?

Call us Today!

+49 30 / 629 318 76 | info@blunix.com
Encrypted Communication