안녕하세요,
Change the domain name or rename your Discourse 을 참고하여 Discourse 도메인 이름을 변경하려고 했습니다. 명령어를 실행하기 전까지는 모든 것이 정상적으로 보였는데,
discourse remap talk.foo.com talk.bar.com
명령어를 실행한 후 다음과 같은 오류가 발생했습니다:
root@plop:/var/www/discourse# discourse remap plop.domain.fr forum.plop.fr
Rewriting all occurrences of plop.domain.fr to forum.plop.fr
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)
YES
backup_metadata=1
email_logs=991
javascript_caches=1
post_revisions=126
post_search_data=20
posts=782
stylesheet_cache=446
theme_settings=1
Error: ERROR: duplicate key value violates unique constraint "unique_post_links"
DETAIL: Key (topic_id, post_id, url)=(274, 455, http://forum.plop.fr) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.
여기 보고된 오류와 유사해 보였지만, 약간 달랐습니다. 새로운 도메인이 포럼에서 논의되었기 때문에 발생하는 버그라고 추측합니다.
이를 해결하기 위해 rake를 통해 db:exec와 같은 명령을 실행하여 DB 명령을 강제하는 방법을 찾지 못했습니다. 그래서 postgres를 통해 직접 처리했습니다:
- 데이터베이스에 연결:
# cd /var/discourse/
# ./launcher enter app
# su - postgres
$ psql
postgres=# \c discourse
- 테이블에서 URL을 직접 교체 시도
discourse=# update topic_links set url=REPLACE(url, 'plop.domain.fr', 'forum.plop.fr');
ERROR: duplicate key value violates unique constraint "unique_post_links"
DETAIL: Key (topic_id, post_id, url)=(274, 455, http://forum.plop.fr) already exists.
- 오류 발생 시: 유일성을 깨뜨리지 않는 교체(예:
forum.plop.fr/)를 강제:
discourse=# update topic_links set url=REPLACE(url, 'plop.domain.fr', 'forum.plop.fr/') where topic_id=274;
- 2단계가 오류 없이 완료될 때까지 3단계를 반복합니다. 그런 다음 pg에서 나옵니다.
discourse=# update topic_links set url=REPLACE(url, 'plop.domain.fr', 'forum.plop.fr');
UPDATE 1349
discourse=#
\q
- remap과 rebake를 다시 실행:
$ exit
# discourse remap plop.domain.fr forum.plop.fr
forum.plop.fr/t/topic/274등을 방문하여 문제의 주제(내용이 일관되지 않을 수 있음)를 수동으로 확인하고 수정합니다.