diff --git a/changelogs/unreleased/remove-inactive-default-email-services.yml b/changelogs/unreleased/remove-inactive-default-email-services.yml new file mode 100644 index 0000000000000000000000000000000000000000..c32c1390e4e8301daaabdadac8a31cd362fe2f8e --- /dev/null +++ b/changelogs/unreleased/remove-inactive-default-email-services.yml @@ -0,0 +1,4 @@ +--- +title: Remove inactive default email services +merge_request: 8987 +author: diff --git a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb new file mode 100644 index 0000000000000000000000000000000000000000..18affebde73750dbd6217eecf8f9c82a85e56aa2 --- /dev/null +++ b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb @@ -0,0 +1,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