Class: CreateComments

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

Instance Method Summary collapse

Instance Method Details

#downObject



16
17
18
# File 'lib/generators/comments/templates/comments_table.rb', line 16

def down
  drop_table :comments
end

#upObject



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

def up
  create_table :comments do |t|
    t.text       :body
    t.references :user, index: true
    t.references :commentable, polymorphic: true
    t.string     :group
    t.string     :topic

    t.timestamps
  end
  add_index :comments, :commentable_type
  add_index :comments, :commentable_id
end