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

20200824130028_remove_index_on_users_bio.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d41734eb9ce5f71b1c85f69981e62c15724b811c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class RemoveIndexOnUsersBio < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  BACKGROUND_MIGRATION_CLASS = 'MigrateUsersBioToUserDetails'
  INDEX_NAME = 'tmp_idx_on_user_id_where_bio_is_filled'

  disable_ddl_transaction!

  def up
    Gitlab::BackgroundMigration.steal(BACKGROUND_MIGRATION_CLASS)
    remove_concurrent_index_by_name(:users, INDEX_NAME)
  end

  def down
    add_concurrent_index :users, :id, where: "(COALESCE(bio, '') IS DISTINCT FROM '')", name: INDEX_NAME
  end
end