Class: SunriseCreateComments

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

Class Method Summary collapse

Class Method Details

.downObject



22
23
24
# File 'lib/generators/sunrise/comments/templates/create_comments.rb', line 22

def self.down
  drop_table :comments
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/sunrise/comments/templates/create_comments.rb', line 2

def self.up
  create_table :comments do |t|
    t.string :user_name, :limit => 50
    t.string :user_email, :limit => 50
    t.text :content, :null => false
    t.text :content_html
    t.integer :commentable_id, :default => 0, :null => false
    t.string :commentable_type, :limit => 15, :default => "", :null => false
    t.boolean :is_follow, :default => false

    t.integer :author_id
    t.string :author_type, :limit => 25
  
    t.timestamps
  end
  
  add_index :comments, [:author_type, :author_id]
  add_index :comments, [:commentable_type, :commentable_id]
end