Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-02-07 17:09:13 +0300
committerLin Jen-Shin <godfat@godfat.org>2017-02-14 15:14:22 +0300
commit7ecee7a4d79718bc46086ee8dec23a00cea39b39 (patch)
tree0eb94a99871165010c08a74f5401809d92c32197 /db
parent0c2f4a3c422c522bd32bdcf36425e836ebee8ea6 (diff)
Introduce ThreadedConnectionPool for customized pool
This way we could reuse this pool for other migrations Feedback: * https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8987#note_22923350 * https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8987#note_22923365
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20170206040400_remove_inactive_default_email_services.rb45
1 files changed, 17 insertions, 28 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 d69f68a13d2..52e7f91bb01 100644
--- a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
+++ b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
@@ -3,38 +3,27 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
DOWNTIME = false
- def up
- builds_service = spawn <<-SQL.strip_heredoc
- DELETE FROM services
- WHERE type = 'BuildsEmailService'
- AND active IS FALSE
- AND properties = '{"notify_only_broken_builds":true}';
- SQL
-
- pipelines_service = spawn <<-SQL.strip_heredoc
- DELETE FROM services
- WHERE type = 'PipelinesEmailService'
- AND active IS FALSE
- AND properties = '{"notify_only_broken_pipelines":true}';
- SQL
+ disable_ddl_transaction!
- [builds_service, pipelines_service].each(&:join)
- end
-
- private
+ def up
+ Gitlab::Database::ThreadedConnectionPool.with_pool(2) do |pool|
+ pool.execute_async <<-SQL.strip_heredoc
+ DELETE FROM services
+ WHERE type = 'BuildsEmailService'
+ AND active IS FALSE
+ AND properties = '{"notify_only_broken_builds":true}';
+ SQL
- def spawn(query)
- Thread.new do
- with_connection do |connection|
- connection.execute(query)
- end
+ pool.execute_async <<-SQL.strip_heredoc
+ DELETE FROM services
+ WHERE type = 'PipelinesEmailService'
+ AND active IS FALSE
+ AND properties = '{"notify_only_broken_pipelines":true}';
+ SQL
end
end
- def with_connection(&block)
- pool = ActiveRecord::Base.establish_connection
- pool.with_connection(&block)
- ensure
- pool.disconnect!
+ def down
+ # Nothing can be done to restore the records
end
end