Changing user email address in Gitlab using rails console

For reasons that will remain unspoken, Active directory that Gitlab authenticates against changed its name. After gitlab.rb was adjusted to reflect the change, another issue popped up. It was simply impossible to change the email addresses of the users. Thankfully, there is a solution, which I shamelessly stole and replicated here for my own reference.

[root@gitlab-1 gitlab]# gitlab-rails console
 GitLab:       13.0.0 (6743e883eae) FOSS
 GitLab Shell: 13.2.0
 PostgreSQL:   11.7
Loading production environment (Rails 6.0.3)
irb(main):001:0> user = User.find_by_email("")
=> #<User id:4 @old_email>
=> ""
irb(main):003:0> = ""
=> ""
=> true

That’s it.