diff options
author | Alberto Almagro <alberto.almagro@rakuten.com> | 2017-11-18 11:54:18 +0100 |
---|---|---|
committer | Alberto Almagro <alberto.almagro@rakuten.com> | 2017-12-11 10:46:14 +0100 |
commit | 7ac7f4a18895da2aba093f603c968a630c5fe4ba (patch) | |
tree | 8f86a7029a020a80357463495f0db18e3fb32f41 /activerecord/lib | |
parent | 9b2180c7de0823f2561b9e359728c15a32ec3a7b (diff) | |
download | rails-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')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/migration/compatibility.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 479131caad..2d1d265f65 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -293,7 +293,7 @@ module ActiveRecord end def create_table(table_name, **options) #:nodoc: - super(table_name, options: "ENGINE=InnoDB", **options) + super(table_name, options: "", **options) end def bulk_change_table(table_name, operations) #:nodoc: 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 |