postgresql - What's the proper way to add an index to a table in a Rails migration? -
i'm using rails 5 postgres 9.5 . have following migration
class createcryptoindexcurrencies < activerecord::migration[5.0] def change create_table :crypto_index_currencies |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 upon running migration, dying error
pg::undefinedcolumn: error: column "crypto_currency" not exist what proper way add index? table name want reference called "crypto_currencies".
add_index 'crypto_index_currencies', ['crypto_currency'], name: "index_crypto_index_currencies_on_crypto_currency", unique: true, using: :btree using: :btree optional.
Comments
Post a Comment