root@ehealthforum-nz-syd01-web-only:/var/www/discourse# discourse remap draft.ehealthforum.nzehealthforum.nz
Rewriting all occurrences of draft.ehealthforum.nz to ehealthforum.nz
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)
YES
Error: ERROR: duplicate key value violates unique constraint “index_post_hotlinked_media_on_post_id_and_url_md5”
DETAIL: Key (post_id, md5(url::text))=(80591,66a0d020b208dc9f8452a5eb9617f6bc) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.
While a bit obscure, this is likely to trip up others. It is similar to this, but has occurred on remapping instead.
It seems to occur on posts with Oneboxes. Of which there are many!
I’ve got a workaround which has fixed the immediate problem for me. I’ve set up a CNAME record from the ‘old’ URL (which happens to be a subdomain of my new root), and validated it with Let’s Encrypt as per this guide:
Now the broken links at least get the user to the correct place!
I’m a little unclear why I had the problem. An automated remap seemed to occur the first time I restored my backup on my staging instance (before making it live). Subsequent restores didn’t trigger a remap despite the instance URL changing - this confused me, and has let to this current problem.