2017-10-31 2 views
1

カピストラーノを使用して生産に私の変更を展開する場合とき、私は私の移行で"PG :: UndefinedColumn:" 展開レールはアプリ

PG::UndefinedColumn: ERROR: column "address_id" of relation "member_applications" does not exist 

エラーを取得する私は

class CreateAddresses < ActiveRecord::Migration[5.1] 
    def change 
     create_table :addresses do |t| 
      t.string :full_name, null: false 
      t.string :email, null: false 
      t.string :phone, null: false 
      t.string :address, null: false 
      t.string :state, null: false 
      t.string :country, null: false 
      t.string :postcode, null: false 
      t.timestamps 
     end 
    end 
end 

class CreateMemberApplications < ActiveRecord::Migration[5.1] 
    def change 
     create_table :member_applications do |t| 
      t.references :location, null: false 
      t.references :addresses, null: false 
      t.references :user, null: false 
      t.string :full_name, null: false 
      t.date :birthdate, null: false 
      t.timestamps 
     end 
    end 
end 
を持っています

そして最後に

class SetAddressToNull < ActiveRecord::Migration[5.1] 
    def change 
     change_column_null :member_applications, :address_id, true 
    end 
end 

この最後の移行は問題を引き起こすようです。この問題の原因は何ですか?私の開発マシンでは動作していますが、最後に展開してからしばらくしています。

答えて

1

私はこの問題はここにあると信じて:

create_table :member_applications do |t| 
    ... 
    t.references :addresses, null: false 
    ... 
end 

それが特異でt.references :address, null: falseでなければなりません。

db/schema.rbを確認して確認することができます。

+0

これが問題でした。どういうわけか私のスキーマが正しいaddress_idを使用していました。それがどのように起こったのかわかりませんが、移行を修正してpsqlでサーバーの列の名前を変更した後、今すぐ検索できます。 – Qwertie

関連する問題