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 'db/post_migrate/20210513163904_cleanup_move_container_registry_enabled_to_project_feature.rb')
-rw-r--r--db/post_migrate/20210513163904_cleanup_move_container_registry_enabled_to_project_feature.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/db/post_migrate/20210513163904_cleanup_move_container_registry_enabled_to_project_feature.rb b/db/post_migrate/20210513163904_cleanup_move_container_registry_enabled_to_project_feature.rb
new file mode 100644
index 00000000000..665d274a0ee
--- /dev/null
+++ b/db/post_migrate/20210513163904_cleanup_move_container_registry_enabled_to_project_feature.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class CleanupMoveContainerRegistryEnabledToProjectFeature < ActiveRecord::Migration[6.0]
+ MIGRATION = 'MoveContainerRegistryEnabledToProjectFeature'
+
+ disable_ddl_transaction!
+
+ def up
+ Gitlab::BackgroundMigration.steal(MIGRATION)
+
+ bg_migration_job_class = define_background_migration_jobs_class
+ bg_migration_job_class.where(class_name: MIGRATION, status: bg_migration_job_class.statuses['pending']).each do |job|
+ Gitlab::BackgroundMigration::MoveContainerRegistryEnabledToProjectFeature.new.perform(*job.arguments)
+ end
+
+ bg_migration_job_class.where(class_name: MIGRATION).delete_all
+ end
+
+ def down
+ # no-op
+ end
+
+ private
+
+ def define_background_migration_jobs_class
+ Class.new(ActiveRecord::Base) do
+ self.table_name = 'background_migration_jobs'
+ self.inheritance_column = :_type_disabled
+
+ enum status: {
+ pending: 0,
+ succeeded: 1
+ }
+ end
+ end
+end