Skip to content
代码片段 群组 项目
未验证 提交 13a65cd5 编辑于 作者: Jan Provaznik's avatar Jan Provaznik 提交者: GitLab
浏览文件

Merge branch 'morefice/add-schema-to-finalize-migration-keep' into 'master'

Add database_name to OverdueFinalizeBackgroundMigration keep

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



Merged-by: default avatarJan Provaznik <jprovaznik@gitlab.com>
Approved-by: default avatarPedro Pombeiro <noreply@pedro.pombei.ro>
Approved-by: default avatarJan Provaznik <jprovaznik@gitlab.com>
Reviewed-by: default avatarPedro Pombeiro <noreply@pedro.pombei.ro>
Reviewed-by: default avatarMax Orefice <morefice@gitlab.com>
Co-authored-by: default avatarMaxime Orefice <morefice@gitlab.com>
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
......@@ -93,7 +93,7 @@ def change_description(migration_record, job_name, last_migration_file)
To confirm it is finished you can run:
```
/chatops run batched_background_migrations status #{migration_record.id}
/chatops run batched_background_migrations status #{migration_record.id} --database #{database_name(migration_record)}
```
The last time this background migration was triggered was in [#{last_migration_file}](https://gitlab.com/gitlab-org/gitlab/-/blob/master/#{last_migration_file})
......@@ -271,5 +271,11 @@ def migration_code_in_ee?(file_name)
Rails.root.join(*%w[ee lib ee gitlab background_migration]).join(file_name)
)
end
private
def database_name(migration_record)
migration_record.gitlab_schema.split("_").last
end
end
end
......@@ -3,7 +3,7 @@
require 'spec_helper'
require './keeps/overdue_finalize_background_migration'
MigrationRecord = Struct.new(:id, :finished_at, :updated_at)
MigrationRecord = Struct.new(:id, :finished_at, :updated_at, :gitlab_schema)
RSpec.describe Keeps::OverdueFinalizeBackgroundMigration, feature_category: :tooling do
subject(:keep) { described_class.new }
......@@ -11,7 +11,10 @@
describe '#initialize_change' do
let(:migration) { { 'feature_category' => 'shared' } }
let(:feature_category) { migration['feature_category'] }
let(:migration_record) { MigrationRecord.new(id: 1, finished_at: "2020-04-01 12:00:01") }
let(:migration_record) do
MigrationRecord.new(id: 1, finished_at: "2020-04-01 12:00:01", gitlab_schema: 'gitlab_main')
end
let(:job_name) { "test_background_migration" }
let(:last_migration_file) { "db/post_migrate/20200331140101_queue_test_background_migration.rb" }
let(:groups_helper) { instance_double(::Keeps::Helpers::Groups) }
......@@ -41,9 +44,13 @@
end
describe '#change_description' do
let(:migration_record) { MigrationRecord.new(id: 1, finished_at: "2020-04-01 12:00:01") }
let(:migration_record) do
MigrationRecord.new(id: 1, finished_at: "2020-04-01 12:00:01", gitlab_schema: 'gitlab_main')
end
let(:job_name) { "test_background_migration" }
let(:last_migration_file) { "db/post_migrate/20200331140101_queue_test_background_migration.rb" }
let(:chatops_command) { %r{/chatops run batched_background_migrations status \d+ --database main} }
subject(:description) { keep.change_description(migration_record, job_name, last_migration_file) }
......@@ -55,6 +62,10 @@
it 'does not contain a warning' do
expect(description).not_to match(/^### Warning/)
end
it 'contains the database name' do
expect(description).to match(chatops_command)
end
end
context 'when migration code is absent' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册