我知道,我能触摸迁移和添加
add_index :table_name, :column_name, :unique => true
但是如何正确的轨道迁移命令生成的?
rails g migration add_index_to_column_name :column_name, :unique => true
是对的吗?
在我的特殊的例子,我有一个表的客户
t.integer :customerID
t.string :surname
t.string :first_name
t.string :phone
一个我想在客户设置为唯一的。 试着
rails g migration AddIndexToCustomers :customerID, :unique => true
但是,如果我在这之后看向我的移民文件,它不看的权利看到这一点:
def change
add_column :customers, :, :customerID,
add_column :customers, :, :unique
add_column :customers, :=, :string
end
任何想法或建议?