# فشل إعادة التعيين عند تغيير مجال الخطاب

**URL:** https://meta.discourse.org/t/remap-failure-when-changing-discourse-domain/306470
**Category:** Self-hosting
**Created:** [2 مايو 2024، 1:10م UTC](https://meta.discourse.org/t/remap-failure-when-changing-discourse-domain/306470 "2024-05-02T13:10:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fpoulain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fpoulain/32/251282_2.png) [@fpoulain](https://meta.discourse.org/u/fpoulain)
#### Post date: [2 مايو 2024، 1:10م UTC](https://meta.discourse.org/t/remap-failure-when-changing-discourse-domain/306470/1 "2024-05-02T13:10:13Z")

</div>

مرحباً،  
لقد حاولت تغيير اسم نطاق discourse، متبعًا [Change the domain name or rename your Discourse](https://meta.discourse.org/t/change-the-domain-name-or-rename-your-discourse/16098). بدت الأمور صحيحة حتى قمت بتشغيل الأمر

```plaintext
discourse remap talk.foo.com talk.bar.com

```

حصلت على ما يلي:

```plaintext
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.

```

بدا الأمر وكأنه يشبه الخطأ المبلغ عنه [هنا](https://meta.discourse.org/t/rebake-fails-when-changing-the-subdomain-name-only/128104)، ولكنه كان مختلفًا قليلاً. أعتقد أن الخطأ يتعلق بحقيقة أن النطاق الجديد قد تمت مناقشته في المنتدى.

للتغلب على ذلك، لم أتمكن من تشغيل شيء مثل `db:exec` لفرض أوامر قاعدة البيانات عبر `rake`. لذلك قمت بذلك مباشرة عبر postgres:

1. الاتصال بقاعدة البيانات:

```plaintext
# cd /var/discourse/
# ./launcher enter app
# su - postgres
$ psql
postgres=# \c discourse

```

1. محاولة استبدال عنوان URL مباشرة في الجدول

```plaintext
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.

```

1. عند حدوث خطأ: فرض استبدال لا يكسر التفرد، على سبيل المثال `forum.plop.fr/`:

```plaintext
discourse=# update topic_links set url=REPLACE(url, 'plop.domain.fr', 'forum.plop.fr/') where topic_id=274;

```

1. كرر 3. حتى ينتهي 2. بدون خطأ. ثم اخرج من pg.

```plaintext
discourse=# update topic_links set url=REPLACE(url, 'plop.domain.fr', 'forum.plop.fr');
UPDATE 1349
discourse=#
\q

```

1. إعادة تشغيل remap و rebake:

```plaintext
$ exit
# discourse remap plop.domain.fr forum.plop.fr

```

1. تحقق يدويًا وصحح المواضيع الإشكالية (التي قد يكون محتواها غير متسق)، عن طريق زيارة `forum.plop.fr/t/topic/274` وغيرها.

---

<div class="post-metadata">

### Author: ![fpoulain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fpoulain/32/251282_2.png) [@fpoulain](https://meta.discourse.org/u/fpoulain)
#### Post date: [2 مايو 2024، 1:15م UTC](https://meta.discourse.org/t/remap-failure-when-changing-discourse-domain/306470/2 "2024-05-02T13:15:24Z")

</div>

> [@fpoulain](#):
>
> `discourse remap talk.foo.com talk.bar.com`

إذا كنت أفهم المشكلة بشكل صحيح _بعد فوات الأوان_، فإن [doc](https://meta.discourse.org/t/change-the-domain-name-or-rename-your-discourse/16098) قد يقترح إزالة جميع الحالات القديمة لـ `talk.bar.com` قبل تشغيل هذا الأمر. يمكن القيام بذلك ببساطة عبر

```plaintext
discourse remap talk.bar.com talk.foo-or-bar-that-s-the-question.com

```

(لم أجرب.)
