Created
July 30, 2008 17:24
-
-
Save duncanbeevers/3298 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
namespace :db do | |
namespace :schema do | |
task :load => :alias_create_table | |
task :alias_create_table do | |
# WTF! | |
if /_test$/ === ActiveRecord::Base.connection.instance_variable_get('@connection_options')[3] | |
max_heap_table_size = 180 # Mb | |
ActiveRecord::Base.connection.execute("SET max_heap_table_size = #{max_heap_table_size} * 1024 * 1024") | |
module ActiveRecord::ConnectionAdapters::SchemaStatements | |
def create_table_with_memory_engine(table_name, options = {}, &block) | |
begin | |
new_options = options.merge(:options => 'ENGINE=MEMORY') | |
create_table_without_memory_engine(table_name, new_options, &block) | |
rescue | |
# Oops, try again | |
create_table_without_memory_engine(table_name, options, &block) | |
end | |
end | |
alias_method_chain :create_table, :memory_engine | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment