'rename_discourse_rewind_disabled_to_enabled' 마이그레이션 오류

다시 빌드(rebuild)에 실패했습니다. 로그는 다음과 같습니다:

discourse -c 'bundle exec rake db:migrate'
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)

You must drop a column's default value before marking it as readonly
I, [2026-01-08T16:18:49.016491 #1]  INFO -- : Terminating async processes
I, [2026-01-08T16:18:49.018961 #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/15/bin/postmaster -D /etc/postgresql/15/main pid: 46
I, [2026-01-08T16:18:49.020147 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 113
2026-01-08 16:18:49.019 UTC [46] LOG:  received fast shutdown request
113:signal-handler (1767889129) Received SIGTERM scheduling shutdown...
2026-01-08 16:18:49.023 UTC [46] LOG:  aborting any active transactions
2026-01-08 16:18:49.034 UTC [46] LOG:  background worker "logical replication launcher" (PID 60) exited with exit code 1
2026-01-08 16:18:49.040 UTC [55] LOG:  shutting down
2026-01-08 16:18:49.042 UTC [55] LOG:  checkpoint starting: shutdown immediate
2026-01-08 16:18:49.057 UTC [55] LOG:  checkpoint complete: wrote 32 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.007 s, sync=0.004 s, total=0.017 s; sync files=16, longest=0.002 s, average=0.001 s; distance=180 kB, estimate=180 kB
2026-01-08 16:18:49.067 UTC [46] LOG:  database system is shut down
113:M 08 Jan 2026 16:18:49.108 # User requested shutdown...
113:M 08 Jan 2026 16:18:49.108 * Saving the final RDB snapshot before exiting.
113:M 08 Jan 2026 16:18:49.123 * DB saved on disk
113:M 08 Jan 2026 16:18:49.123 # 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 4483 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/exec_command.rb:131:in `spawn'
exec failed with the params {"cd"=>"$home", "tag"=>"migrate", "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.

죄송합니다, 제 실수였습니다. 마이그레이션에서 기본값 / null 제약 조건의 순서가 잘못되었습니다 :man_facepalming:

괜찮아, 수리할 때까지 기다릴게. 화이팅 화이팅~~~

마지막 업데이트 이후로 같은 문제를 겪고 있습니다.

@zogstrip의 해당 마이그레이션 수정 사항이 latest에 적용되었습니다. 따라서 업그레이드를 한 번 더 실행하면 다시 정상적으로 작동할 것입니다.

방금 다시 빌드해 봤는데도 여전히 작동하지 않습니다

방금 rebuild을 시도해 보았는데 여전히 실패했습니다. 원인이 무엇일까요?

I, [2026-01-09T05:09:31.402079 #1]  INFO -- : > exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
I, [2026-01-09T05:09:31.409979 #1]  INFO -- : > sleep 10
4481:C 09 Jan 2026 05:09:31.416 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
4481:C 09 Jan 2026 05:09:31.416 # Redis version=7.0.15, bits=64, commit=00000000, modified=0, pid=4481, just started
4481:C 09 Jan 2026 05:09:31.416 # Configuration loaded
4481:M 09 Jan 2026 05:09:31.417 * monotonic clock: POSIX clock_gettime
4481:M 09 Jan 2026 05:09:31.418 # Warning: Could not create server TCP listening socket *:6379: bind: Address already in use
4481:M 09 Jan 2026 05:09:31.418 # Failed listening on port 6379 (TCP), aborting.
I, [2026-01-09T05:09:41.418357 #1]  INFO -- : 
I, [2026-01-09T05:09:41.421210 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)

You must drop a column's default value before marking it as readonly
/var/www/discourse/lib/migration/column_dropper.rb:15:in `mark_readonly'
/var/www/discourse/plugins/discourse-rewind/db/migrate/20260105171115_rename_discourse_rewind_disabled_to_enabled.rb:15:in `up'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-8.0.4/lib/active_record/migration.rb:993:in `public_send'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-8.0.4/lib/active_record/migration.rb:993:in `exec_migration'
/var/www/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `block in exec_migration'
I, [2026-01-09T05:09:52.683547 #1]  INFO -- : Terminating async processes
I, [2026-01-09T05:09:52.684945 #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/15/bin/postmaster -D /etc/postgresql/15/main pid: 45
112I, [2026-01-09T05:09:52.685640 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 112
:signal-handler (1767935392) Received SIGTERM scheduling shutdown...
2026-01-09 05:09:52.686 UTC [45] LOG:  received fast shutdown request
2026-01-09 05:09:52.691 UTC [45] LOG:  aborting any active transactions
2026-01-09 05:09:52.708 UTC [45] LOG:  background worker "logical replication launcher" (PID 59) exited with exit code 1
2026-01-09 05:09:52.713 UTC [54] LOG:  shutting down
2026-01-09 05:09:52.716 UTC [54] LOG:  checkpoint starting: shutdown immediate
112:M 09 Jan 2026 05:09:52.718 # User requested shutdown...
112:M 09 Jan 2026 05:09:52.718 * Saving the final RDB snapshot before exiting.
2026-01-09 05:09:52.734 UTC [54] LOG:  checkpoint complete: wrote 17 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.007 s, sync=0.004 s, total=0.020 s; sync files=14, longest=0.002 s, average=0.001 s; distance=71 kB, estimate=71 kB
2026-01-09 05:09:52.750 UTC [45] LOG:  database system is shut down
112:M 09 Jan 2026 05:09:52.763 * DB saved on disk
112:M 09 Jan 2026 05:09:52.763 # 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 4484 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/exec_command.rb:131:in `spawn'
exec failed with the params {"cd"=>"$home", "tag"=>"migrate", "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.

솔직히 말해서, 여러분의 Discourse 설치에서 문제가 무엇인지 잘 모르겠습니다. 저는 서버 터미널을 통해 제 두 번째 포럼을 다시 구축했는데, 지금은 모든 것이 정상으로 돌아왔습니다. 이제 제 세 번째 포럼도 다시 구축할 텐데, hopefully 이것도 잘 되길 바랍니다.

만약 Discourse 파일에 변경 사항을 가하셨다면, 이것이 나중에 문제를 일으킬 수 있다는 걸 알고 있습니다. 아니면 수동으로 플러그인을 추가하거나 설치하신 경우에도 마찬가지입니다.

잠시만 기다리세요. 저보다 더 잘 아시는 분들이 도와주실 것입니다. 이 시스템이 좋다고 느끼고 이 시스템으로 전환한 이유 중 하나가 바로 이 커뮤니티입니다. 커뮤니티가 이 시스템을 더 위대하게 만들어 줍니다.

수정:
하지만 제 세 번째 포럼에서는 다시 구축이 작동하지 않았습니다.
FAILED

Pups::ExecError: cd /var/www/discourse && su discourse -c ‘bundle exec rake db:migrate’ failed with return #<Process::Status: pid 4466 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/exec_command.rb:131:in `spawn’
exec failed with the params {“cd”=>“$home”, “tag”=>“migrate”, “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.
63e30cde8c7295d25def35eef74dea30714627609c3d38b49a8f80865e5759cf

그리고 이제 제 두 번째 포럼으로 리다이렉트됩니다… 뭐라고… 뭐라고… :rofl:

답변해 주셔서 감사합니다. 저는 어떤 수정도 하지 않았으며, 추가 플러그인도 설치하지 않았습니다.

제 세 번째 포럼에도 수동으로 설치한 플러그인은 없지만, 재구축이 실패한 뒤 두 번째 포럼으로 리다이렉트되는 현상이 발생했어요… 설정 파일(nano containers/app.yml)도 확인해 봤는데 거기서는 문제가 없는데… 대체 무슨 일이 일어나고 있는 걸까요? :smiley:

rebuild 성공

나한테는 안 맞아요 :frowning: 다행히 2026-05-01자리의 서버 복원점이 있네요. 두 번째로 Discourse 업데이트도 재빌드도 안 됩니다. 이제 다시 복원 중인데, 한 가지는 분명합니다:

  1. 모든 주제/글을 텍스트 파일로 백업하세요.
    2.hopefully Discourse를 새로 설치하거나, 다른 시스템으로 교체(원치 않는 방법)하는 것으로 해결될 것입니다.

어딘가에 제가 놓치고 있는 게 있는데, 그게 뭔지 모르겠고 미치겠습니다. 하지만 아마도 후행 우라늄이 그 말을 하고 있는 것 같습니다. 일단 이대로 두겠습니다. HELLDIVERS 2에서 버그를 좀 정리하러 가겠습니다. 슬프네요 :rofl:

불편을 드려 죄송합니다. 제 '수정’을 로컬 개발 데이터베이스와 완전히 새로운 데이터베이스에서 모두 테스트해 보았는데, 두 경우 모두 정상적으로 작동했습니다. 제가 관리하는 커뮤니티를 위해 호스팅하는 인스턴스에서도 테스트를 진행했는데, 여기에서도 문제가 없었습니다. 또한 공개된 CI (GitHub)와 내부 CI 및 스모크 테스트도 모두 통과했습니다.

그런데 알고 보니, 해당 마이그레이션의 영향을 받는 데이터가 그 어떤 데이터베이스에도 존재하지 않았습니다 :expressionless_face:

불편한 경험을 하게 해드려 죄송하며, 다음에는 더 세심하게 주의를 기울이겠습니다.

그래서… 지금 시도해도 안전할까요, 아니면 오히려 더 악화될까요? 저도 같은 문제가 있는데, 이 글을 보고 나서 아직 재구성을 시도하지 않았습니다.

재구축 후 데이터가 최신이 아니라는 것을 발견했고, 그 뒤 관리 콘솔에서 이틀 전의 백업으로 복구 작업을 수행했습니다. 현재까지 특이사항은 발견되지 않았습니다.

정상적으로 작동하는 것 같고, 궁금해하는 분들을 위해 정상적으로 로딩되고 있다고 알려드립니다.

@here 문제가 발생하고 있는 분들을 위해, @david와 제가 근본 원인을 찾은 것 같습니다. 다만 로컬에서 재현하는 것이 복잡합니다.

혹시 아래 SQL 쿼리를 실행하여 결과를 여기에 보고해 주실 수 있을까요?

쿼리 #1

SELECT table_schema, column_name, column_default
FROM information_schema.columns
WHERE table_name = 'user_options' 
AND column_name = 'discourse_rewind_disabled'
ORDER BY table_schema;

쿼리 #2

SELECT n.nspname, n.oid
FROM pg_namespace n
JOIN pg_class c ON c.relnamespace = n.oid
WHERE c.relname = 'user_options'
ORDER BY n.oid;

쿼리 #3

SELECT table_schema, column_default IS NOT NULL as has_default
FROM information_schema.columns
WHERE table_name = 'user_options'
AND column_name = 'discourse_rewind_disabled';

쿼리 #4

SELECT nspname, oid FROM pg_namespace
WHERE nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast', 'public')
AND nspname NOT LIKE 'pg_temp%'
AND nspname NOT LIKE 'pg_toast_temp%'
ORDER BY oid;

감사합니다 :folded_hands:

네, 괜찮습니다. 지금 밖에 있다가 집에 가서 확인해 보겠습니다.

이 명령어들은 컨테이너 내부에서 실행해야 하는 것 아닌가요? Docker로 배포한 Discourse의 PostgreSQL 비밀번호 기본값은 무엇인가요?

컨테이너 내부에서 discourse 사용자로 discourse 디렉터리의 루트에 있으면, bin/rails db를 실행하여 올바른 데이터베이스에 연결할 수 있습니다.