diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-02-14 20:17:17 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-02-14 20:29:36 +0800 |
commit | ca659822257f21f09d5b22660ba7ae39395d79e6 (patch) | |
tree | 4a024b0a63362d2f388765f7d0e496b912022c1c /db | |
parent | ae93d08b9cf01b8a12a5f6cacbd9c89e87e54ac4 (diff) | |
download | gitlab-ce-ca659822257f21f09d5b22660ba7ae39395d79e6.tar.gz |
Use Gitlab::Database.with_connection_pool from !9192remove-inactive-default-email-services
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170206040400_remove_inactive_default_email_services.rb | 63 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 24 insertions, 41 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 249a9e805f1..a8e63e8bc7d 100644 --- a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb +++ b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb @@ -6,53 +6,36 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration disable_ddl_transaction! def up - pool = create_connection_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 + 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 end - end - 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 + 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 end - end - threads.each(&:join) - pool.disconnect! + threads.each(&:join) + end end def down # Nothing can be done to restore the records end - - private - - def create_connection_pool - # See activerecord-4.2.7.1/lib/active_record/connection_adapters/connection_specification.rb - env = Rails.env - original_config = ActiveRecord::Base.configurations - env_config = original_config[env].merge('pool' => 2) - config = original_config.merge(env => env_config) - - spec = - ActiveRecord:: - ConnectionAdapters:: - ConnectionSpecification::Resolver.new(config).spec(env.to_sym) - - ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec) - end end diff --git a/db/schema.rb b/db/schema.rb index de07b3837ad..d421d5c6774 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170204181513) do +ActiveRecord::Schema.define(version: 20170210075922) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |