From ab4af170fbb8675a882e916143a08d8de8901d3b Mon Sep 17 00:00:00 2001 From: moshenglv Date: Wed, 20 Jan 2021 13:52:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9E=E6=8E=A5ci=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=90=8D=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=A0=B9=E6=8D=AErepo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ci/base_controller.rb | 1 + app/controllers/concerns/ci/db_connectable.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/ci/base_controller.rb b/app/controllers/ci/base_controller.rb index c17105cd6..5aedbddbf 100644 --- a/app/controllers/ci/base_controller.rb +++ b/app/controllers/ci/base_controller.rb @@ -63,6 +63,7 @@ class Ci::BaseController < ApplicationController if current.ci_cloud_account.server_type == Ci::CloudAccount::SERVER_TYPE_TRUSTIE connect_to_trustie_ci_database(options) else + options = options.merge(db_name: current.login) connect_to_ci_database(options) end diff --git a/app/controllers/concerns/ci/db_connectable.rb b/app/controllers/concerns/ci/db_connectable.rb index 559384a59..e2c8ffefd 100644 --- a/app/controllers/concerns/ci/db_connectable.rb +++ b/app/controllers/concerns/ci/db_connectable.rb @@ -17,7 +17,8 @@ module Ci::DbConnectable password: db_config[:password], port: db_config[:port] } - req_params = req_params.merge(database: "#{current_user.login}_#{db_config[:database]}") unless master_db === true + db_name = options[:db_name].blank? ? current_user.login : options[:db_name] + req_params = req_params.merge(database: "#{db_name}_#{db_config[:database]}") unless master_db === true db_params = Ci::Database.get_connection_params(req_params) @connection = Ci::Database.set_connection(db_params).connection