مرحباً،
لقد حاولت تغيير اسم نطاق discourse، متبعًا Change the domain name or rename your 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.
بدا الأمر وكأنه يشبه الخطأ المبلغ عنه هنا، ولكنه كان مختلفًا قليلاً. أعتقد أن الخطأ يتعلق بحقيقة أن النطاق الجديد قد تمت مناقشته في المنتدى.
للتغلب على ذلك، لم أتمكن من تشغيل شيء مثل db:exec لفرض أوامر قاعدة البيانات عبر rake. لذلك قمت بذلك مباشرة عبر 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;
- كرر 3. حتى ينتهي 2. بدون خطأ. ثم اخرج من 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وغيرها.