Last active
December 20, 2022 03:47
-
-
Save gregawoods/b26751a623a56aa0a75d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>KeepAlive</key> | |
<true/> | |
<key>Label</key> | |
<string>homebrew.mxcl.mysql</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/local/opt/mysql/bin/mysqld_safe</string> | |
<string>--bind-address=127.0.0.1</string> | |
<string>--datadir=/usr/local/var/mysql</string> | |
<string>--innodb_file_format=Barracuda</string> | |
<string>--innodb_large_prefix=ON</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>WorkingDirectory</key> | |
<string>/usr/local/var/mysql</string> | |
</dict> | |
</plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveSupport.on_load(:active_record) do | |
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.class_eval do | |
def create_table(table_name, options = {}) #:nodoc: | |
super(table_name, options.reverse_merge(:options => 'ROW_FORMAT=DYNAMIC ENGINE=InnoDB')) | |
end | |
end | |
end |
In order to use this solution your Mysql server will need to be configured with the following two options:
- innodb_file_format must be set to
Barracuda
- innodb_large_prefix must be set to
ON
I credit serversforhackers.com for the info on innodb_large_prefix
.
Added sample launch deamon for users on OS X and using Homebrew.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The goal of this hack is to work around a problem we ran into when using the utf8mb charset in mysql with Rails 4.
Using utf8mb4 allows us to store emoji characters in our text columns. This causes a new problem however that prevents us from creating indexes using the
create_index
migration. More details about that issue can be found here.One workaround is to create your tables using the
ROW_FORMAT=DYNAMIC
option. Tables created this way will store their data off-page if the data is too large. More info about that can be found here.You could resolve this by adding
ROW_FORMAT=DYNAMIC
to all of your migrations, but that is tedious. This code will override the defaultcreate_table
migration and add that config to all of your tables by default.