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

20190424134256_drop_projects_ci_id.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 44e8f316393daba572c8ef5b457f7093b2e5ec05 (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
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class DropProjectsCiId < ActiveRecord::Migration[5.1]
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  disable_ddl_transaction!

  def up
    if index_exists?(:projects, :ci_id)
      remove_concurrent_index :projects, :ci_id
    end

    if column_exists?(:projects, :ci_id)
      remove_column :projects, :ci_id
    end
  end

  def down
    unless column_exists?(:projects, :ci_id)
      add_column :projects, :ci_id, :integer
    end

    unless index_exists?(:projects, :ci_id)
      add_concurrent_index :projects, :ci_id
    end
  end
end