-
-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mysql - BLOB/TEXT column 'value' used in key specification without a key length #789
Comments
The issue is with this index:
Now that And here are the Rails docs for #add_index with prefix size:
|
@bkeepers thank you for looking into that! below migration fixed the issue class ChangeFlipperGatesValueToText < ActiveRecord::Migration[7.1]
def up
remove_index :flipper_gates, %i[feature_key key value]
change_column :flipper_gates, :value, :text
add_index :flipper_gates, [:feature_key, :key, :value], unique: true, length: {feature_key: 50, key: 50, value: 50}
end
def down
change_column :flipper_gates, :value, :string
end
end I'm not any mysql expert, its just an experimentation |
@gs-deliverists-io Thanks, I was just experimenting with the same thing. I just ran the flipper-active_record test suite against mysql after making the change below and everything passes. @fer9305 @BrandonHicks-msr @gs-deliverists-io can you all test this out and confirm that it works for you as well? class ChangeFlipperGatesValueToText < ActiveRecord::Migration[7.1]
def up
remove_index :flipper_gates, [:feature_key, :key, :value], unique: true
change_column :flipper_gates, :value, :text
add_index :flipper_gates, [:feature_key, :key, :value], unique: true, length: { value: 255 }
end
def down
change_column :flipper_gates, :value, :string
end
end |
The latest snippet you provided above worked for me. The only issue I had was related to the index (and maybe related to something I was previously missing). But changing it to the following resolved it: remove_index(:flipper_gates, [:feature_key, :key, :value], unique: true) if index_exists?(:flipper_gates, [:feature_key, :key, :value], unique: true) |
@bkeepers it works for me! |
Thank you @bkeepers ! Lovely work. Works fine now. ❤️ |
Originally raised in #557 (comment):
Reproducable with mysql2 and trilogy adapters on Mysql 8.2.0
cc @fer9305 @BrandonHicks-msr @gs-deliverists-io
The text was updated successfully, but these errors were encountered: