ref: master
plugins/admin_notifications/db/migrate/20160330171610_rename_plugin_tables.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
class RenamePluginTables < ActiveRecord::Migration def up remove_index :environment_notifications_users, name: :index_Zaem6uuw remove_index :environment_notifications_users, name: :index_ap3nohR9 rename_column :environment_notifications_users, :environment_notification_id, :notification_id rename_table :environment_notifications, :admin_notifications_plugin_notifications rename_table :environment_notifications_users, :admin_notifications_plugin_notifications_users add_index :admin_notifications_plugin_notifications_users, [:notification_id], :name => :index_notifications_users_notification_id add_index :admin_notifications_plugin_notifications_users, [:user_id], :name => :index_notifications_users_user_id Environment.all.each do |e| if e.enabled_plugins.include?('EnvironmentNotificationPlugin') e.enabled_plugins -= ['EnvironmentNotificationPlugin'] e.enabled_plugins += ['AdminNotificationsPlugin'] e.save! end end end def down remove_index :admin_notifications_plugin_notifications_users, :name => :index_notifications_users_notification_id remove_index :admin_notifications_plugin_notifications_users, :name => :index_notifications_users_user_id rename_table :admin_notifications_plugin_notifications, :environment_notifications rename_table :admin_notifications_plugin_notifications_users, :environment_notifications_users rename_column :environment_notifications_users, :notification_id, :environment_notification_id add_index :environment_notifications_users, [:environment_notification_id], name: :index_Zaem6uuw add_index :environment_notifications_users, [:user_id], name: :index_ap3nohR9 end Environment.all.each do |e| if e.enabled_plugins.include?('AdminNotificationsPlugin') e.enabled_plugins -= ['AdminNotificationsPlugin'] e.enabled_plugins += ['EnvironmentNotificationPlugin'] e.save! end end end |