Skip to content

Instantly share code, notes, and snippets.

@attilahorvath
Last active September 23, 2015 08:33
Show Gist options
  • Save attilahorvath/95b6f7ddfd9413f3dfac to your computer and use it in GitHub Desktop.
Save attilahorvath/95b6f7ddfd9413f3dfac to your computer and use it in GitHub Desktop.
Limit ActiveRecord strings to 191 characters to avoid index too long errors with MySQL utf8mb4 encoding
# config/initializers/active_record_patch.rb
require 'active_record/connection_adapters/abstract_mysql_adapter'
module ActiveRecord
module ConnectionAdapters
class AbstractMysqlAdapter
NATIVE_DATABASE_TYPES[:string] = { name: "varchar", limit: 191 }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment