# Discourse 설치 실패: ON CONFLICT DO NOTHING 오류

**URL:** https://meta.discourse.org/t/unable-to-install-discourse-question-answer-on-conflict-do-nothing/238128
**Category:** Self-hosting
**Tags:** post-voting
**Created:** [9월 5, 2022, 7:10오전 UTC](https://meta.discourse.org/t/unable-to-install-discourse-question-answer-on-conflict-do-nothing/238128 "2022-09-05T07:10:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![scavin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/scavin/32/115938_2.png) [@scavin](https://meta.discourse.org/u/scavin)
#### Post date: [9월 5, 2022, 7:10오전 UTC](https://meta.discourse.org/t/unable-to-install-discourse-question-answer-on-conflict-do-nothing/238128/1 "2022-09-05T07:10:52Z")

</div>

Discourse 질문 답변(Question Answer) 설치 실패

```plaintext
== 20211020062413 CreateQuestionAnswerVotes: migrating ========================
-- create_table(:question_answer_votes, {})
   -> 0.0478s
-- add_index(:question_answer_votes, [:post_id, :user_id], {:unique=>true})
   -> 0.0024s
-- execute("INSERT INTO question_answer_votes (post_id, user_id, created_at)\nSELECT\n X.post_id AS post_id,\n (X.value->>'user_id')::int AS user_id,\n (X.value->>'created_at')::timestamp AS created_at\nFROM (\n SELECT\n post_id,\n jsonb_array_elements(value::jsonb) AS value\n FROM post_custom_fields WHERE name = 'vote_history'\n) AS X\nWHERE (X.value->>'action') != 'destroy'\nORDER BY (X.value->>'created_at')::timestamp DESC\nON CONFLICT DO NOTHING\n")

I, [2022-09-05T08:36:29.418247 #1] INFO -- : Terminating async processes
I, [2022-09-05T08:36:29.418302 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 41
ds WHERE name = 'vote_history'\n) AS X\nWHERE (X.value->>'action') != 'destroy'\nORDER BY (X.value->>'created_at')::timestamp DESC\nON CONFLICT DO NOTHING\n")

I, [2022-09-05T08:36:29.418247 #1] INFO -- : Terminating async processes
I, [2022-09-05T08:36:29.418302 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 41
I, [2022-09-05T08:36:29.418383 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 102
2022-09-05 08:36:29.418 CST [41] LOG: received fast shutdown request
102:signal-handler (1662338189) Received SIGTERM scheduling shutdown...
2022-09-05 08:36:29.419 CST [41] LOG: aborting any active transactions
2022-09-05 08:36:29.422 CST [41] LOG: background worker "logical replication launcher" (PID 50) exited with exit code 1
2022-09-05 08:36:29.426 CST [45] LOG: shutting down
102:M 05 Sep 2022 08:36:29.437 # User requested shutdown...
102:M 05 Sep 2022 08:36:29.437 * Saving the final RDB snapshot before exiting.
2022-09-05 08:36:29.466 CST [41] LOG: database system is shut down
102:M 05 Sep 2022 08:36:29.896 * DB saved on disk
102:M 05 Sep 2022 08:36:29.896 # Redis is now ready to exit, bye bye...

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 790 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
**FAILED TO BOOTSTRAP** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
e3d5cb6cab0a78a5d9b12c2fb6f5dac60c4e1182509b163f1a4fbdf207578f04

```

Pavilion의 질문 답변(Question Answer) 플러그인을 설치했다가 오래전에 제거한 상태입니다.

---

<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: [9월 5, 2022, 7:13오전 UTC](https://meta.discourse.org/t/unable-to-install-discourse-question-answer-on-conflict-do-nothing/238128/2 "2022-09-05T07:13:21Z")

</div>

메시지에 적혀 있듯이…

> [@scavin](#):
>
> `위쪽으로 스크롤하여 이전 오류 메시지를 찾아보세요`

---

<div class="post-metadata">

### Author: ![scavin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/scavin/32/115938_2.png) [@scavin](https://meta.discourse.org/u/scavin)
#### Post date: [9월 5, 2022, 11:44오전 UTC](https://meta.discourse.org/t/unable-to-install-discourse-question-answer-on-conflict-do-nothing/238128/3 "2022-09-05T11:44:21Z")

</div>

죄송합니다. 전체 로그입니다:

[https://paste.ubuntu.com/p/pmQfNzSk3J/](https://paste.ubuntu.com/p/pmQfNzSk3J/)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [9월 5, 2022, 11:53오전 UTC](https://meta.discourse.org/t/unable-to-install-discourse-question-answer-on-conflict-do-nothing/238128/4 "2022-09-05T11:53:18Z")

</div>

‘vote\_history’ 필드에 문제가 있는 것으로 보입니다:

```plaintext
I, [2022-09-05T19:39:21.422820 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
2022-09-05 19:39:34.506 CST [819] discourse@discourse ERROR: cannot extract elements from a scalar
2022-09-05 19:39:34.506 CST [819] discourse@discourse STATEMENT: INSERT INTO question_answer_votes (post_id, user_id, created_at)
        SELECT
          X.post_id AS post_id,
          (X.value->>'user_id')::int AS user_id,
          (X.value->>'created_at')::timestamp AS created_at
        FROM (
          SELECT
            post_id,
            jsonb_array_elements(value::jsonb) AS value
          FROM post_custom_fields WHERE name = 'vote_history'
        ) AS X
        WHERE (X.value->>'action') != 'destroy'
        ORDER BY (X.value->>'created_at')::timestamp DESC
        ON CONFLICT DO NOTHING

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

```

최근 유사한 오류에 대한 보고가 하나 더 있었습니다 - [Bootstrap failed with exit code 1](https://meta.discourse.org/t/bootstrap-failed-with-exit-code-1/237270) 하지만 아직 해당 스레드에서 해결책이 게시되지 않았습니다.

이전에 Pavilion 플러그인을 설치했던 것과 충돌이 발생한 것일 수 있습니다. @Hifihedgehog, 당신의 사이트에도 이전에 해당 플러그인이 설치되어 있었나요?

---

<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: [9월 5, 2022, 11:53오전 UTC](https://meta.discourse.org/t/unable-to-install-discourse-question-answer-on-conflict-do-nothing/238128/5 "2022-09-05T11:53:51Z")

</div>

오류는 586번째 줄에서 발생했습니다.

스칼라에서 값을 가져올 수 없습니다(메모리 기준). 해당 부분 주변의 내용을 여기에 복사해 주세요. 마이그레이션의 문제인지, 아니면 급할 경우 데이터베이스에서 수정해야(또는 수정할 수 있는) 문제인지 명확하지 않습니다.

수정: 질문 답변을 제거하면 단기적으로 해결되는 것 같습니다.
