私はPostGres 9.5でRails 5を使用しています。私は、マイグレーションを実行する際に、次の移行Railsの移行でテーブルにインデックスを追加する適切な方法は何ですか?
class CreateCryptoIndexCurrencies < ActiveRecord::Migration[5.0]
def change
create_table :crypto_index_currencies do |t|
t.references :crypto_currency, foreign_key: true
t.date :join_date, :null => false, :default => Time.now
t.timestamps
end
add_index :crypto_index_currencies, :crypto_currency, unique: true
end
end
は、それがこのエラー
PG::UndefinedColumn: ERROR: column "crypto_currency" does not exist
インデックスを追加する適切な方法は何で死にかけているのか?私が参照したいテーブル名は "crypto_currencies"と呼ばれます。