Commit ca659822 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use Gitlab::Database.with_connection_pool from !9192

parent ae93d08b
......@@ -6,7 +6,7 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
disable_ddl_transaction!
def up
pool = create_connection_pool
Gitlab::Database.with_connection_pool(2) do |pool|
threads = []
threads << Thread.new do
......@@ -32,27 +32,10 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
end
threads.each(&:join)
pool.disconnect!
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
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment