summaryrefslogtreecommitdiff
path: root/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
blob: 18affebde73750dbd6217eecf8f9c82a85e56aa2 (plain)
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
class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  def up
    execute <<-SQL.strip_heredoc
      DELETE FROM services
        WHERE type = 'BuildsEmailService'
          AND active = #{false_value}
          AND properties = '{"notify_only_broken_builds":true}';

      DELETE FROM services
        WHERE type = 'PipelinesEmailService'
          AND active = #{false_value}
          AND properties = '{"notify_only_broken_pipelines":true}';
    SQL
  end

  def false_value
    quote(false)
  end

  def quote(value)
    ActiveRecord::Base.connection.quote(value)
  end
end