Topics 테이블과의 외래키 관계를 생성하려고 합니다.
문제는 가장 이상한 이유로 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
더 이상한 부분은 이 마이그레이션이 프로덕션에서는 작동한다는 것입니다!
어떤 통찰도 환영합니다!