简体   繁体   中英

How do I define a database index in HoboFields?

With HoboFields , I can declare fields for my model in its own file, like this:

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.

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.

Edit: it's been implemented and is currently in this experimental branch: http://github.com/tablatom/hobo/tree/indexgen . I'll update the answer when it gets included in a release.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM