by using timestamps we can create created_at and updated_on columns to
our tables. But i dont wnat the columns in my table and i want to add my
own column which datatype is timestamp and that must take
current_timestamp or now as default value.
how to do it
re
--
Posted via http://www.ruby-forum.com/.
Since we cannot specify the now() function in the :default option in the
migration file, we can achieve this requirement using the following:
# Sample code
class Samples < ActiveRecord::Migration
def self.up
create_table :system_settings do |t|
t.text :value
t.string :type
t.timestamp :created_time
end
execute "ALTER TABLE system_settings ALTER created_time SET
DEFAULT now()"
end
def self.down
end
end
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.