cirandas.net

ref: master

db/migrate/037_add_dates_to_articles.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class AddDatesToArticles < ActiveRecord::Migration

  def self.each_table
    [ :articles, :article_versions ].each do |table|
      yield(table)
    end
  end

  def self.up
    each_table do |table|
      add_column table, :start_date, :date
      add_column table, :end_date, :date
    end
  end

  def self.down
    each_table do |table|
      remove_column table, :start_date
      remove_column table, :end_date
    end
  end
end