blob: c78c3a86cf301eeea600ffca90821d9bd688dd88 (
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
25
26
27
28
29
|
# frozen_string_literal: true
class AddIndexToDeploymentsOnCreatedAtClusterIdAndProjectId < Gitlab::Database::Migration[2.0]
disable_ddl_transaction!
# This temporary index was created to support the script that will be run as part o this
# Change Request: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/6981
#
# Issue to remove the temporary index: https://gitlab.com/gitlab-org/gitlab/-/issues/361389
INDEX_NAME = 'tp_index_created_at_cluster_id_project_id_on_deployments'
# The change request will only run for deployments newer than this date. This is what we'll
# be considering as "Active certificate based cluster Kubernetes Deployments". Namespaces with
# deployments older than this will have to be migrated to the agent and won't have their
# certificate based clusters life extended.
DEPLOYMENTS_START_DATE = '2022-04-03 00:00:00'
def up
add_concurrent_index(
:deployments,
[:created_at, :cluster_id, :project_id],
name: INDEX_NAME,
where: "cluster_id is not null and created_at > '#{DEPLOYMENTS_START_DATE}'")
end
def down
remove_concurrent_index_by_name(:deployments, INDEX_NAME)
end
end
|