LoginSignup
0
0

More than 5 years have passed since last update.

Mysql2::Error: Index column size too large. The maximum column size is 767 bytes.: CREATE INDEX `index_xxx_yyy_id`

Last updated at Posted at 2016-08-29

utf8mb4対応

MySQLのデータベース設定がutf8mb4でこのエラーが発生したら

  • ROW_FORMATnのデフォルトをDYNAMIC
config/initializers/ar_innodb_row_format.rb
ActiveSupport.on_load :active_record do
  module ActiveRecord::ConnectionAdapters
    class AbstractMysqlAdapter
      def create_table_with_innodb_row_format(table_name, options = {})
        table_options = options.merge(options: 'ENGINE=InnoDB ROW_FORMAT=DYNAMIC')
        create_table_without_innodb_row_format(table_name, table_options) do |td|
          yield td if block_given?
        end
      end
      alias_method_chain :create_table, :innodb_row_format
    end
  end
end
  • my.cnf
    • innodb_file_format = Barracuda
    • innodb_file_per_table = 1
    • innodb_large_prefix
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0