Class: CreateComments

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

Instance Method Summary collapse

Instance Method Details

#changeObject



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

def change
  create_table :comments do |t|
    t.text       :message
    t.references :user, index: true
    t.references :commentable, polymorphic: true
    t.string     :groups
    t.string     :mentions

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