diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /db/post_migrate/20210415155043_move_container_registry_enabled_to_project_features3.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'db/post_migrate/20210415155043_move_container_registry_enabled_to_project_features3.rb')
-rw-r--r-- | db/post_migrate/20210415155043_move_container_registry_enabled_to_project_features3.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/db/post_migrate/20210415155043_move_container_registry_enabled_to_project_features3.rb b/db/post_migrate/20210415155043_move_container_registry_enabled_to_project_features3.rb new file mode 100644 index 00000000000..6fd8d280c97 --- /dev/null +++ b/db/post_migrate/20210415155043_move_container_registry_enabled_to_project_features3.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class MoveContainerRegistryEnabledToProjectFeatures3 < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + include Gitlab::Database::DynamicModelHelpers + + BATCH_SIZE = 21_000 + MIGRATION = 'MoveContainerRegistryEnabledToProjectFeature' + + disable_ddl_transaction! + + def up + # Delete any existing jobs from the queue + delete_queued_jobs(MIGRATION) + + # Delete existing rows in background_migration_jobs table + bg_migration_job_class = define_model('background_migration_jobs') + bg_migration_job_class.where(class_name: MIGRATION).delete_all + + batchable_project_class = define_batchable_model('projects') + queue_background_migration_jobs_by_range_at_intervals(batchable_project_class, MIGRATION, 2.minutes, batch_size: BATCH_SIZE, track_jobs: true) + end + + def down + # no-op + end + + private + + def define_model(table_name) + Class.new(ActiveRecord::Base) do + self.table_name = table_name + self.inheritance_column = :_type_disabled + end + end +end |