blob: 275207ca870eef8f7c6178dc5637b225c2942336 (
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
|
# frozen_string_literal: true
class AddIndexForGroupVulnerabilitiesAysnc < Gitlab::Database::Migration[2.1]
# The column used with the IN query and the columns in the ORDER BY
# clause are covered with a database index. The columns in the index
# must be in the following order: column_for_the_in_query, order by
# column 1, and order by column 2.
#
# https://docs.gitlab.com/ee/development/database/efficient_in_operator_queries.html#requirements
INDEX_NAME = 'index_vulnerabilities_on_project_id_and_id'
TABLE_NAME = :vulnerabilities
COLUMN_NAMES = [:project_id, :id]
disable_ddl_transaction!
def up
# TODO: Issue for synchronous migration https://gitlab.com/gitlab-org/gitlab/-/issues/426371
prepare_async_index :vulnerabilities, COLUMN_NAMES, name: INDEX_NAME
end
def down
unprepare_async_index :vulnerabilities, COLUMN_NAMES, name: INDEX_NAME
end
end
|