diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-03-29 12:12:22 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-03-29 12:12:22 +0200 |
commit | 9afabee3e0ff698c1e15dc06b25f8e9c5f548727 (patch) | |
tree | 306247eb2b64330a6207af177f76f8eec22ec8a3 | |
parent | 3577009ad84fbd6b90b4702f06290980ebd4771a (diff) | |
download | gitlab-ce-9afabee3e0ff698c1e15dc06b25f8e9c5f548727.tar.gz |
Do not use STI mechanisms when migrating pipeline stages
-rw-r--r-- | lib/gitlab/background_migration/migrate_build_stage.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/migrate_build_stage.rb b/lib/gitlab/background_migration/migrate_build_stage.rb index 8fe4f1a2289..242e3143e71 100644 --- a/lib/gitlab/background_migration/migrate_build_stage.rb +++ b/lib/gitlab/background_migration/migrate_build_stage.rb @@ -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! diff --git a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb index e112e9e9e3d..5ce84c61042 100644 --- a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb +++ b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb @@ -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 |