Wednesday, 15 August 2012

ruby on rails - Name an Index in a Migrate with index: true -



ruby on rails - Name an Index in a Migrate with index: true -

i have migrate, below, create index index: true. however, name long index attempted name myself. however, doesn't seem run. same "name long" error. there way name index index: true? if not, how go naming add_index?

class createvehicleproductapplicationnotes < activerecord::migration def alter create_table :vehicle_product_application_notes |t| t.references :product_id, index: true t.references :product_application_id, index: true, :name "my_index" t.references :note_id, index: true t.timestamps end end end

instead of true, can pass hash containing name of index follows,

t.references :product_application_id, index: { name: "my_index" }

reference: http://api.rubyonrails.org/classes/activerecord/connectionadapters/tabledefinition.html

ruby-on-rails ruby indexing naming

No comments:

Post a Comment