什么是迁移索引?
问题描述:
我正在阅读RoR的在线指南,并看到了这段迁移代码。什么是迁移索引?
change_table: products do |t|
#some code here
t.string :part_number
t.index :part_number
#some code here
end
这是什么指标?由于我已经有一个名为part_number的字符串列,为什么可以添加另一个具有相同名称但类型不同的列?
对于SQL数据源,它映射到CREATE INDEX语句([MySQL](http://dev.mysql.com/doc/refman/5.6/en/create-index.html),[Postgres]( http://www.postgresql.org/docs/9.2/static/sql-createindex.html))。这会创建一个名为':part_number'的字符串列,然后创建一个索引列来加速查询。 – 2013-03-07 21:19:52
如果我记得没错,索引的列名实际上是'part_number_index' – AdamT 2013-03-07 21:35:55