ref: master
db/migrate/20110202141024_set_start_date_of_reference_article.rb
1 2 3 4 5 6 7 8 9 10 11 |
class SetStartDateOfReferenceArticle < ActiveRecord::Migration def self.up execute("SELECT articles.id as a_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 |