Class: ActsAsCommentableUpgradeMigration

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

Class Method Summary collapse

Class Method Details

.downObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/acts_as_commentable_upgrade_migration/templates/migration.rb', line 13

def self.down
  rename_column :comments, :body, :comment
  remove_column :comments, :subject
  remove_column :comments, :parent_id
  remove_column :comments, :lft
  remove_column :comments, :rgt
  remove_column :comments, :updated_at
  
  remove_index :comments, :commentable_id
end

.upObject



2
3
4
5
6
7
8
9
10
11
# File 'lib/generators/acts_as_commentable_upgrade_migration/templates/migration.rb', line 2

def self.up
  rename_column :comments, :comment, :body
  add_column :comments, :subject, :string
  add_column :comments, :parent_id, :integer
  add_column :comments, :lft, :integer
  add_column :comments, :rgt, :integer
  add_column :comments, :updated_at, :datetime
  
  add_index :comments, :commentable_id
end