トピックテーブルとの外部キーリレーションシップを作成しようとしています。
奇妙な理由で、GitHubワークフローのテスト環境でテスト中に失敗しています。これは、数年前にコアマイグレーションで削除された、もはや存在しない親テーブルのフィールドにアクセスしようとしています!
エラーは PG::UndefinedColumn: ERROR: column topics.off_topic_count does not exist です。
ええ、2018年のコアマイグレーションで削除されたからです!
テストプロセス中にこれが既に実行されたことを確認しました。
== 20180917024729 RemoveSuperfluousColumns: migrating =========================
== 20180917024729 RemoveSuperfluousColumns: migrated (0.0410s) ===============
古い親テーブルフィールドを明示的に参照しているわけではありません… SQL自体が生成されているように見えますが、現在の定義には不適切です。
== 20231119010101 CreateLocationsTopicTable: migrating ========================rake aborted!
[12035](https://github.com/paviliondev/discourse-locations/actions/runs/7039607316/job/19158951878?pr=103#step:19:12036)StandardError: An error has occurred, this and all later migrations canceled: (StandardError)
[12036](https://github.com/paviliondev/discourse-locations/actions/runs/7039607316/job/19158951878?pr=103#step:19:12037)
[12037](https://github.com/paviliondev/discourse-locations/actions/runs/7039607316/job/19158951878?pr=103#step:19:12038)PG::UndefinedColumn: ERROR: column topics.off_topic_count does not exist
[12038](https://github.com/paviliondev/discourse-locations/actions/runs/7039607316/job/19158951878?pr=103#step:19:12039)LINE 1: ...cs"."deleted_at", "topics"."highest_post_number", "topics"...
テーブル定義は非常にシンプルです。
class CreateLocationsTopicTable < ActiveRecord::Migration[7.0]
def change
create_table :locations_topic do |t|
t.references :topic, foreign_key: true
t.float :latitude, null: false
SNIP
さらに奇妙なのは、このマイグレーションが本番環境では機能することです!
何か洞察があれば大歓迎です!