ERROR: column "id" does not exist

This error shows up after a “forced migration” of my gitlab install – the server it had been running on was having a hard drive failure, and wasn’t stable enough to backup using gitlab-rake, so I instead copied over the filesystem directories and config files to the new server manually.

Any users and repos that existed before this migration work just fine as expected. But new users who have signed up since the migration get hit with a 500. The error in production.log shows details:

ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR:  column "id" does not exist
LINE 1: SELECT "id", "project_authorizations"."project_id", "project...
               ^
: SELECT "id", "project_authorizations"."project_id", "project_authorizations"."access_level" FROM "project_authorizations" WHERE "project_authorizations"."user_id" = $1):
  app/services/users/refresh_authorized_projects_service.rb:97:in `current_authorizations_per_project'
  app/services/users/refresh_authorized_projects_service.rb:31:in `execute'
  app/models/user.rb:446:in `refresh_authorized_projects'
  app/models/user.rb:460:in `authorized_projects'
  app/controllers/dashboard/projects_controller.rb:7:in `index'
  app/controllers/root_controller.rb:13:in `index'
  lib/gitlab/middleware/multipart.rb:93:in `call'
  lib/gitlab/request_profiler/middleware.rb:15:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'

Install details:

$ sudo gitlab-rake gitlab:env:info

System information
System:         Ubuntu 16.04
Current User:   git
Using RVM:      no
Ruby Version:   2.3.3p222
Gem Version:    2.6.6
Bundler Version:1.13.7
Rake Version:   10.5.0
Sidekiq Version:4.2.7

GitLab information
Version:        8.15.5
Revision:       8350cb1
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     postgresql
URL:            https://git.XXX.com
HTTP Clone URL: https://git.XXX.com/some-group/some-project.git
SSH Clone URL:  git@git.XXX.com:some-group/some-project.git
Using LDAP:     no
Using Omniauth: no

GitLab Shell
Version:        4.1.1
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
Hooks:          /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git:            /opt/gitlab/embedded/bin/git

Upgrading to 8.17.8 fixed it.

1 Like