This project is archived and is in readonly mode.

#4319 ✓duplicate

MySQL index name is too long

Reported by | April 3rd, 2010 @ 05:48 PM

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.


Comments and changes to this ticket

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=""></a>

People watching this ticket