summaryrefslogtreecommitdiff
path: root/db/migrate/20200713152443_add_background_migration_job_index_for_partitioning_migrations.rb
blob: 5ca9b6536ee28a715877ad5b283f66ab380dfb1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class AddBackgroundMigrationJobIndexForPartitioningMigrations < ActiveRecord::Migration[6.0]
  DOWNTIME = false

  INDEX_NAME = 'index_background_migration_jobs_for_partitioning_migrations'

  def up
    # rubocop:disable Migration/AddIndex
    add_index :background_migration_jobs, '((arguments ->> 2))', name: INDEX_NAME,
      where: "class_name = 'Gitlab::Database::PartitioningMigrationHelpers::BackfillPartitionedTable'"
    # rubocop:enable Migration/AddIndex
  end

  def down
    remove_index :background_migration_jobs, name: INDEX_NAME # rubocop:disable Migration/RemoveIndex
  end
end