This project is archived and is in readonly mode.
add_index
Reported by Tim Neill | November 14th, 2008 @ 06:35 PM | in 2.x
Guys -
There is a very simple problem with the add_index command & mysql. It is not validating whether index names are too long and working around them.
e.g.:
# Comp Category Hierarchy Table
create_table :comp_category_hierarchies, :id => false do |t|
t.column :comp_category_id, :integer, :null => false
t.column :comp_subcategory_id, :integer, :null => false
end
add_index(:comp_category_hierarchies, [:comp_category_id, :comp_subcategory_id], :unique => true)
Generates the following error:
Mysql::Error: Identifier name 'index_comp_category_hierarchies_on_comp_category_id_and_comp_subcategory_id' is too long: CREATE UNIQUE INDEX `index_comp_category_hierarchies_on_comp_category_id_and_comp_subcategory_id` ON `comp_category_hierarchies` (`comp_category_id`, `comp_subcategory_id`)
Just thought I would let you know.
Thanks for all the hard work.
Comments and changes to this ticket
-
Pratik March 10th, 2009 @ 12:31 PM
- Assigned user set to Pratik
- State changed from new to wontfix
Not sure what'd be the best way to fix it. You could always submit a patch and help out :) http://guides.rails.info/contrib...
Thanks !
-
Nick Eskelinen January 7th, 2010 @ 07:11 PM
In this case add_index should probably resort to generating a unique name using MD5 (or something similar).
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>