Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-11-27 03:09:34 +00:00
parent ccdcf4e139
commit d99ae62430
5 changed files with 43 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
title: Change services.inherit_from_id foreign key to ON DELETE CASCADE
merge_request: 48163
author:
type: fixed

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
class ChangeServicesInheritFromIdForeignKey < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_foreign_key :services, :services, column: :inherit_from_id, on_delete: :cascade, name: 'fk_services_inherit_from_id'
remove_foreign_key_if_exists :services, name: 'fk_868a8e7ad6'
end
def down
remove_foreign_key_if_exists :services, name: 'fk_services_inherit_from_id'
add_concurrent_foreign_key :services, :services, column: :inherit_from_id, on_delete: :nullify, name: 'fk_868a8e7ad6'
end
end

View File

@ -0,0 +1 @@
c41f4649540c23d25f0ae26c3754476409b5e77f53b96db65f2c1fd4a6caf087

View File

@ -23112,9 +23112,6 @@ ALTER TABLE ONLY merge_request_diffs
ALTER TABLE ONLY ci_pipelines
ADD CONSTRAINT fk_86635dbd80 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY services
ADD CONSTRAINT fk_868a8e7ad6 FOREIGN KEY (inherit_from_id) REFERENCES services(id) ON DELETE SET NULL;
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_86c84214ec FOREIGN KEY (repository_renamed_event_id) REFERENCES geo_repository_renamed_events(id) ON DELETE CASCADE;
@ -24780,6 +24777,9 @@ ALTER TABLE ONLY resource_label_events
ALTER TABLE ONLY ci_builds_metadata
ADD CONSTRAINT fk_rails_ffcf702a02 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY services
ADD CONSTRAINT fk_services_inherit_from_id FOREIGN KEY (inherit_from_id) REFERENCES services(id) ON DELETE CASCADE;
ALTER TABLE ONLY timelogs
ADD CONSTRAINT fk_timelogs_issues_issue_id FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;

View File

@ -21,9 +21,10 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
let(:data) { described_class.build(pipeline) }
let(:attributes) { data[:object_attributes] }
let(:build_data) { data[:builds].first }
let(:runner_data) { build_data[:runner] }
let(:project_data) { data[:project] }
it 'has correct attributes' do
it 'has correct attributes', :aggregate_failures do
expect(attributes).to be_a(Hash)
expect(attributes[:ref]).to eq(pipeline.ref)
expect(attributes[:sha]).to eq(pipeline.sha)
@ -36,6 +37,7 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
expect(build_data[:id]).to eq(build.id)
expect(build_data[:status]).to eq(build.status)
expect(build_data[:allow_failure]).to eq(build.allow_failure)
expect(runner_data).to eq(nil)
expect(project_data).to eq(project.hook_attrs(backward: false))
expect(data[:merge_request]).to be_nil
expect(data[:user]).to eq({
@ -46,6 +48,18 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
})
end
context 'build with runner' do
let!(:build) { create(:ci_build, pipeline: pipeline, runner: ci_runner) }
let(:ci_runner) { create(:ci_runner) }
it 'has runner attributes', :aggregate_failures do
expect(runner_data[:id]).to eq(ci_runner.id)
expect(runner_data[:description]).to eq(ci_runner.description)
expect(runner_data[:active]).to eq(ci_runner.active)
expect(runner_data[:is_shared]).to eq(ci_runner.instance_type?)
end
end
context 'pipeline without variables' do
it 'has empty variables hash' do
expect(attributes[:variables]).to be_a(Array)