From a7702271391524262788accfc78e6ef58b63f88e Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 6 Feb 2017 12:22:55 +0800 Subject: Remove inactive default email services Note that we no longer generate this by default. This is for clearing legacy default data. --- .../remove-inactive-default-email-services.yml | 4 ++++ ...40400_remove_inactive_default_email_services.rb | 27 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 changelogs/unreleased/remove-inactive-default-email-services.yml create mode 100644 db/post_migrate/20170206040400_remove_inactive_default_email_services.rb 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 00000000000..c32c1390e4e --- /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 00000000000..18affebde73 --- /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 -- cgit v1.2.1