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

20210621044000_rename_services_indexes_to_integrations.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9dba663f6a7bbe04a9001ca1ef6225b78adac6ed (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
# frozen_string_literal: true

class RenameServicesIndexesToIntegrations < ActiveRecord::Migration[6.1]
  INDEXES = %w(
    project_and_type_where_inherit_null
    project_id_and_type_unique
    template
    type
    type_and_instance_partial
    type_and_template_partial
    type_id_when_active_and_project_id_not_null
    unique_group_id_and_type
  ).freeze

  def up
    INDEXES.each do |index|
      execute(<<~SQL)
        ALTER INDEX IF EXISTS "index_services_on_#{index}" RENAME TO "index_integrations_on_#{index}"
      SQL
    end
  end

  def down
    INDEXES.each do |index|
      execute(<<~SQL)
        ALTER INDEX IF EXISTS "index_integrations_on_#{index}" RENAME TO "index_services_on_#{index}"
      SQL
    end
  end
end