我已经迁移了一个称为单位的表,其中有几列.我想知道如何使用cmd将“add_index”单独迁移到此表.这段代码是否正确:
class AddIndexToUnits < ActiveRecord::Migration def self.up add_index :units,:lesson_id end def self.down remove :units end end
我有一种感觉self.down可能是错的,我不确定.
解决方法
self.up方法是正确的.使用这个为你的self.down:
remove_index :units,:column => :lesson_id