Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20231019003052_swap_columns_for_ci_pipelines_pipeline_id_bigint_v2_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9fc07a0ac7692bd34153f321506d2528dcbaff8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe SwapColumnsForCiPipelinesPipelineIdBigintV2, feature_category: :continuous_integration do
  context 'when auto_canceled_by_id sql type is integer' do
    before do
      active_record_base.connection.execute(<<~SQL)
        ALTER TABLE ci_pipelines ALTER COLUMN auto_canceled_by_id TYPE integer;
        ALTER TABLE ci_pipelines ALTER COLUMN auto_canceled_by_id_convert_to_bigint TYPE bigint;
      SQL
    end

    it_behaves_like(
      'swap conversion columns',
      table_name: :ci_pipelines,
      from: :auto_canceled_by_id,
      to: :auto_canceled_by_id_convert_to_bigint
    )
  end

  context 'when auto_canceled_by_id sql type is bigint' do
    before do
      active_record_base.connection.execute(<<~SQL)
        ALTER TABLE ci_pipelines ALTER COLUMN auto_canceled_by_id TYPE bigint;
        ALTER TABLE ci_pipelines ALTER COLUMN auto_canceled_by_id_convert_to_bigint TYPE integer;
      SQL
    end

    it 'does nothing' do
      recorder = ActiveRecord::QueryRecorder.new { migrate! }
      expect(recorder.log).not_to include(/LOCK TABLE/)
      expect(recorder.log).not_to include(/ALTER TABLE/)
    end
  end
end