我已经迁移了一个名为 units 的表,其中包含几列。我想知道如何使用 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 可能是错误的,我不确定。