Class: MoveAdminNotesToComments
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- MoveAdminNotesToComments
- Defined in:
- lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb
Class Method Summary collapse
Class Method Details
.down ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb', line 16 def self.down remove_index :active_admin_comments, :column => [:author_type, :author_id] remove_index :active_admin_comments, :column => [:namespace] remove_column :active_admin_comments, :namespace rename_column :active_admin_comments, :author_id, :admin_user_id rename_column :active_admin_comments, :author_type, :admin_user_type rename_table :active_admin_comments, :admin_notes add_index :admin_notes, [:admin_user_type, :admin_user_id] end |
.up ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb', line 2 def self.up remove_index :admin_notes, [:admin_user_type, :admin_user_id] rename_table :admin_notes, :active_admin_comments rename_column :active_admin_comments, :admin_user_type, :author_type rename_column :active_admin_comments, :admin_user_id, :author_id add_column :active_admin_comments, :namespace, :string add_index :active_admin_comments, [:namespace] add_index :active_admin_comments, [:author_type, :author_id] # Update all the existing comments to the default namespace say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace." execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'" end |