Class: CreateComments

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

Overview

Migration responsible for creating a table for comments

Class Method Summary collapse

Class Method Details

.downObject

Drop table



20
21
22
# File 'lib/generators/threadable_comments/migration/templates/migration.rb', line 20

def self.down
  drop_table :comments
end

.upObject

Create table



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

def self.up
  create_table :comments, force: true do |t|
    t.belongs_to :commentable, :polymorphic => true, null: false
    t.integer 'user_id', null: false
    t.text 'text', default: ''
    t.text 'parameters', default: ''
    t.string 'ancestry'
    t.timestamps null: false
  end

  add_index :comments, :user_id
  add_index :comments, :ancestry
  add_index :comments, :commentable_id
end