Class: ActsAsCommentableWithThreadingMigration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/acts_as_commentable_with_threading_migration/templates/migration.rb

Class Method Summary collapse

Class Method Details

.downObject



18
19
20
# File 'lib/generators/acts_as_commentable_with_threading_migration/templates/migration.rb', line 18

def self.down
  drop_table :comments
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/acts_as_commentable_with_threading_migration/templates/migration.rb', line 2

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