How to make Rails ActiveRecord::Migration default to MyISAM

Some people perfer InnoDB, other MyISAM. This post ain't about a MySQL-Engine flame war but about letting people choice.

Fact is, the excellent Migration system shipped with rubyonrails and ActiveRecord is defaulting to InnoDB. The doc shows how you can specify the engine on each create_table statement. but then your migration are mysql-only because these engine options will not be supported by sqlite or MSSQL. and I dont want to copy/paste these options to all of my create table. I want to change the default.

unfortunately Rails supply no options for it

fortunately Rails is built on Ruby.

so you can simply overwrite the proper method by adding it to your config/environment.rb

module ActiveRecord
        module ConnectionAdapters
                class MysqlAdapter < AbstractAdapter
                        def create_table(table_name, options = {}) #:nodoc:
                                super(table_name, options.reverse_merge(:options => "ENGINE=MyISAM"))
                        end
                end
        end
end

Tags , , , , , , , , ,

Posted in , , | Posted on 08 Apr 2009 13:56by somekool | 2 comments

Gotta Love Dreamhost

So Dreamhost recently celebrated their 9th anniversary. and for this event they upped our disk space and bandwidth limit BY TEN (10). Actually, it feels like 20x.

So I was using 30% of my 20GB of space (got lot of pictures). and suddenly I am now only using 3% for my new 200GB of space ;) I wonder what would happen if everyone would suddenly decide to fill it up ;)

Dreamhost Host Quota, gotta love 'em

The best part is, I got this account for so cheap, I'm even a bit shy to tell you all the details....

So go ahead and create yourself a Dreamhost account by clicking here and save even more money by using this coupon code. GODREAMHOST20 Simply enter the coupon when you sign up for your account, you will save 20$ dollars on your invoice. its as easy as that.

if you need more info about Dreamhost and what not, feel free to ask me. I used them for a bit more than a year now. And I am simply more satisfied with them every single month.

Tags , , , , , , , , , , , , , , , , , , , , ,

Posted in , , | Posted on 03 Oct 2006 19:57by somekool | no comments

Subscribe

Personal Links

Tags

Categories

Archives

my Xbox 360 gamertag

my last twitter posts

Copyright © Mathieu Jobin's Life and Thoughts

Tech Blue designed by Hive Designs • Ported by Free WordPress Themes and Frédéric de Villamil Powered by Typo