diff --git a/keeps/overdue_finalize_background_migration.rb b/keeps/overdue_finalize_background_migration.rb index fb67d5dd9f9c73ba2693331490b31f471b6d09be..27375f58f563c2a94e42067323fe8de5f70f7e01 100644 --- a/keeps/overdue_finalize_background_migration.rb +++ b/keeps/overdue_finalize_background_migration.rb @@ -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 diff --git a/spec/keeps/overdue_finalize_background_migration_spec.rb b/spec/keeps/overdue_finalize_background_migration_spec.rb index 25d99d55c570ff89d6ce53a8b750682b0d843ea1..722128f566459b4bc5ec63509f02df7d7b103b1f 100644 --- a/spec/keeps/overdue_finalize_background_migration_spec.rb +++ b/spec/keeps/overdue_finalize_background_migration_spec.rb @@ -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