From d1c360959fc583d699d3fb018d1d12f89e5fe00f Mon Sep 17 00:00:00 2001 From: jomo Date: Fri, 24 Apr 2015 00:43:29 +0200 Subject: [PATCH] maybe I should add migrations... --- db/migrate/20150423221202_add_timestamps_to_info.rb | 6 ++++++ .../20150423221613_add_timestamps_to_existing_info.rb | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 db/migrate/20150423221202_add_timestamps_to_info.rb create mode 100644 db/migrate/20150423221613_add_timestamps_to_existing_info.rb diff --git a/db/migrate/20150423221202_add_timestamps_to_info.rb b/db/migrate/20150423221202_add_timestamps_to_info.rb new file mode 100644 index 0000000..61a8b58 --- /dev/null +++ b/db/migrate/20150423221202_add_timestamps_to_info.rb @@ -0,0 +1,6 @@ +class AddTimestampsToInfo < ActiveRecord::Migration + def change + add_column :info, :created_at, :datetime + add_column :info, :updated_at, :datetime + end +end \ No newline at end of file diff --git a/db/migrate/20150423221613_add_timestamps_to_existing_info.rb b/db/migrate/20150423221613_add_timestamps_to_existing_info.rb new file mode 100644 index 0000000..a02a4ae --- /dev/null +++ b/db/migrate/20150423221613_add_timestamps_to_existing_info.rb @@ -0,0 +1,7 @@ +class AddTimestampsToExistingInfo < ActiveRecord::Migration + def change + Info.all.each do |i| + i.update_attributes(created_at: Time.now) + end + end +end