Ho recentemente copiato la cartella del database /shared dal nostro server di produzione a quello di staging (per far coincidere entrambi gli ambienti).
Ho notato che i link puntavano al dominio precedente, quindi ho seguito questa guida.
Eseguendo questo comando all’interno del container:
Riscrittura di tutte le occorrenze di forums.coretabs.net in discourse.coretabs.net
QUESTA OPERAZIONE RISCRIVERÀ I DATI, SEI SICURO (digita YES)
YES
Errore: ERRORE: valore di chiave duplicato viola il vincolo univoco "index_incoming_domains_on_name_and_https_and_port"
DETTAGLIO: La chiave (name, https, port)=(discourse.coretabs.net, t, 443) esiste già.
La rimappatura è stata applicata solo parzialmente a causa dell'errore sopra riportato. Si prega di rieseguire lo script.
Rewriting all occurences of forums.coretabs.net to discourse.coretabs.net
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)
YES
incoming_domains=1
incoming_referers=3
invites=1
javascript_caches=1
post_revisions=509
posts=84
single_sign_on_records=1099
theme_fields=4
topic_custom_fields=4
Error: ERROR: duplicate key value violates unique constraint "unique_post_links"
DETAIL: Key (topic_id, post_id, url)=(69, 212, https://discourse.coretabs.net/t/topic/365) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.
Googled "unique_post_links" and found that its table is called topic_links from the schema.sql
This time links are partial so I used a replace query:
DB.exec "update topic_links set url=REPLACE(url, 'discourse.coretabs.net', 'discourse-old.coretabs.net')"