The database migration failed for me when upgrading to GitLab v15.4 with the error:
ActiveRecord::StatementInvalid: PG::ObjectNotInPrerequisiteState: ERROR: sequence must have same owner as table it is linked to
This was resolved by creating a new user in PostgreSQL that was a member of the user who owned the database and also the user that GitLab is using to access the database, connecting as that user.
And then running the REASSIGN OWNED BY badowneruser TO gitlab_user
Just hopes this helps someone else out there.
In my case the database was owned by the user I used to import it when upgrading to PostgreSQL 13 from 11 and it just never caused an issue until now.