Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-09 21:08:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-09 21:08:15 +0300
commit7d8fc3b6b67a22969cd1fa5cb018fc22e6aa1ade (patch)
tree4b93bb357e5f29bc0e97dac5a15c111277411a8d /lib/gitlab/background_migration
parentfd8183c340684448fd976af9c0b4217fa58d7211 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/background_migration')
-rw-r--r--lib/gitlab/background_migration/disable_legacy_open_source_license_for_projects_less_than_five_mb.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/disable_legacy_open_source_license_for_projects_less_than_five_mb.rb b/lib/gitlab/background_migration/disable_legacy_open_source_license_for_projects_less_than_five_mb.rb
new file mode 100644
index 00000000000..dcef4f086e2
--- /dev/null
+++ b/lib/gitlab/background_migration/disable_legacy_open_source_license_for_projects_less_than_five_mb.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Set `project_settings.legacy_open_source_license_available` to false for projects less than 5 MB
+ class DisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb < ::Gitlab::BackgroundMigration::BatchedMigrationJob
+ scope_to ->(relation) do
+ relation
+ .where(legacy_open_source_license_available: true)
+ end
+
+ operation_name :disable_legacy_open_source_license_for_projects_less_than_five_mb
+
+ def perform
+ each_sub_batch do |sub_batch|
+ updates = { legacy_open_source_license_available: false, updated_at: Time.current }
+
+ sub_batch
+ .joins('INNER JOIN project_statistics ON project_statistics.project_id = project_settings.project_id')
+ .where('project_statistics.repository_size < ?', 5.megabyte)
+ .update_all(updates)
+ end
+ end
+ end
+ end
+end