public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
yaroslav (author)
Sun May 11 04:06:30 -0700 2008
commit  33a730791242bb12b2bcd8cfab0a59e2b750b725
tree    1d883f402575865a5d3bf8ea2cbf9a920812966a
parent  bc58c2c800ee1bb8e33b4054e8565ce7e19ee8fa
mephisto / db / migrate / 029_add_correct_comment_lifetime.rb
100644 32 lines (29 sloc) 1.333 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class AddCorrectCommentLifetime < ActiveRecord::Migration
  class Site < ActiveRecord::Base ; end
  class Content < ActiveRecord::Base ; end
  class Article < Content ; end
 
  def self.up
    remove_column "sites", "comment_lifetime"
    remove_column "sites", "comment_link_max"
    add_column "sites", "accept_comments", :boolean
    add_column "sites", "approve_comments", :boolean
    add_column "sites", "comment_age", :integer
    add_column "contents", "expire_comments_at", :datetime
    add_column "content_versions", "expire_comments_at", :datetime
    Site.find(:all, :select => 'id, accept_comments, approve_comments, comment_age').each do |site|
      site.update_attributes(:accept_comments => true, :approve_comments => false, :comment_age => 30)
    end
    Article.find(:all, :select => 'id, created_at, expire_comments_at').each do |article|
      article.update_attribute(:expire_comments_at, (article.created_at + 30.days))
    end
  end
 
  def self.down
    add_column "sites", "comment_lifetime", :integer
    add_column "sites", "comment_link_max", :integer
    remove_column "sites", "accept_comments"
    remove_column "sites", "approve_comments"
    remove_column "sites", "comment_age"
    remove_column "contents", "expire_comments_at"
    remove_column "content_versions", "expire_comments_at"
  end
end