I have read this question and I try to test it in my case, but I don't understand why it work.
I'm using rails and utf8mb4 encoded MariaDB (version 10.1.35)
I have this in my schema:
create_table "settings", force: :cascade do |t|
t.string "var", limit: 255, null: false
t.text "value", limit: 65535
t.integer "target_id", limit: 4, null: false
t.string "target_type", limit: 255, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "settings", ["target_type", "target_id", "var"],
name: "index_settings_on_target_type_and_target_id_and_var",
unique: true,
length: {"target_type"=>191,
"target_id"=>nil,
"var"=>191}, using: :btree
I do rake db:schema:load
and it pass without any problem. I think it should show error because innoDB index prefix limit is 767 bytes and we exceed the limit in this case:
191*4 + 191*4 = 1528 which exceed 767
Can anybody explain why it still work?
I'm struggling to understand the difference between index, key for index and prefix in index. It would be nice if someone can list a resource for me to learn these too.
What I have read: