업그레이드 실패: UniqueViolation: 중복된 키 값이 유니크 제약 조건 "data_explorer_queries_pkey"을 위반했습니다

오늘 최신 버전으로 업그레이드하는 동안 실패가 발생했습니다:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' 실행이 실패했으며 반환 값은 #<Process::Status: pid 3194 exit 1>입니다.
실패 위치: /pups/lib/pups/exec_command.rb:112:in `spawn'
파라미터 {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}로 실행이 실패했습니다.
590cf0611c566ea6df5f70ffdd2cec2359e84eaea29b7abcde77d56288a46370
** 부트스트랩 실패 ** 이전의 오류 메시지를 확인하려면 위로 스크롤하십시오. 오류가 하나 이상 있을 수 있습니다.

로그의 위쪽 부분:

Caused by:
PG::UniqueViolation: ERROR:  unique constraint "data_explorer_queries_pkey"를 위반하는 중복 키 값
DETAIL:  Key (id)=(-10)이(가) 이미 존재합니다.

그리고

rake aborted!
StandardError: 오류가 발생했으며, 이 마이그레이션 및 그 이후의 모든 마이그레이션이 취소되었습니다:

ERROR:  unique constraint "data_explorer_queries_pkey"를 위반하는 중복 키 값
DETAIL:  Key (id)=(-10)이(가) 이미 존재합니다.

따라서 중복된 data_explorer_queries_pkey 키를 제거해야 할 것 같습니다.

어떻게 하면 되나요?

감사합니다. 하지만 앱에 접근할 수 없습니다:

./launcher enter app
Error response from daemon: Container 694b24a2a235e90456fb0ca770c86ac14bb914ad33ada8a18fc4777a1188d848 is not running
root@gaoa-discourse:/var/discourse#

그리고:

root@gaoa-discourse:/var/discourse# su - postgres
No passwd entry for user 'postgres'

그럼 컨테이너를 재시작하나요?

./launcher start app

그다음에는 이런 명령이 필요합니다:

./launcher enter app

그리고:

su postgres -c 'psql discourse'

감사합니다! 처음 시도했을 때 왜 시작되지 않았는지는 모르겠네요.

중복된 “10” ID가 있는 것 같습니다:

4374 | discourse-data-explorer | q:-10 | JSON      | {"id":-10,"name":"Inactive Users with no posts","description":"analyze pre-Discourse signups.","sql":"SELECT\
n    u.id,\n    u.username_lower AS \"username\",\n    u.created_at,\n    u.last_seen_at\nFROM users u\nWHERE u.active = false\nORDER BY u.id\n","created_by":"-1",
"created_at":null,"group_ids":[],"last_run_at":"2019-10-21T04:03:35.548+00:00"}

4114 | discourse-data-explorer | q:-10 | JSON      | {"id":-10,"name":"Inactive Users with no posts","description":"analyze pre-Discourse signups.","sql":"SELECT\
n    u.id,\n    u.username_lower AS \"username\",\n    u.created_at,\n    u.last_seen_at\nFROM users u\nWHERE u.active = false\nORDER BY u.id\n","created_by":"-1",
"created_at":null,"last_run_at":"2019-02-27T06:17:48.317+00:00"}

그러면 다음을 실행해야 할 것 같습니다:

DELETE from plugin_store_rows WHERE id = 10

아니면 이렇게 해야 하나요:

DELETE from plugin_store_rows WHERE id = -10

궁금한 점이 있습니다 - 위의 명령어로 삭제될 항목은 첫 번째로 찾은 항목 하나인가요, 아니면 두 항목 모두인가요?

ID 열의 숫자는 4374와 4114입니다. 가장 큰 숫자의 항목을 삭제하세요.

DELETE from plugin_store_rows WHERE id = 10을 실행하지 마세요!! 그렇지 않으면 잘못된 항목이 삭제됩니다!

아, 이거 말하는 거야?

DELETE from plugin_store_rows WHERE id = 4374;

네. plsql 쿼리 출력에서 올바른 컬럼 헤더가 표시되어야 하지 않나요?

말씀해 주니 그렇군. 출력이 이렇게 나와서 아래로 스크롤했었어:

네, 그리고 일반적으로 커밋하기 전에 명령을 실행하여 그 영향을 확인해 보세요. 참고:

예를 들어, 한 줄만 삭제하려고 했는데 500줄을 삭제해 버렸다면, 걱정 없이 롤백할 수 있는 기회가 생기는 겁니다.

성공! :tada: @merefield 님, 조언 감사합니다.

제 DELETE 명령어에서 마침표가 빠져 있었습니다. (위에서 수정했습니다.)

아 네, 그거 매번 저를 당하게 하네요 :wink: