20161227192806_rename_slack_and_mattermost_notification_services.rb 893 Bytes
Newer Older
1
# rubocop:disable Migration/UpdateColumnInBatches
2
class RenameSlackAndMattermostNotificationServices < ActiveRecord::Migration[4.2]
3 4 5 6
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

7 8
  disable_ddl_transaction!

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  def up
    update_column_in_batches(:services, :type, 'SlackService') do |table, query|
      query.where(table[:type].eq('SlackNotificationService'))
    end

    update_column_in_batches(:services, :type, 'MattermostService') do |table, query|
      query.where(table[:type].eq('MattermostNotificationService'))
    end
  end

  def down
    update_column_in_batches(:services, :type, 'SlackNotificationService') do |table, query|
      query.where(table[:type].eq('SlackService'))
    end

    update_column_in_batches(:services, :type, 'MattermostNotificationService') do |table, query|
      query.where(table[:type].eq('MattermostService'))
    end
  end
end