summaryrefslogtreecommitdiff
path: root/db/migrate/20120607130928_acts_as_commentable_with_threading_migration.rb
blob: 3684a68a92217e62b2d930ad78e89adebaa73f1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class ActsAsCommentableWithThreadingMigration < ActiveRecord::Migration
  def self.up
    create_table :comments, :force => true do |t|
      t.integer :commentable_id, :default => 0
      t.string :commentable_type, :default => ""
      t.string :title, :default => ""
      t.text :body, :default => ""
      t.string :subject, :default => ""
      t.integer :user_id, :default => 0, :null => false
      t.integer :parent_id, :lft, :rgt
      t.timestamps
    end
    
    add_index :comments, :user_id
    add_index :comments, :commentable_id
  end
  
  def self.down
    drop_table :comments
  end
end