From c3c70bc70ce53cf1e5dc955b8857f2ad4db608f4 Mon Sep 17 00:00:00 2001 From: Clemens Kofler Date: Thu, 10 Jul 2008 16:07:12 +0200 Subject: [PATCH] Added configuraton option for storage engine to MySQL driver (still defaults to "InnoDB"). --- .../connection_adapters/mysql_adapter.rb | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index c596276..f56e821 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -145,6 +145,7 @@ module ActiveRecord # * :password - Defaults to nothing. # * :database - The name of the database. No default, must be provided. # * :encoding - (Optional) Sets the client encoding by executing "SET NAMES " after connection. + # * :engine - (Optional) Sets the database engine by executing "SET STORAGE_ENGINE " after connection. Defaults to "InnoDB". # * :sslkey - Necessary to use MySQL with an SSL connection. # * :sslcert - Necessary to use MySQL with an SSL connection. # * :sslcapath - Necessary to use MySQL with an SSL connection. @@ -427,10 +428,6 @@ module ActiveRecord columns end - def create_table(table_name, options = {}) #:nodoc: - super(table_name, options.reverse_merge(:options => "ENGINE=InnoDB")) - end - def rename_table(table_name, new_name) execute "RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}" end @@ -506,12 +503,15 @@ module ActiveRecord if encoding @connection.options(Mysql::SET_CHARSET_NAME, encoding) rescue nil end + + engine = @config[:engine] || "InnoDB" @connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher]) if @config[:sslkey] @connection.real_connect(*@connection_options) execute("SET NAMES '#{encoding}'") if encoding + execute("SET STORAGE_ENGINE=#{engine}") # By default, MySQL 'where id is null' selects the last inserted id. # Turn this off. http://dev.rubyonrails.org/ticket/6778 -- 1.5.2.4