summaryrefslogtreecommitdiff
path: root/db/migrate/20170222143500_remove_old_project_id_columns.rb
blob: 9bed38a34443f67ebf6285e9cf3fd533fe075494 (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
# rubocop:disable Migration/RemoveColumn
# rubocop:disable RemoveIndex
class RemoveOldProjectIdColumns < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers
  disable_ddl_transaction!

  DOWNTIME = true
  DOWNTIME_REASON = 'Unused columns are being removed.'

  def up
    remove_index :ci_builds, :project_id if
      index_exists?(:ci_builds, :project_id)

    remove_column :ci_builds, :project_id
    remove_column :ci_commits, :project_id
    remove_column :ci_runner_projects, :project_id
    remove_column :ci_triggers, :project_id
    remove_column :ci_variables, :project_id
  end

  def down
    add_column :ci_builds, :project_id, :integer
    add_column :ci_commits, :project_id, :integer
    add_column :ci_runner_projects, :project_id, :integer
    add_column :ci_triggers, :project_id, :integer
    add_column :ci_variables, :project_id, :integer

    add_concurrent_index :ci_builds, :project_id
  end
end