diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-02-06 07:39:36 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-02-14 15:13:54 +0300 |
commit | 25cd5aa228ebe10ce9eabb17c75eb86e9d8c152c (patch) | |
tree | 5869807c8e42b9cfec895a8147ebc1b05ec7b4ad /db | |
parent | a7702271391524262788accfc78e6ef58b63f88e (diff) |
Run two threads to improve migration running time
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170206040400_remove_inactive_default_email_services.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb index 18affebde73..dc7750f3244 100644 --- a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb +++ b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb @@ -4,24 +4,38 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration DOWNTIME = false def up - execute <<-SQL.strip_heredoc + builds_service = spawn <<-SQL.strip_heredoc DELETE FROM services WHERE type = 'BuildsEmailService' AND active = #{false_value} AND properties = '{"notify_only_broken_builds":true}'; + SQL + pipelines_service = spawn <<-SQL.strip_heredoc DELETE FROM services WHERE type = 'PipelinesEmailService' AND active = #{false_value} AND properties = '{"notify_only_broken_pipelines":true}'; SQL + + [builds_service, pipelines_service].each(&:join) end - def false_value - quote(false) + private + + def spawn(query) + Thread.new do + ActiveRecord::Base.connection_pool.with_connection do + ActiveRecord::Base.connection.execute(query) + end + end end def quote(value) ActiveRecord::Base.connection.quote(value) end + + def false_value + quote(false) + end end |