diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb')
-rw-r--r-- | db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb b/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb index 2e6ad12f928..3a758394d7f 100644 --- a/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb +++ b/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb @@ -1,52 +1,11 @@ # frozen_string_literal: true class DisableJobTokenScopeWhenUnused < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - class ProjectCiCdSetting < ApplicationRecord - include EachBatch - - self.table_name = 'project_ci_cd_settings' - end - - module Ci - module JobToken - class ProjectScopeLink < ApplicationRecord - self.table_name = 'ci_job_token_project_scope_links' - end - end - end - def up - # Disabling job token scope after db/migrate/20210902171808_set_default_job_token_scope_false.rb - # if users haven't configured it. - ProjectCiCdSetting.each_batch(of: 10_000) do |settings| - with_enabled_but_unused_scope(settings).each_batch(of: 500) do |settings_to_update| - settings_to_update.update_all(job_token_scope_enabled: false) - end - end + # no-op: Must have run before %"15.X" as it is not compatible with decomposed CI database end def down - # irreversible data migration - - # The migration relies on the state of `job_token_scope_enabled` and - # updates it based on whether the feature is used or not. - # - # The inverse migration would be to set `job_token_scope_enabled: true` - # for those projects that have the feature disabled and unused. But there - # could be also existing cases where the feature is disabled and unused. - # For example, old projects. - end - - private - - # The presence of ProjectScopeLinks means that the job token scope - # is configured and we need to leave it enabled. Unused job token scope - # can be disabled since they weren't configured. - def with_enabled_but_unused_scope(settings) - settings - .where(job_token_scope_enabled: true) - .where.not(project_id: Ci::JobToken::ProjectScopeLink.select(:source_project_id)) + # no-op end end |