“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.

抱歉,那是我的失误。迁移时将默认值/空值约束的顺序弄反了 :man_facepalming:

4 个赞

没事的,等你修复哦 加油加油~~~~~

2 个赞

我在上次更新后遇到了同样的问题。

@zogstrip 对该迁移的修复程序现已在 latest 中上线,因此再次运行升级应该可以恢复正常工作。

2 个赞

刚刚rebuild了一下,还是不行

真的没有在宣布问题修复之前对所谓的“修复”进行测试吗?

这似乎是QA不足的反复出现的模式……在这个问题中,至少有连续的3个实例。

我刚才试了一下 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.
1 个赞

说实话,我不知道你的 Discourse 安装出了什么问题。我刚刚通过服务器终端重建了我的第二个论坛,一切又恢复正常了。现在我要重建我的第三个论坛,希望它也能正常。

如果你对 Discourse 文件进行了任何更改,我知道这可能会在将来导致问题。或者如果你手动添加/安装了任何插件。

等等,保持耐心,比我懂的人会来帮忙的。这也是我喜欢并转向这个系统的原因之一,就是它的社区,这让它更加伟大。

编辑:
然而,在我的第三个论坛上,重建没有成功。
失败

Pups::ExecError: cd /var/www/discourse && su discourse -c ‘bundle exec rake db:migrate’ 失败,返回 #<Process::Status: pid 4466 exit 1>
失败位置: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/exec_command.rb:131:in `spawn’
exec 失败,参数为 {“cd”=>“$home”, “tag”=>“migrate”, “hook”=>“db_migrate”, “cmd”=>[“su discourse -c ‘bundle exec rake db:migrate’”]}
bootstrap 失败,退出代码为 1
引导失败 请向上滚动查找更早的错误消息,可能不止一个。
./discourse-doctor 可能会帮助诊断问题。
63e30cde8c7295d25def35eef74dea30714627609c3d38b49a8f80865e5759cf

现在又重定向到我的第二个论坛了……什么……什么…… :rofl:

谢谢您的回复。我没有进行过任何修改修改,也未安装任何额外插件。

1 个赞

我的第三个论坛也没有安装任何手动插件,但在重建失败并重定向到我的第二个论坛后……我还检查了配置文件(nano containers/app.yml),那里的所有内容都很好……怎么回事?:smiley:

1 个赞

rebuild 成功

2 个赞

对我来说不行 :frowning: 幸运的是,我有一个 2026 年 5 月 1 日的服务器还原点。这是我第二次无法更新或重建 Discourse。我现在再次恢复它,有一件事是明确的:

  1. 将所有主题/文章备份到文本文件中。
  2. 希望通过重新安装 Discourse 或使用另一个系统(我不想这样做)来解决这个问题。

我遗漏了某处的一些东西,但我不知道那是什么,这让我很抓狂。但显然,逆行铀(retrograde uranium)在起作用。目前我将保持现状,然后去修复一下《绝地潜兵 2》(HELLDIVERS 2) 中的一些错误,因为我很难过 :rofl:

我理解你们的沮丧,我深表歉意。我在本地的开发数据库以及一个全新的数据库上测试了我的“修复”,它们都运行得很好。然后,我在我为我管理的一个社区运行的托管实例上进行了测试,它在那里也运行得很好。它也通过了我们在 GitHub 上的所有公共持续集成(CI)以及我们的内部 CI 和冒烟测试。

碰巧的是,那些数据库中都没有受到该迁移影响的数据 :expressionless_face:

很抱歉你们有不好的体验,我下次会更小心。

3 个赞

所以……现在尝试安全吗,还是只会让情况更糟?我遇到了同样的问题,在看到这个之后还没有尝试重建。

我rebuild之后发现数据不是最新,然后又从管理后台用前天的备份进行了恢复操作。目前暂未发现任何问题。

1 个赞

看起来它运行正常,对于其他有疑问的人来说,它正在正常加载

@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:

2 个赞

好的,没问题, 我现在外面,等我回去查询一下。