Upgrade fails on duplicate key error ("index post hotlinked media on post id and url md5")

On my development instance it does successfully migrate the database, but if I restore a backup from 2022-04-27-153103-v20220407195246.tar.gz it fails:

                                                                                [361/9020]
Migrating the database...                                                                               EXCEPTION: /home/pfaffman/src/discourse-repos/discourse/lib/discourse.rb:126:in `exec': Failed to migrat
e database.
Ignoring /home/pfaffman/src/discourse-repos/discourse/db/schema_cache.yml because it has expired. The cu
rrent schema version is 20220407195246, but the one in the schema cache file is 20220428094027.
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

followed by some more of that with some of these:

ActiveRecord::StatementInvalid: PG::DuplicateObject: ERROR:  type "hotlinked_media_status" already exist
1 Like