I have a specific need to hack active record migrations for MySQL so that 
:timestamp fields will map to MySQL TIMESTAMP columns (instead of DATETIMElike 
they do now). I first tried monkey-patching active record with an 
initializer, then with a gem that uses a railtie. After consistent failure 
(and after attending my local ruby user group meeting last night) it was 
suggested to me that I just try directly editing my copy of the active 
record gem to see if the stuff I'm changing is even correct for what I'm 
trying to accomplish.

I took their advice and directly edited the 
lib/active_record/connection_adapters/mysql_adapter.rb file like so:

      NATIVE_DATABASE_TYPES = {
        :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY 
KEY".freeze,
        :string      => { :name => "varchar", :limit => 255 },
        :text        => { :name => "text" },
        :integer     => { :name => "int", :limit => 4 },
        :float       => { :name => "float" },
        :decimal     => { :name => "decimal" },
        :datetime    => { :name => "datetime" },
        :timestamp   => { :name => "timestamp" }, # "datetime" ==> 
"timestamp"
        :time        => { :name => "time" },
        :date        => { :name => "date" },
        :binary      => { :name => "blob" },
        :boolean     => { :name => "tinyint", :limit => 1 }
      }

The complete log of everything I did is here: http://gist.github.com/853701

It *still* doesn't work. Their advice was good as clearly I'm not even 
changing the right stuff to make this happen!

Anyone know what I need to change so my :timestamp fields in my migrations 
will create TIMESTAMP columns in MySQL? If I can figure out what to change 
then I can make a monkey-patch to do it for my project.

Thanks for your time!

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to