Class: CreateComments
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- CreateComments
- Defined in:
- lib/generators/threadable_comments/migration/templates/migration.rb
Overview
Migration responsible for creating a table for comments
Class Method Summary collapse
-
.down ⇒ Object
Drop table.
-
.up ⇒ Object
Create table.
Class Method Details
.down ⇒ Object
Drop table
20 21 22 |
# File 'lib/generators/threadable_comments/migration/templates/migration.rb', line 20 def self.down drop_table :comments end |
.up ⇒ Object
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. null: false end add_index :comments, :user_id add_index :comments, :ancestry add_index :comments, :commentable_id end |