summaryrefslogtreecommitdiff
path: root/db/post_migrate/20211031152417_add_indexes_to_issue_stage_events.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-18 13:16:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-18 13:16:36 +0000
commit311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch)
tree07e7870bca8aed6d61fdcc810731c50d2c40af47 /db/post_migrate/20211031152417_add_indexes_to_issue_stage_events.rb
parent27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff)
downloadgitlab-ce-311b0269b4eb9839fa63f80c8d7a58f32b8138a0.tar.gz
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'db/post_migrate/20211031152417_add_indexes_to_issue_stage_events.rb')
-rw-r--r--db/post_migrate/20211031152417_add_indexes_to_issue_stage_events.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/db/post_migrate/20211031152417_add_indexes_to_issue_stage_events.rb b/db/post_migrate/20211031152417_add_indexes_to_issue_stage_events.rb
new file mode 100644
index 00000000000..73b70ad1e27
--- /dev/null
+++ b/db/post_migrate/20211031152417_add_indexes_to_issue_stage_events.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+class AddIndexesToIssueStageEvents < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::PartitioningMigrationHelpers
+
+ disable_ddl_transaction!
+
+ GROUP_INDEX_NAME = 'index_issue_stage_events_group_duration'
+ GROUP_IN_PROGRESS_INDEX_NAME = 'index_issue_stage_events_group_in_progress_duration'
+ PROJECT_INDEX_NAME = 'index_issue_stage_events_project_duration'
+ PROJECT_IN_PROGRESS_INDEX_NAME = 'index_issue_stage_events_project_in_progress_duration'
+
+ def up
+ add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
+ 'stage_event_hash_id, group_id, end_event_timestamp, issue_id, start_event_timestamp',
+ where: 'end_event_timestamp IS NOT NULL',
+ name: GROUP_INDEX_NAME
+
+ add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
+ 'stage_event_hash_id, project_id, end_event_timestamp, issue_id, start_event_timestamp',
+ where: 'end_event_timestamp IS NOT NULL',
+ name: PROJECT_INDEX_NAME
+
+ add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
+ 'stage_event_hash_id, group_id, start_event_timestamp, issue_id',
+ where: 'end_event_timestamp IS NULL AND state_id = 1',
+ name: GROUP_IN_PROGRESS_INDEX_NAME
+
+ add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
+ 'stage_event_hash_id, project_id, start_event_timestamp, issue_id',
+ where: 'end_event_timestamp IS NULL AND state_id = 1',
+ name: PROJECT_IN_PROGRESS_INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, GROUP_INDEX_NAME
+ remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, PROJECT_INDEX_NAME
+ remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, GROUP_IN_PROGRESS_INDEX_NAME
+ remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, PROJECT_IN_PROGRESS_INDEX_NAME
+ end
+end