Commit 1487cf22 authored by drew cimino's avatar drew cimino

Schedule async weekend build of index for job traces

Changelog: performance
parent 6172b14a
# frozen_string_literal: true
class AsyncBuildTraceExpireAtIndex < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_where_trace_and_expire_at'
TIMESTAMPS = "'2021-04-22 00:00:00', '2021-05-22 00:00:00', '2021-06-22 00:00:00', '2022-01-22 00:00:00', '2022-02-22 00:00:00', '2022-03-22 00:00:00', '2022-04-22 00:00:00'"
def up
prepare_async_index :ci_job_artifacts, :id, where: "file_type = 3 AND expire_at IN (#{TIMESTAMPS})", name: INDEX_NAME
end
def down
unprepare_async_index :ci_builds, :id, name: INDEX_NAME
end
end
74b4d572118b7f5da0a80722601a4757ce47ccbdae1af1e84b2304343477d634
\ No newline at end of file
# frozen_string_literal: true
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20220224000000_async_build_trace_expire_at_index.rb')
RSpec.describe AsyncBuildTraceExpireAtIndex do
describe '#up' do
it 'sets up a delayed concurrent index creation' do
expect_next_instance_of(described_class) do |instance|
expect(instance).to receive(:prepare_async_index)
end
migrate!
end
end
describe '#down' do
it 'removes an index' do
expect_any_instance_of(described_class) do |instance|
expect(instance).to receive(:unprepare_async_index)
end
schema_migrate_down!
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment