Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4351 (closed defect: wontfix)

Opened 3 years ago

Last modified 3 years ago

[PATCH] ActiveRecord mysql_adapter.rb: ":timestamp" should create "TIMESTAMP" column

Reported by: dvdplm@gmail.com Assigned to: David
Priority: normal Milestone:
Component: ActiveRecord Version: 1.0.0
Severity: major Keywords: mysql timestamp datetime activerecord
Cc:

Description

(disclaimer: I am *very* new to Ruby and to RoR; might do things wrong here...)

ActiveRecord::Schema.define() do
	create_table(:category) do |t|
		t.column "updated_on",	:timestamp
	end
end

The above should create a TIMESTAMP column in the MySQL database when I "rake db_schema_import". Instead it creates a DATETIME column.

A cannot see the reason for this, so I started digging and found, in activerecord/lib/connection_adapters/mysql_adapter.rb, row 106 that "timestamp" is mapped to "datetime" instead of "timestamp". I'm using ActiveRecord 1.13.2

PATCH (mysql_adapter.rb, row 106)


Was:

          :timestamp   => { :name => "datetime" },

Change:

          :timestamp   => { :name => "timestamp" },

Attachments

mysql_adapter.rb (10.7 kB) - added by dvdplm@gmail.com on 03/22/06 11:18:55.
patched "mysql_adapter.rb"

Change History

03/22/06 11:18:55 changed by dvdplm@gmail.com

  • attachment mysql_adapter.rb added.

patched "mysql_adapter.rb"

03/22/06 19:27:08 changed by david

  • status changed from new to closed.
  • resolution set to wontfix.

timestamps are turned back into datetimes when rows are initialized, so we've basically just decided that timestamps are a bad idea. Instead you should use things like created_on/at and updated_on/at.