Commit e269cd60 authored by Alper Akgun's avatar Alper Akgun

Merge branch '244831-split-pipelines-for-merged-results-and-merge-train-check-boxes' into 'master'

Add merge_trains_enabled column to project_ci_cd_settings

See merge request gitlab-org/gitlab!45834
parents 64d3d6d7 1a832246
---
title: Add merge trains enabled setting to project ci cd settings
merge_request: 45834
author:
type: other
# frozen_string_literal: true
class AddMergeTrainsEnabled < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false
end
end
# frozen_string_literal: true
class SeedMergeTrainsEnabled < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
update_column_in_batches(:project_ci_cd_settings, :merge_trains_enabled, true) do |table, query|
query.where(table[:merge_pipelines_enabled].eq(true))
end
end
def down
# no-op
end
end
72580665fcb0fca332ede450690902c0a7afb6159feff41df1bc10a3cf6607f2
\ No newline at end of file
691fe3335de3e072bc5612705c4d16744ff17e334025ddd78eb37309f87441e3
\ No newline at end of file
...@@ -14822,7 +14822,8 @@ CREATE TABLE project_ci_cd_settings ( ...@@ -14822,7 +14822,8 @@ CREATE TABLE project_ci_cd_settings (
group_runners_enabled boolean DEFAULT true NOT NULL, group_runners_enabled boolean DEFAULT true NOT NULL,
merge_pipelines_enabled boolean, merge_pipelines_enabled boolean,
default_git_depth integer, default_git_depth integer,
forward_deployment_enabled boolean forward_deployment_enabled boolean,
merge_trains_enabled boolean DEFAULT false
); );
CREATE SEQUENCE project_ci_cd_settings_id_seq CREATE SEQUENCE project_ci_cd_settings_id_seq
......
# frozen_string_literal: true
require 'spec_helper'
require Rails.root.join('db', 'migrate', '20201026200736_seed_merge_trains_enabled.rb')
RSpec.describe SeedMergeTrainsEnabled do
describe 'migrate' do
let(:project_ci_cd_settings) { table(:project_ci_cd_settings) }
let(:projects) { table(:projects) }
let(:namespaces) { table(:namespaces) }
context 'when on Gitlab.com' do
before do
namespace = namespaces.create!(name: 'hello', path: 'hello/')
project1 = projects.create!(namespace_id: namespace.id)
project2 = projects.create!(namespace_id: namespace.id)
project_ci_cd_settings.create!(project_id: project1.id, merge_pipelines_enabled: true)
project_ci_cd_settings.create!(project_id: project2.id, merge_pipelines_enabled: false)
end
it 'updates merge_trains_enabled to true for where merge_pipelines_enabled is true' do
migrate!
expect(project_ci_cd_settings.where(merge_trains_enabled: true).count).to be(1)
end
end
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