2018-09-24 10:17:04 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-13 07:27:31 +00:00
|
|
|
class AddPartialIndexToScheduledAt < ActiveRecord::Migration[4.2]
|
2018-09-24 10:17:04 +00:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
2018-10-03 09:52:18 +00:00
|
|
|
INDEX_NAME = 'partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs'.freeze
|
2018-09-24 10:17:04 +00:00
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
2018-10-05 11:53:44 +00:00
|
|
|
add_concurrent_index(:ci_builds, :scheduled_at, where: "scheduled_at IS NOT NULL AND type = 'Ci::Build' AND status = 'scheduled'", name: INDEX_NAME)
|
2018-09-24 10:17:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_concurrent_index_by_name(:ci_builds, INDEX_NAME)
|
|
|
|
end
|
|
|
|
end
|