로컬에서는 마이그레이션이 정상적으로 수행됩니다 (SQLite를 사용하고 있지만 로컬 환경에서는 postgresql으로 변경됩니다).Heroku에서 마이그레이션을 수행 할 때 PG :: Error : ERROR : relation "member1_id"가 존재하지 않습니다.
heroku pg:reset DATABASE
와 Heroku가에서 데이터베이스를 재설정 한 후 나는
heroku run rake db:migrate
을 실행하지만 마이그레이션 후 다음과 같은 오류가 점점 오전 : 여기
== AddForeignKeysToCollaborations: migrating =================================
-- change_table(:collaborations)
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: relation "member1_id" does not exist
: ALTER TABLE "collaborations" ADD CONSTRAINT "collaborations_member1_id_id_fk" FOREIGN KEY ("member1_id_id") REFERENCES "member1_id"(id) ON DELETE CASCADE
가 마이그레이션입니다 :
협력에 대한
이전 마이그레이션
class CreateCollaborations < ActiveRecord::Migration
def change
create_table :collaborations do |t|
t.integer :user_id
t.integer :collaborator_id
t.timestamps
end
add_index :collaborations, :collaborator_id
add_index :collaborations, [:user_id, :collaborator_id], unique: true
end
end
그 순서대로 실행됩니다
class UpdateCollaborations < ActiveRecord::Migration
def change
change_table :collaborations do |t|
t.rename :user_id, :member1_id
t.rename :collaborator_id, :member2_id
t.string :status
end
add_index :collaborations,:member1_id
add_index :collaborations,:member2_id
end
end
있습니다. 왜이 오류가 Heroku에 오나요? 특히, PG가 "member1_id"에 불필요한 "_id"를 추가하는 것 같습니다.
감사합니다. –