[英]How do I define a database index in HoboFields?
With HoboFields , I can declare fields for my model in its own file, like this: 使用HoboFields ,我可以在自己的文件中声明模型的字段,如下所示:
class User < ActiveRecord::Base
fields do
login :string
persistence_token :string
end
end
I'd like to know if there's equivalent syntax for the add_index
command I can use in vanilla Rails migrations. 我想知道在香草Rails迁移中是否可以使用
add_index
命令的等效语法。
class User < ActiveRecord::Base
fields do
login :string
persistence_token :string, :index => true
end
end
This doesn't exist yet in HoboFields, but I've suggested it on this thread and it seems it's going to be implemented in a future release. HoboFields中尚不存在此功能,但我已在此线程上建议使用它,并且似乎将在将来的版本中实现。
Edit: it's been implemented and is currently in this experimental branch: http://github.com/tablatom/hobo/tree/indexgen . 编辑:它已经实现,当前在此实验分支中: http : //github.com/tablatom/hobo/tree/indexgen 。 I'll update the answer when it gets included in a release.
当发布中包含答案时,我将对其进行更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.