# مشكلة في الترقية: قيمة المفتاح المكررة تنتهك قيد التفرد

**URL:** https://meta.discourse.org/t/problem-in-upgrade-duplicate-key-value-violates-unique-constraint/256826
**Category:** Self-hosting
**Created:** [2 مارس 2023، 2:32م UTC](https://meta.discourse.org/t/problem-in-upgrade-duplicate-key-value-violates-unique-constraint/256826 "2023-03-02T14:32:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Arta\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arta_s/32/537495_2.png) [@Arta\_S](https://meta.discourse.org/u/Arta_S)
#### Post date: [2 مارس 2023، 2:32م UTC](https://meta.discourse.org/t/problem-in-upgrade-duplicate-key-value-violates-unique-constraint/256826/1 "2023-03-02T14:32:45Z")

</div>

مرحباً،

لقد استخدمت للتو أداة الترقية لترقية نسخة discourse الخاصة بي. الغريب أن المنتدى معطل الآن. عندما حاولت إعادة البناء باستخدام سطر الأوامر، أحصل على هذا الخطأ:

`duplicate key value violates unique constraint "index_tags_on_lower_name"`

يتكرر هذا الخطأ عدة مرات في السجل، لذا أعتقد أنه يتعلق به.

هنا السجلات الكاملة:  
[https://paste.apps.7ho.st/dezomakasu.sql](https://paste.apps.7ho.st/dezomakasu.sql) (هذا جزء من السجلات، ولكن [هنا](https://paste.apps.7ho.st/sadoqetohu.yaml) السجل الكامل)

هل يمكن لأي شخص مساعدتي؟ لقد قمت أيضًا باستعادة ملف نسخة احتياطية من 7 ساعات قبل حدوث هذه المشكلة، ولكن لا يزال نفس الخطأ يحدث عند الترقية.

شكراً لك.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2 مارس 2023، 2:56م UTC](https://meta.discourse.org/t/problem-in-upgrade-duplicate-key-value-violates-unique-constraint/256826/2 "2023-03-02T14:56:16Z")

</div>

ستحتاج إلى إعادة تسمية بعض هذه العلامات، أعتقد. لا يفترض أن يحدث ذلك، ولكنه حدث.

ستقوم بتشغيل الحاوية القديمة، والقيام بشيء مثل:

```plaintext
./launcher start app
./launcher enter app
rails c
tags=Tag.where("name like '%ووکامرس%'")
ntag1=tags[1]
ntag1.name='bad1'
ntag1.save

```

وهكذا بالنسبة للآخرين (ربما هناك 3 فقط؟).

---

<div class="post-metadata">

### Author: ![Arta\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arta_s/32/537495_2.png) [@Arta\_S](https://meta.discourse.org/u/Arta_S)
#### Post date: [2 مارس 2023، 4:06م UTC](https://meta.discourse.org/t/problem-in-upgrade-duplicate-key-value-violates-unique-constraint/256826/3 "2023-03-02T16:06:03Z")

</div>

هل يجب أن أستبدل المكان الذي يوجد فيه الرقم بمعرف العلامة؟

هذا ما أحصل عليه حتى الآن `tags=Tag.where("name like '%ووکامرس%'")`

```plaintext
root@Seven-Forums-app:/var/www/discourse# rails c
[1] pry(main)> tags=Tag.where("name like '%ووکامرس%'")
=> [#<Tag:0x00007f0cef631638
  id: 26,
  name: "ووکامرس",
  created_at: Fri, 27 Jul 2018 07:05:01.048694000 UTC +00:00,
  updated_at: Fri, 27 Jul 2018 07:05:01.048694000 UTC +00:00,
  pm_topic_count: 0,
  target_tag_id: nil,
  description: nil>,
 #<Tag:0x00007f0cef61bfb8
  id: 108,
  name: "حمل-و-نقل-ووکامرس",
  created_at: Thu, 16 May 2019 10:12:19.073070000 UTC +00:00,
  updated_at: Thu, 16 May 2019 10:12:19.073070000 UTC +00:00,
  pm_topic_count: 0,
  target_tag_id: nil,
  description: nil>,
 #<Tag:0x00007f0cef61bef0
  id: 312,
  name: "ووکامرس",
  created_at: Sat, 23 Jan 2021 12:56:26.583839000 UTC +00:00,
  updated_at: Sat, 23 Jan 2021 12:56:26.583839000 UTC +00:00,
  pm_topic_count: 0,
  target_tag_id: nil,
  description: nil>,
 #<Tag:0x00007f0cef61bdd8
  id: 317,
  name: "مشکل-ووکامرس",
  created_at: Wed, 17 Feb 2021 20:32:41.416170000 UTC +00:00,
  updated_at: Wed, 17 Feb 2021 20:32:41.416170000 UTC +00:00,
  pm_topic_count: 0,
  target_tag_id: nil,
  description: nil>]

```
