これは、Discourse の公式 Docker インストールでも同様に発生します。毎朝、パイプラインを通じて自動化された復元テストを実行しています。この類似のエラーが、失敗したパイプラインで突然出現しました。
I, [2026-05-20T07:59:01.413128 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle
exec rake db:migrate'
2026-05-20 07:59:09.214 UTC [1576] discourse@discourse ERROR: relation "translation_overrides" does not exist at character 523
2026-05-20 07:59:09.214 UTC [1576] discourse@discourse STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
c.collname, col_description(a.attrelid, a.attnum) AS comment,
attidentity AS identity,
attgenerated as attgenerated
FROM pg_attribute a
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
LEFT JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
WHERE a.attrelid = '"translation_overrides"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
2026-05-20 07:59:13.167 UTC [1627] discourse@discourse ERROR: schema "discourse_functions" already exists
2026-05-20 07:59:13.167 UTC [1627] discourse@discourse STATEMENT: CREATE SCHEMA discourse_functions;
psql:/var/www/discourse/db/structure.sql:16: ERROR: schema "discourse_functions" already exists
rake aborted!
根本原因は、復元されたバックアップとコンテナコードのバージョン不一致でした。
最新の Discourse コードには translation_overrides を参照するモデルが含まれていますが、本番環境のデータベース(バックアップから)は古いバージョンにあり、このテーブルが存在しないか、または異なる名前になっています。
私が有効だった方法は、まずリビルド(スキーマを一から作成)し、その後バックアップを復元することです。復元プロセスは Discourse の組み込み復元機能を使用し、データベースを適切に削除して再作成します。