Commit fb876346 authored by Avielle Wolfe's avatar Avielle Wolfe

Add ResetJobTokenScopeEnabledAgain migration

This migration drops the `job_token_scope_enabled` field on
project_ci_cd_settings` and re-adds it. This will effectively cause its
value for all projects to be `false`, which will let us safely re-enable
the `ci_scoped_job_token` feature flag.

We previously reset this field before turning on the feature flag for
the first time. We are now resetting it again because we had to turn off
the feature flag after an incident.

Changelog: other
parent 4280e2f3
# frozen_string_literal: true
class ResetJobTokenScopeEnabledAgain < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
with_lock_retries do
remove_column :project_ci_cd_settings, :job_token_scope_enabled
add_column :project_ci_cd_settings, :job_token_scope_enabled, :boolean, default: false, null: false
end
end
def down
# no-op
end
end
24c49a12b6624c8e215e8a0c16b1bc9acc1875e68d3727fc3904b9e2eee1d319
\ No newline at end of file
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe ResetJobTokenScopeEnabledAgain do
let(:settings) { table(:project_ci_cd_settings) }
let(:projects) { table(:projects) }
let(:namespaces) { table(:namespaces) }
let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
let(:project_1) { projects.create!(name: 'proj-1', path: 'gitlab-org', namespace_id: namespace.id)}
let(:project_2) { projects.create!(name: 'proj-2', path: 'gitlab-org', namespace_id: namespace.id)}
before do
settings.create!(id: 1, project_id: project_1.id, job_token_scope_enabled: true)
settings.create!(id: 2, project_id: project_2.id, job_token_scope_enabled: false)
end
it 'migrates job_token_scope_enabled to be always false' do
expect { migrate! }
.to change { settings.where(job_token_scope_enabled: false).count }
.from(1).to(2)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment