Commit b7d1217d authored by Thong Kuah's avatar Thong Kuah

Allow old background migration that does cross-DB query

parent 8cfb1472
...@@ -9,14 +9,17 @@ module EE ...@@ -9,14 +9,17 @@ module EE
override :perform override :perform
def perform(start_id, stop_id) def perform(start_id, stop_id)
execute <<~SQL # Introduced in GitLab 12.9, will be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/33124
INSERT INTO security_scans (created_at, updated_at, build_id, scan_type) ::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/331248') do
SELECT ci_job_artifacts.created_at, ci_job_artifacts.updated_at, ci_job_artifacts.job_id, ci_job_artifacts.file_type - 4 execute <<~SQL
FROM ci_job_artifacts INSERT INTO security_scans (created_at, updated_at, build_id, scan_type)
WHERE ci_job_artifacts.id BETWEEN #{start_id} AND #{stop_id} SELECT ci_job_artifacts.created_at, ci_job_artifacts.updated_at, ci_job_artifacts.job_id, ci_job_artifacts.file_type - 4
AND ci_job_artifacts.file_type BETWEEN 5 and 8 FROM ci_job_artifacts
ON CONFLICT (build_id, scan_type) DO NOTHING; WHERE ci_job_artifacts.id BETWEEN #{start_id} AND #{stop_id}
SQL AND ci_job_artifacts.file_type BETWEEN 5 and 8
ON CONFLICT (build_id, scan_type) DO NOTHING;
SQL
end
end end
def execute(sql) def execute(sql)
......
...@@ -38,7 +38,10 @@ module EE ...@@ -38,7 +38,10 @@ module EE
AND "vulnerability_feedback"."project_id" = "pipelines_with_reports"."project_id"; AND "vulnerability_feedback"."project_id" = "pipelines_with_reports"."project_id";
SQL SQL
connection.execute(update_feedback_pipeline_id_sql) # Introduced in GitLab 13.6, will be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/331248
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/331248') do
connection.execute(update_feedback_pipeline_id_sql)
end
end end
def pipelines_with_security_reports_subquery(project_ids) def pipelines_with_security_reports_subquery(project_ids)
......
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
- "./ee/spec/finders/ee/namespaces/projects_finder_spec.rb" - "./ee/spec/finders/ee/namespaces/projects_finder_spec.rb"
- "./ee/spec/graphql/ee/resolvers/namespace_projects_resolver_spec.rb" - "./ee/spec/graphql/ee/resolvers/namespace_projects_resolver_spec.rb"
- "./ee/spec/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb" - "./ee/spec/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb"
- "./ee/spec/lib/ee/gitlab/background_migration/migrate_security_scans_spec.rb"
- "./ee/spec/lib/ee/gitlab/background_migration/populate_latest_pipeline_ids_spec.rb" - "./ee/spec/lib/ee/gitlab/background_migration/populate_latest_pipeline_ids_spec.rb"
- "./ee/spec/lib/ee/gitlab/background_migration/populate_resolved_on_default_branch_column_spec.rb" - "./ee/spec/lib/ee/gitlab/background_migration/populate_resolved_on_default_branch_column_spec.rb"
- "./ee/spec/lib/ee/gitlab/background_migration/populate_uuids_for_security_findings_spec.rb" - "./ee/spec/lib/ee/gitlab/background_migration/populate_uuids_for_security_findings_spec.rb"
- "./ee/spec/lib/ee/gitlab/background_migration/populate_vulnerability_feedback_pipeline_id_spec.rb"
- "./ee/spec/lib/ee/gitlab/usage_data_spec.rb" - "./ee/spec/lib/ee/gitlab/usage_data_spec.rb"
- "./ee/spec/migrations/schedule_populate_resolved_on_default_branch_column_spec.rb" - "./ee/spec/migrations/schedule_populate_resolved_on_default_branch_column_spec.rb"
- "./ee/spec/models/ci/build_spec.rb" - "./ee/spec/models/ci/build_spec.rb"
......
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