cirandas.net

ref: master

db/migrate/20100921121528_add_is_image_to_articles.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class AddIsImageToArticles < ActiveRecord::Migration
  def self.up
     add_column :articles, :is_image, :boolean, :default => false
     add_column :article_versions, :is_image, :boolean, :default => false

     execute ApplicationRecord.sanitize_sql(["update articles set is_image = ? where articles.content_type like 'image/%'", true])
  end

  def self.down
     remove_column :articles, :is_image
     remove_column :article_versions, :is_image
  end
end