ERROR: sequence must have same owner as table it is linked to

I ran sudo gitlab-rake db:migration and got the following error:

[2022-11-07T13:49:12-05:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: rails_migration[gitlab-rails] (gitlab::database_migrations line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: bash[migrate gitlab-rails database] (gitlab::database_migrations line 18) had an error: Mixlib::ShellOut::ShellCommandFailed: Command execution failed. STDOUT/STDERR suppressed for sensitive resource
[diana@nflk-ird gitlab]$ sudo gitlab-rake db:migrate
main: == 20220902204048 MoveSecurityFindingsTableToGitlabPartitionsDynamicSchema: migrating
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("LOCK TABLE vulnerability_scanners, security_scans, security_findings IN ACCESS EXCLUSIVE MODE\n")
main:    -> 0.0006s
main: -- execute("SELECT\n  pg_get_constraintdef(pg_catalog.pg_constraint.oid)\nFROM\n  pg_catalog.pg_constraint\nINNER JOIN pg_class ON pg_class.oid = pg_catalog.pg_constraint.conrelid\nWHERE\n  conname = 'check_partition_number' AND\n  pg_class.relname = 'security_findings'\n")
main:    -> 0.0052s
main: -- execute("ALTER TABLE security_findings RENAME TO security_findings_1;\n")
main:    -> 0.0006s
main: -- execute("ALTER INDEX security_findings_pkey RENAME TO security_findings_1_pkey;\n")
main:    -> 0.0004s
main: -- execute("CREATE TABLE security_findings (\n  LIKE security_findings_1 INCLUDING ALL\n) PARTITION BY LIST (partition_number);\n")
main:    -> 0.0032s
main: -- execute("ALTER SEQUENCE security_findings_id_seq OWNED BY public.security_findings.id;\n")
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

PG::ObjectNotInPrerequisiteState: ERROR:  sequence must have same owner as table it is linked to

Another post with a similar issue mentioned changing the owners so they match. However, upon checking the database, they already have the same user.

gitlabhq_production=#  select * from pg_sequences where sequencename='security_findings_id_seq';
 schemaname |       sequencename       | sequenceowner | data_type | start_value | min_value |      max_value      | increment_by | cycle | cache_size | last_value
------------+--------------------------+---------------+-----------+-------------+-----------+---------------------+--------------+-------+------------+------------
 public     | security_findings_id_seq | gitlab-psql   | bigint    |           1 |         1 | 9223372036854775807 |            1 | f     |          1 |
(1 row)
gitlabhq_production=# select * from pg_tables where tablename='security_findings';
 schemaname |     tablename     | tableowner  | tablespace | hasindexes | hasrules | hastriggers | rowsecurity
------------+-------------------+-------------+------------+------------+----------+-------------+-------------
 public     | security_findings | gitlab-psql |            | t          | f        | t           | f
(1 row)

I’m unsure how to proceed from here.

I am on version 15.4 running on RedHat 7.

So changing username to gitlab-psql (from default) in config led to authentication failure. I changed the owner of both table & sequence to gitlab, and that got me past the database migration error. I’m still figuring things out around Gitlab though as the person who installed is no longer with us. I’m wondering if the default postgres username used to be gitlab-psql? All of the other database objects are owned by this user.