Commit 4dc48bc2 authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-background-migration-double-parsing' into 'master'

Fix null argument handling in background migration Rake task

See merge request gitlab-org/gitlab!84318
parents a9bc2aa9 b6f60ccc
......@@ -961,7 +961,7 @@ module Gitlab
"\n\n" \
"Finalize it manualy by running" \
"\n\n" \
"\tsudo gitlab-rake gitlab:background_migrations:finalize[#{job_class_name},#{table_name},#{column_name},'#{job_arguments.inspect.gsub(',', '\,')}']" \
"\tsudo gitlab-rake gitlab:background_migrations:finalize[#{job_class_name},#{table_name},#{column_name},'#{job_arguments.to_json.gsub(',', '\,')}']" \
"\n\n" \
"For more information, check the documentation" \
"\n\n" \
......
......@@ -19,7 +19,7 @@ namespace :gitlab do
args[:job_class_name],
args[:table_name],
args[:column_name],
Gitlab::Json.parse(args[:job_arguments]),
args[:job_arguments],
connection: main_model.connection
)
end
......@@ -38,7 +38,7 @@ namespace :gitlab do
args[:job_class_name],
args[:table_name],
args[:column_name],
Gitlab::Json.parse(args[:job_arguments]),
args[:job_arguments],
connection: model.connection
)
end
......
......@@ -2211,7 +2211,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
table_name: :events,
column_name: :id,
job_arguments: [["id"], ["id_convert_to_bigint"]]
job_arguments: [["id"], ["id_convert_to_bigint"], nil]
}
end
......@@ -2226,7 +2226,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
"\n\n" \
"Finalize it manualy by running" \
"\n\n" \
"\tsudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,events,id,'[[\"id\"]\\, [\"id_convert_to_bigint\"]]']" \
"\tsudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,events,id,'[[\"id\"]\\,[\"id_convert_to_bigint\"]\\,null]']" \
"\n\n" \
"For more information, check the documentation" \
"\n\n" \
......
......@@ -42,6 +42,17 @@ RSpec.describe 'gitlab:background_migrations namespace rake tasks' do
end
end
context 'with a null parameter' do
let(:arguments) { %w[ProjectNamespaces::BackfillProjectNamespaces projects id] + ['[null\, "up"]'] }
it 'finalizes the matching migration' do
expect(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner).to receive(:finalize)
.with('ProjectNamespaces::BackfillProjectNamespaces', 'projects', 'id', [nil, "up"], connection: connection)
expect { finalize_task }.to output(/Done/).to_stdout
end
end
context 'when multiple database feature is enabled' do
subject(:finalize_task) { run_rake_task("gitlab:background_migrations:finalize:#{ci_database_name}", *arguments) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment