Upgrade from 18.8.4 to 18.9.0-ce fails with PG::DuplicateTable: ERROR: relation "virtual_registries_packages_maven_cache_local_ent ries_iid_seq" already exists

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

Upgrade from 18.8.4 to 18.9.0-ce fails with PG::DuplicateTable: ERROR: relation "virtual_registries_packages_maven_cache_local_ent ries_iid_seq" already exists

Steps to reproduce

During Update I first encountered the constraint violation on gpg_key_subkeys. I fixed that after a rollback to 18.8.4 using:

gitlab-ctl stop puma
gitlab-ctl stop sidekiq
gitlab-rails dbconsole --database main
UPDATE gpg_key_subkeys 
SET user_id = gpg_keys.user_id FROM gpg_keys 
WHERE gpg_key_subkeys.gpg_key_id = gpg_keys.id 
AND gpg_key_subkeys.user_id IS NULL;

Then running the update again, it fails with:

ain: == 20260115101000 CreateSeqOnVirtualRegistriesPackagesMavenCacheLocalEntries: mig
rating 
main: -- quote_table_name(:virtual_registries_packages_maven_cache_local_entries_iid_se
q)
main:    -> 0.0002s
main: -- quote_table_name(:virtual_registries_packages_maven_cache_local_entries)
main:    -> 0.0001s
main: -- quote_column_name(:iid)
main:    -> 0.0001s
main: -- quote(:virtual_registries_packages_maven_cache_local_entries_iid_seq)
main:    -> 0.0002s
main: -- execute("CREATE SEQUENCE \"virtual_registries_packages_maven_cache_local_entri
es_iid_seq\" START 1;\nALTER TABLE \"virtual_registries_packages_maven_cache_local_entr
ies\" ALTER COLUMN \"iid\" SET DEFAULT nextval('virtual_registries_packages_maven_cache
_local_entries_iid_seq')\n")
main: == [advisory_lock_connection] object_id: 67320, pg_backend_pid: 2819295
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR:  relation "virtual_registries_packages_maven_cache_local_ent
ries_iid_seq" already exists

Where do I go from here?

Edited by 🤖 GitLab Bot 🤖