Skip to content

Mysql2::Error: Specified key was too long; max key length is 3072 bytes #238

Answered by 0000sir
estebanutz asked this question in Q&A
Discussion options

You must be logged in to vote

change the migration like this will make it work:

      #t.references :favoritable, polymorphic: true, null: false
      #t.references :favoritor, polymorphic: true, null: false
      t.integer :favoritor_id, null: false, index: true
      t.string :favoritor_type, null: false, limit: 50, index: true
      t.integer :favoritable_id, null: false, index: true
      t.string :favoritable_type, null: false, limit: 50, index: true

You won't have a class name longer than 50 normally~

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@jonhue
Comment options

Comment options

You must be logged in to vote
1 reply
@0000sir
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@estebanutz
Comment options

Answer selected by jonhue
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
3 participants
Converted from issue

This discussion was converted from issue #237 on November 11, 2021 07:20.