Class: ActsAsCommentableMigration

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/templates/comment_migration.rb

Class Method Summary collapse

Class Method Details

.downObject



14
15
16
# File 'lib/generators/templates/comment_migration.rb', line 14

def self.down
  drop_table :comments
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/generators/templates/comment_migration.rb', line 2

def self.up
  create_table :comments, force: true do |t|
    t.references :commentable, polymorphic: true, null: false
    t.references :commenter, polymorphic: true, null: false
    t.integer :parent_id
    t.integer :children_comments_count, default: 0
    t.text :content
    t.timestamps
  end
  add_index :comments, :parent_id
end