Merge branch 'fix/gb/fix-background-pipeline-stages-migration' into 'master'
Fix background pipeline stages migration Closes #44135 See merge request gitlab-org/gitlab-ce!18076
This commit is contained in:
commit
8230b774b5
4 changed files with 26 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix exceptions raised when migrating pipeline stages in the background
|
||||
merge_request: 18076
|
||||
author:
|
||||
type: fixed
|
|
@ -12,6 +12,7 @@ module Gitlab
|
|||
|
||||
class Build < ActiveRecord::Base
|
||||
self.table_name = 'ci_builds'
|
||||
self.inheritance_column = :_type_disabled
|
||||
|
||||
def ensure_stage!(attempts: 2)
|
||||
find_stage || create_stage!
|
||||
|
|
|
@ -51,4 +51,20 @@ describe Gitlab::BackgroundMigration::MigrateBuildStage, :migration, schema: 201
|
|||
expect { described_class.new.perform(1, 6) }
|
||||
.to raise_error ActiveRecord::RecordNotUnique
|
||||
end
|
||||
|
||||
context 'when invalid class can be loaded due to single table inheritance' do
|
||||
let(:commit_status) do
|
||||
jobs.create!(id: 7, commit_id: 1, project_id: 123, stage_idx: 4,
|
||||
stage: 'post-deploy', status: :failed)
|
||||
end
|
||||
|
||||
before do
|
||||
commit_status.update_column(:type, 'SomeClass')
|
||||
end
|
||||
|
||||
it 'does ignore single table inheritance type' do
|
||||
expect { described_class.new.perform(1, 7) }.not_to raise_error
|
||||
expect(jobs.find(7)).to have_attributes(stage_id: (a_value > 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
module MigrationsHelpers
|
||||
def table(name)
|
||||
Class.new(ActiveRecord::Base) { self.table_name = name }
|
||||
Class.new(ActiveRecord::Base) do
|
||||
self.table_name = name
|
||||
self.inheritance_column = :_type_disabled
|
||||
end
|
||||
end
|
||||
|
||||
def migrations_paths
|
||||
|
|
Loading…
Reference in a new issue