summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb
blob: 81e95f531c1988309550fd1d09fdf7d03688254a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class IndexOnIntegrationTypeNewIdWhenActiveAndHasGroup < Gitlab::Database::Migration[2.0]
  INDEX_NAME = 'index_integrations_on_type_new_id_when_active_and_has_group'

  disable_ddl_transaction!

  def up
    add_concurrent_index :integrations,
                         [:type_new, :id, :inherit_from_id],
                         name: INDEX_NAME,
                         where: '((active = true) AND (group_id IS NOT NULL))'
  end

  def down
    remove_concurrent_index_by_name :integrations, INDEX_NAME
  end
end