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:
Diffstat (limited to 'lib/gitlab/background_migration/set_null_package_files_file_store_to_local_value.rb')
-rw-r--r--lib/gitlab/background_migration/set_null_package_files_file_store_to_local_value.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/set_null_package_files_file_store_to_local_value.rb b/lib/gitlab/background_migration/set_null_package_files_file_store_to_local_value.rb
new file mode 100644
index 00000000000..9ac92aab637
--- /dev/null
+++ b/lib/gitlab/background_migration/set_null_package_files_file_store_to_local_value.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # This class is responsible for migrating a range of package files
+ # with file_store == NULL to 1.
+ #
+ # The index `index_packages_package_files_file_store_is_null` is
+ # expected to be used to find the rows here and in the migration scheduling
+ # the jobs that run this class.
+ class SetNullPackageFilesFileStoreToLocalValue
+ LOCAL_STORE = 1 # equal to ObjectStorage::Store::LOCAL
+
+ # Temporary AR class for package files
+ class PackageFile < ActiveRecord::Base
+ self.table_name = 'packages_package_files'
+ end
+
+ def perform(start_id, stop_id)
+ Packages::PackageFile.where(file_store: nil, id: start_id..stop_id).update_all(file_store: LOCAL_STORE)
+ end
+ end
+ end
+end