User Tools

Site Tools


mysql:error_index_name_too_long_using_rails

MySQL - Error index name too long using rails

If you get an error that says the auto-generated index name is too long (limited to 64 characters) during a rails migration, add a name to it in the last argument to overwrite the generated name with your custom shorter name.

Sample Error Message:

== AddColumnNameToPrices: reverting ============================================
— remove_column(:prices, :column_name)
rake aborted!
An error has occurred, this and all later migrations canceled:
Index name 'temp_index_altered_prices_on_column_and_other_column_and_third_column' on table 'altered_prices' is too long; the limit is 64 characters

Solution:

add_index :designations, [ :scope_type, :scope_id, :role_id, :user_id ], :unique => true, :name => ‘my_index’
mysql/error_index_name_too_long_using_rails.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki