aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration
diff options
context:
space:
mode:
authorAlberto Almagro <alberto.almagro@rakuten.com>2017-11-18 11:54:18 +0100
committerAlberto Almagro <alberto.almagro@rakuten.com>2017-12-11 10:46:14 +0100
commit7ac7f4a18895da2aba093f603c968a630c5fe4ba (patch)
tree8f86a7029a020a80357463495f0db18e3fb32f41 /activerecord/lib/active_record/migration
parent9b2180c7de0823f2561b9e359728c15a32ec3a7b (diff)
downloadrails-7ac7f4a18895da2aba093f603c968a630c5fe4ba.tar.gz
rails-7ac7f4a18895da2aba093f603c968a630c5fe4ba.tar.bz2
rails-7ac7f4a18895da2aba093f603c968a630c5fe4ba.zip
Remove default ENGINE=InnoDB for Mysql2 adapter
Before this commit ENGINE=InnoDB was added by default to Mysql2 adapter +create_table+ if no +options+ option was provided. This default ENGINE was lost as soon as something was passed in at +options+ option, making its goal and propagation inconsistent, as the programmer needed to remember including ENGINE=InnoDB when something was passed in. This commit removes default ENGINE as its use isn't needed anymore for current MySQL and MariaDB versions. It adds compatibility support and tests to ensure that default ENGINE is still present for migrations with version 5.1 and before. It also ensures we still dump the ENGINE option to +schema.rb+ in order to avoid inconsistencies.
Diffstat (limited to 'activerecord/lib/active_record/migration')
-rw-r--r--activerecord/lib/active_record/migration/compatibility.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/migration/compatibility.rb b/activerecord/lib/active_record/migration/compatibility.rb
index bd8c054c28..7ae8073478 100644
--- a/activerecord/lib/active_record/migration/compatibility.rb
+++ b/activerecord/lib/active_record/migration/compatibility.rb
@@ -28,6 +28,14 @@ module ActiveRecord
super
end
end
+
+ def create_table(table_name, options = {})
+ if adapter_name == "Mysql2"
+ super(table_name, options: "ENGINE=InnoDB", **options)
+ else
+ super
+ end
+ end
end
class V5_0 < V5_1