From 8a99ab3acca7df86e3cb92fdffa7c87d46280333 Mon Sep 17 00:00:00 2001 From: Keilla Menezes Date: Wed, 2 Feb 2011 15:35:30 -0300 Subject: [PATCH] Added date for events with nil date --- db/migrate/20110202141024_set_start_date_of_reference_article.rb | 11 +++++++++++ db/schema.rb | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20110202141024_set_start_date_of_reference_article.rb diff --git a/db/migrate/20110202141024_set_start_date_of_reference_article.rb b/db/migrate/20110202141024_set_start_date_of_reference_article.rb new file mode 100644 index 0000000..cea45dc --- /dev/null +++ b/db/migrate/20110202141024_set_start_date_of_reference_article.rb @@ -0,0 +1,11 @@ +class SetStartDateOfReferenceArticle < ActiveRecord::Migration + def self.up + execute("SELECT articles.id as a_id, articles.start_date as a_start_date, reference.id as r_id, reference.start_date as r_start_date FROM articles INNER JOIN articles reference ON articles.reference_article_id = reference.id WHERE articles.Type = 'Event' AND articles.start_date IS NULL").each do |data| + execute("UPDATE articles SET start_date = '#{data['r_start_date']}' WHERE id = #{data['a_id']}") + end + end + + def self.down + say "Nothing to do" + end +end diff --git a/db/schema.rb b/db/schema.rb index 78db5a9..3cb1c6c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20101221134544) do +ActiveRecord::Schema.define(:version => 20110127174236) do create_table "action_tracker", :force => true do |t| t.integer "user_id" @@ -31,8 +31,8 @@ ActiveRecord::Schema.define(:version => 20101221134544) do t.integer "profile_id" end + add_index "action_tracker_notifications", ["action_tracker_id", "profile_id"], :name => "index_action_tracker_notifications_on_profile_id_and_action_tra", :unique => true add_index "action_tracker_notifications", ["action_tracker_id"], :name => "index_action_tracker_notifications_on_action_tracker_id" - add_index "action_tracker_notifications", ["profile_id", "action_tracker_id"], :name => "index_action_tracker_notifications_on_profile_id_and_action_tracker_id", :unique => true add_index "action_tracker_notifications", ["profile_id"], :name => "index_action_tracker_notifications_on_profile_id" create_table "article_versions", :force => true do |t| -- libgit2 0.21.2