Skip to content

Rails 5: support schema t.index for mysql

What does this MR do?

When running RAILS5=1 bin/rake db:reset for mysql with a Rails 5 schema layout, the binary index length wasn't set and resulted in Mysql2::Error: BLOB/TEXT column 'fingerprint' used in key specification without a key length. Also the indexes which have opclasses weren't ignored for Rails 5 on mysql.

To test this, you have to use a Rails 5 schema layout. This schema layout has the index definition inside the create_table block e.g.:

  create_table "gpg_key_subkeys", force: :cascade do |t|
    t.integer "gpg_key_id", null: false
    t.binary "keyid"
    t.binary "fingerprint"
    t.index ["fingerprint"], name: "index_gpg_key_subkeys_on_fingerprint", unique: true, using: :btree
    t.index ["gpg_key_id"], name: "index_gpg_key_subkeys_on_gpg_key_id", using: :btree
    t.index ["keyid"], name: "index_gpg_key_subkeys_on_keyid", unique: true, using: :btree
  end

You can use this schema on a Rails 5 default branch of me where this patch works.

What are the relevant issue numbers?

Does this MR meet the acceptance criteria?

Edited by Yorick Peterse

Merge request reports