20180201102129_add_unique_constraint_to_trending_projects_project_id.rb 840 Bytes
Newer Older
1
class AddUniqueConstraintToTrendingProjectsProjectId < ActiveRecord::Migration[4.2]
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  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