summaryrefslogtreecommitdiff
path: root/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb
blob: 02e53b8fa8acdf0f16ca350d8bbe16125d47d9f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class AddUniqueConstraintToTrendingProjectsProjectId < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :trending_projects, :project_id, unique: true, name: 'index_trending_projects_on_project_id_unique'
    remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id'
    rename_index :trending_projects, 'index_trending_projects_on_project_id_unique', 'index_trending_projects_on_project_id'
  end

  def down
    rename_index :trending_projects, 'index_trending_projects_on_project_id', 'index_trending_projects_on_project_id_old'
    add_concurrent_index :trending_projects, :project_id
    remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id_old'
  end
end