diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-25 18:10:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-25 18:10:33 +0300 |
commit | a8c1bc6f757ecacbc3481e52a3f4cefb6c6db5fd (patch) | |
tree | 7ba85d57835274f11674c33155e68b6af33f2687 /db/post_migrate | |
parent | 76ef00aac974a463243dcda6f692b17ff5d439bc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20210513163904_cleanup_move_container_registry_enabled_to_project_feature.rb | 36 |
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 |