ref: master
db/migrate/063_add_published_at_and_source_to_articles.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
class AddPublishedAtAndSourceToArticles < ActiveRecord::Migration def self.up add_column :articles, :published_at, :date add_column :article_versions, :published_at, :date execute('UPDATE articles SET published_at = created_at WHERE published_at IS NULL') execute('UPDATE article_versions SET published_at = created_at WHERE published_at IS NULL') add_column :articles, :source, :string, :null => true add_column :article_versions, :source, :string, :null => true end def self.down remove_column :articles, :published_at remove_column :article_versions, :published_at remove_column :articles, :source remove_column :article_versions, :source end end |