Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

MySQL index name is too long

#4319

If your table names and your field names are long enough, you can get Rails to generate invalid MySQL code by creating an index name that is too long. This can happen quite easily when you create an index in more than one field.

For example:

Mysql::Error: Identifier name
'index_courses_target_audiences_on_course_id_and_target_audience_id' is too long: CREATE INDEX
index_courses_target_audiences_on_course_id_and_target_audience_id ON courses_target_audiences (course_id, target_audience_id)

I know it can be easily workaround with the :name argument, but it could also be easily made work out of the box by not going over the maximum length.

One concern would be that then there could be a conflict with two keys with the same name. The last 10 characters could be reserved to put a random number or a hash of what would be the complete name to avoid conflicts.

Thanks.

Reported by pupeno@pupeno.com · April 3rd, 2010 @ 05:48 PM

State: duplicate
Milestone: none
Assigned to: Ryan Bigg Ryan Bigg
Importance: Low

Activity

  1. Roland Moriz
    Roland Moriz
    • Assigned user set to Ryan Bigg

    duplicate of #3508 Limit MySQL index name length which is duplicate to #1852 Patch to add index length support which is ...waiting ;-)

    April 11th, 2010 @ 05:12 AM

  2. Roland Moriz
  3. Ryan Bigg
    Ryan Bigg
    • State changed from new to duplicate

    April 11th, 2010 @ 07:19 AM