Skip to content
代码片段 群组 项目
未验证 提交 333dd173 编辑于 作者: Omar Qunsul's avatar Omar Qunsul 提交者: GitLab
浏览文件

Merge branch 'morefice/fix-finalize-background-migration-database-name' into 'master'

Fix OverdueFinalizeBackgroundMigration#database_name

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/184021



Merged-by: default avatarOmar Qunsul <oqunsul@gitlab.com>
Approved-by: default avatarOmar Qunsul <oqunsul@gitlab.com>
Approved-by: default avatarBishwa Hang Rai <bhrai@gitlab.com>
Co-authored-by: default avatarMaxime Orefice <morefice@gitlab.com>
未找到相关分支
未找到相关标签
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.
想要评论请 注册