master
1class MoveAdminNotesToComments < ActiveRecord::Migration
2 def self.up
3 remove_index :admin_notes, [:admin_user_type, :admin_user_id]
4 rename_table :admin_notes, :active_admin_comments
5 rename_column :active_admin_comments, :admin_user_type, :author_type
6 rename_column :active_admin_comments, :admin_user_id, :author_id
7 add_column :active_admin_comments, :namespace, :string
8 add_index :active_admin_comments, [:namespace]
9 add_index :active_admin_comments, [:author_type, :author_id]
10
11 # Update all the existing comments to the default namespace
12 #say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
13 #execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
14 end
15
16 def self.down
17 remove_index :active_admin_comments, :column => [:author_type, :author_id]
18 remove_index :active_admin_comments, :column => [:namespace]
19 remove_column :active_admin_comments, :namespace
20 rename_column :active_admin_comments, :author_id, :admin_user_id
21 rename_column :active_admin_comments, :author_type, :admin_user_type
22 rename_table :active_admin_comments, :admin_notes
23 add_index :admin_notes, [:admin_user_type, :admin_user_id]
24 end
25end