Index name too long for MySQL
Closed this issue · 5 comments
Hi, Im not a proficient Rails developer, so I don't know (and I searched for it) how to specify index names on rails migrations, so I decided to bring this to your attention, when changing the database backend to mysql and running the migrations I get:
An error has occurred, all later migrations canceled:
Mysql::Error: Identifier name 'index_papermill_assets_on_assetable_type_and_assetable_id_and_assetable_key_and_position' is too long: CREATE INDEX index_papermill_assets_on_assetable_type_and_assetable_id_and_assetable_key_and_position
ON papermill_assets
(assetable_type
, assetable_id
, assetable_key
, position
)
The index name is indeed long:
index_papermill_assets_on_assetable_type_and_assetable_id_and_assetable_key_and_position
Thanks for notifying,
I'll have a look at it today. Can you please tell me what version of MySQL on what OS you are using? It does work on Mysql 5.1 on Leopard.
Thanks a lot,
Benoit
My mistake, you nailed it :
https://rails.lighthouseapp.com/projects/8994/tickets/3508-limit-mysql-index-name-length
I hadn't run the migration with indexes on Mysql yet..
I guess specifying the index name in the migration will fix the mess.
Snow Leopard and MySQL 5.1.41, please pardon my ignorance but how can I specify the index name within the migration?
Like here :
http://dev.rubyonrails.org/ticket/10954
add :name => "index_name" in the option hash.
Anyway I'll release a new gem tonight with this fix included.
Fixed with 1.3.1