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

20211109101010_support_partition_query_in_loose_fk_table.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fccb1fc5cacf1e6eb864ea8f66ea0abf7502ac6c (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 SupportPartitionQueryInLooseFkTable < Gitlab::Database::Migration[1.0]
  include Gitlab::Database::PartitioningMigrationHelpers

  disable_ddl_transaction!

  INDEX_NAME = 'index_loose_foreign_keys_deleted_records_for_partitioned_query'

  def up
    add_concurrent_partitioned_index :loose_foreign_keys_deleted_records,
      %I[partition fully_qualified_table_name consume_after id],
      where: 'status = 1',
      name: INDEX_NAME
  end

  def down
    remove_concurrent_partitioned_index_by_name :loose_foreign_keys_deleted_records, INDEX_NAME
  end
end