diff options
Diffstat (limited to 'db/post_migrate/20210513155546_backfill_nuget_temporary_packages_to_processing_status.rb')
-rw-r--r-- | db/post_migrate/20210513155546_backfill_nuget_temporary_packages_to_processing_status.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20210513155546_backfill_nuget_temporary_packages_to_processing_status.rb b/db/post_migrate/20210513155546_backfill_nuget_temporary_packages_to_processing_status.rb new file mode 100644 index 00000000000..8124f94b519 --- /dev/null +++ b/db/post_migrate/20210513155546_backfill_nuget_temporary_packages_to_processing_status.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class BackfillNugetTemporaryPackagesToProcessingStatus < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + class Package < ActiveRecord::Base + include EachBatch + + self.table_name = 'packages_packages' + + scope :nuget_temporary_packages, -> do + # 4 is nuget package type, 0 is default status + where(package_type: 4, name: 'NuGet.Temporary.Package', status: 0) + end + end + + def up + Package.nuget_temporary_packages.each_batch(of: 100) do |batch| + # 2 is processing status + batch.update_all(status: 2) + end + end + + def down + # no-op + end +end |