'Gitlab CE 500 error after upgrade / downgrade

I have a Gitlab CE server version 13.10 which was found updated by mistake during a system update to a version 14.8.

With these version, i get a 500 error for all pages.

So I downgraded to version 13.10.5 and I was able to use my Gitlab server again.

However, wanting to create a new group I again had a 500 error:

Started GET "/groups/new" for 62.34.67.75 at 2022-04-19 17:23:00 +0200
Processing by GroupsController#new as HTML
Completed 500 Internal Server Error in 78ms (ActiveRecord: 4.2ms | Elasticsearch: 0.0ms | Allocations: 27029)
  
ActionView::Template::Error (PG::UndefinedTable: ERROR:  relation "services" does not exist
LINE 8:  WHERE a.attrelid = '"services"'::regclass

Apparently this error seems to be database related.

I tried to upgrade one version up by installing version 13.11.7 and again all pages lead to a 500 error with the same error as above.

any help would be appreciated.

UPDATE After searching in Google it seem's that the integrations table was renamed to services: https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/post_migrate/20210621223242_finalize_rename_services_to_integrations.rb

After taking a look to database schema on my server the integrations is still existing.

So it's like database is still in a ahead version and database donwngrade not ok.



Solution 1:[1]

I solve this error by using gitlab-psql to execute this query:

ALTER TABLE Integrations RENAME TO Services;

By renaming the Integrations table to services the problem disappear.

Solution 2:[2]

You cannot update directly to 14.8 from 13.10 otherwise you will be missing certain database migrations. You are likely to discover many more features of GitLab will be broken in unexpected ways if you skip versions in the upgrade path.

You must follow the upgrade path. Meaning in your case, you should upgrade first to 13.12.15 then to 14.0.12 then to 14.x.y (e.g. 14.8). Also be sure to let all background migrations complete and pay attention to version specific notes (especially in 14.0) before moving onto the next version.

The problem you are experiencing may be fixable by running the database operations manually, but this is not recommended. The best option is to follow the upgrade path to make sure all migrations happen correctly and in the correct order.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2