Instead of duplicating that code everywhere, here's what I'm doing:
class MyTables < ActiveRecord::Migrationdef self.create_table( table_name, options={}, &table_definition )
options[:options] = "" unless( options.has_key?( :options ) )
options[:options] += " DEFAULT CHARSET=UTF8 "
super( table_name, options ) do |t|
t.column :created_at, :timestamp, :null => false
table_definition.call(t)
end
end
end
class Foo < MyTables
# use this like a regular migration
end
So now every migration Foo that inherits from MyTables automatically gets some default goodness.
No comments:
Post a Comment