Skip to content
代码片段 群组 项目
未验证 提交 26878c28 编辑于 作者: Maxime Orefice's avatar Maxime Orefice
浏览文件

Fix OverdueFinalizeBackgroundMigration#database_name

上级 2350f740
No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
...@@ -272,10 +272,10 @@ def migration_code_in_ee?(file_name) ...@@ -272,10 +272,10 @@ def migration_code_in_ee?(file_name)
) )
end end
private
def database_name(migration_record) def database_name(migration_record)
migration_record.gitlab_schema.split("_").last gitlab_schema = migration_record.gitlab_schema
connection = Gitlab::Database.schemas_to_base_models[gitlab_schema].first.connection
Gitlab::Database.db_config_name(connection)
end end
end end
end end
...@@ -96,4 +96,36 @@ ...@@ -96,4 +96,36 @@
end end
end end
end end
describe '#database_name' do
let(:migration_record) do
MigrationRecord.new(id: 1, finished_at: "2020-04-01 12:00:01", gitlab_schema: gitlab_schema)
end
subject(:database_name) { keep.database_name(migration_record) }
context 'when schema is gitlab_main_cell' do
let(:gitlab_schema) { 'gitlab_main_cell' }
it 'returns the database name' do
expect(database_name).to eq('main')
end
end
context 'when schema is gitlab_main' do
let(:gitlab_schema) { 'gitlab_main' }
it 'returns the database name' do
expect(database_name).to eq('main')
end
end
context 'when schema is gitlab_ci' do
let(:gitlab_schema) { 'gitlab_ci' }
it 'returns the database name' do
expect(database_name).to eq('ci')
end
end
end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册