aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-12-21 17:39:31 +0900
committerGitHub <noreply@github.com>2018-12-21 17:39:31 +0900
commit721e26767c0443e63e67f4307415f5e4a8f3cd3d (patch)
tree0ce8574bc07e94ba7cb6c83fd8f88567602fa3ca /activerecord/lib/active_record/connection_adapters
parentb75192845a6aa89b35c857e9f3de443ae1a0fbd5 (diff)
parenta1652c196e57f583cd5c95f7f48eeb6d8c8b285d (diff)
downloadrails-721e26767c0443e63e67f4307415f5e4a8f3cd3d.tar.gz
rails-721e26767c0443e63e67f4307415f5e4a8f3cd3d.tar.bz2
rails-721e26767c0443e63e67f4307415f5e4a8f3cd3d.zip
Merge pull request #34742 from kamipo/row_format_dynamic_by_default
MySQL: `ROW_FORMAT=DYNAMIC` create table option by default
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb
index 66db4e4149..47b5c4b9ec 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb
@@ -77,6 +77,10 @@ module ActiveRecord
super
end
+ def create_table(table_name, options: default_row_format, **)
+ super
+ end
+
def internal_string_options_for_primary_key
super.tap do |options|
if !row_format_dynamic_by_default? && CHARSETS_OF_4BYTES_MAXLEN.include?(charset)
@@ -104,6 +108,20 @@ module ActiveRecord
end
end
+ def default_row_format
+ return if row_format_dynamic_by_default?
+
+ unless defined?(@default_row_format)
+ if query_value("SELECT @@innodb_file_per_table = 1 AND @@innodb_file_format = 'Barracuda'") == 1
+ @default_row_format = "ROW_FORMAT=DYNAMIC"
+ else
+ @default_row_format = nil
+ end
+ end
+
+ @default_row_format
+ end
+
def schema_creation
MySQL::SchemaCreation.new(self)
end