Restream / redmine_tagging

Add simple tagging support to Redmine Issues/Wiki pages
113 stars 52 forks source link

mysql error on rake db:migrate #20

Closed crooy closed 12 years ago

crooy commented 12 years ago

When calling rake db:migrate I get this error. If I'm not mistaking this is because the index is over a couple of varchar(255) utf8 columns.

 rake db:migrate
(in /usr/share/redmine)
==  ActsAsTaggableOnMigration: migrating ======================================
-- create_table(:tags)
   -> 0.0027s
-- create_table(:taggings)
   -> 0.0014s
-- add_index(:taggings, :tag_id)
   -> 0.0018s
-- add_index(:taggings, [:taggable_id, :taggable_type, :context])
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: Specified key was too long; max key length is 1000 bytes: CREATE  INDEX `index_taggings_on_taggable_id_and_taggable_type_and_context` ON `taggings` (`taggable_id`, `taggable_type`, `context`)

(See full trace by running task with --trace)
crooy commented 12 years ago

Took me a while, but I realized this error was caused by acts-as-taggable-on and not this plugin. Nevertheless, I kinda fixed it by changing:

    add_index :taggings, :tag_id
    add_index :taggings, [:taggable_id, :taggable_type, :context]

into

    add_index :taggings, :tag_id
    add_index :taggings, :taggable_id
    add_index :taggings, :taggable_type
    add_index :taggings, :context

Any queries on the three columns should result in a merge of the three indexes, and a negligible loss of performance for the query.

crooy commented 12 years ago

by the way, more people appear to have this issue : http://stackoverflow.com/questions/3489041/mysqlerror-specified-key-was-too-long-max-key-length-is-1000-bytes

retorquere commented 12 years ago

The add_index is part of acts_as_taggable, right? So it's not something I can actually fix. But thanks for figuring this out, I'll add it to the readme.