2017-02-06 04:22:55 +00:00
|
|
|
class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
|
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
|
2017-02-07 14:09:13 +00:00
|
|
|
disable_ddl_transaction!
|
2017-02-06 04:39:36 +00:00
|
|
|
|
2017-02-07 14:09:13 +00:00
|
|
|
def up
|
2017-02-14 12:17:17 +00:00
|
|
|
Gitlab::Database.with_connection_pool(2) do |pool|
|
|
|
|
threads = []
|
|
|
|
|
|
|
|
threads << Thread.new do
|
|
|
|
pool.with_connection do |connection|
|
|
|
|
connection.execute <<-SQL.strip_heredoc
|
|
|
|
DELETE FROM services
|
|
|
|
WHERE type = 'BuildsEmailService'
|
|
|
|
AND active IS FALSE
|
|
|
|
AND properties = '{"notify_only_broken_builds":true}';
|
|
|
|
SQL
|
|
|
|
end
|
2017-02-09 13:11:31 +00:00
|
|
|
end
|
2017-02-06 04:39:36 +00:00
|
|
|
|
2017-02-14 12:17:17 +00:00
|
|
|
threads << Thread.new do
|
|
|
|
pool.with_connection do |connection|
|
|
|
|
connection.execute <<-SQL.strip_heredoc
|
|
|
|
DELETE FROM services
|
|
|
|
WHERE type = 'PipelinesEmailService'
|
|
|
|
AND active IS FALSE
|
|
|
|
AND properties = '{"notify_only_broken_pipelines":true}';
|
|
|
|
SQL
|
|
|
|
end
|
2017-02-09 13:11:31 +00:00
|
|
|
end
|
|
|
|
|
2017-02-14 12:17:17 +00:00
|
|
|
threads.each(&:join)
|
|
|
|
end
|
2017-02-06 04:22:55 +00:00
|
|
|
end
|
|
|
|
|
2017-02-07 14:09:13 +00:00
|
|
|
def down
|
|
|
|
# Nothing can be done to restore the records
|
2017-02-06 04:39:36 +00:00
|
|
|
end
|
2017-02-06 04:22:55 +00:00
|
|
|
end
|