diff --git a/db/migrate/20240104142200_add_index_sent_notifications_on_issue_email_participant_id.rb b/db/migrate/20240104142200_add_index_sent_notifications_on_issue_email_participant_id.rb index c9b755294702da0cf3831b565266ff3daae05ceb..7a564f13fb0fc0d2a0d46552895e2e9516da5165 100644 --- a/db/migrate/20240104142200_add_index_sent_notifications_on_issue_email_participant_id.rb +++ b/db/migrate/20240104142200_add_index_sent_notifications_on_issue_email_participant_id.rb @@ -8,7 +8,9 @@ class AddIndexSentNotificationsOnIssueEmailParticipantId < Gitlab::Database::Mig INDEX_NAME = 'index_sent_notifications_on_issue_email_participant_id' def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :sent_notifications, :issue_email_participant_id, name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20231114034507_add_merge_request_diffs_project_id_index_async.rb b/db/post_migrate/20231114034507_add_merge_request_diffs_project_id_index_async.rb index 1c783b922ae86dc5373b2e99e8eda716b2dd6dac..a55e56e600e4a3e6a61d5d0d788d818d8844b29d 100644 --- a/db/post_migrate/20231114034507_add_merge_request_diffs_project_id_index_async.rb +++ b/db/post_migrate/20231114034507_add_merge_request_diffs_project_id_index_async.rb @@ -7,7 +7,9 @@ class AddMergeRequestDiffsProjectIdIndexAsync < Gitlab::Database::Migration[2.2] INDEX_NAME = 'index_merge_request_diffs_on_project_id' def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :merge_request_diffs, :project_id, name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20231121040153_add_merge_request_diffs_project_id_index.rb b/db/post_migrate/20231121040153_add_merge_request_diffs_project_id_index.rb index 5576e9d534e8f36d47fab61b8ca33f6401cbdeb5..b71e03e20fb297dc6ff12862c4d33f81f0465cbc 100644 --- a/db/post_migrate/20231121040153_add_merge_request_diffs_project_id_index.rb +++ b/db/post_migrate/20231121040153_add_merge_request_diffs_project_id_index.rb @@ -7,7 +7,9 @@ class AddMergeRequestDiffsProjectIdIndex < Gitlab::Database::Migration[2.2] INDEX_NAME = 'index_merge_request_diffs_on_project_id' def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :merge_request_diffs, :project_id, name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb b/db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb index a0149a79f83f915fbf1e8a7c5e3cac48644be89b..d5e4aadc5c3ff820e6be44a6028038914e6f65b8 100644 --- a/db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb +++ b/db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb @@ -7,7 +7,9 @@ class PrepareIidNamespaceUniqueIndexInIssues < Gitlab::Database::Migration[2.2] # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/435856 def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :issues, [:namespace_id, :iid], unique: true, name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20231207211418_add_iid_namespace_unique_index_to_issues.rb b/db/post_migrate/20231207211418_add_iid_namespace_unique_index_to_issues.rb index 4c2439f33ea77bfa45a891494c862e1bb7ac9a19..490d91ea1315762bb7884a91fbf284d0f0d24733 100644 --- a/db/post_migrate/20231207211418_add_iid_namespace_unique_index_to_issues.rb +++ b/db/post_migrate/20231207211418_add_iid_namespace_unique_index_to_issues.rb @@ -8,7 +8,9 @@ class AddIidNamespaceUniqueIndexToIssues < Gitlab::Database::Migration[2.2] milestone '16.8' def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :issues, [:namespace_id, :iid], name: INDEX_NAME, unique: true + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20231215130625_schedule_index_to_events_author_group_action_target_type_created_at.rb b/db/post_migrate/20231215130625_schedule_index_to_events_author_group_action_target_type_created_at.rb index 1e3658aa69741c843ed05a27808f90f8449d4663..bddecce9c054babdc8c007809674be4476fe7909 100644 --- a/db/post_migrate/20231215130625_schedule_index_to_events_author_group_action_target_type_created_at.rb +++ b/db/post_migrate/20231215130625_schedule_index_to_events_author_group_action_target_type_created_at.rb @@ -7,7 +7,7 @@ class ScheduleIndexToEventsAuthorGroupActionTargetTypeCreatedAt < Gitlab::Databa COLUMNS = [:author_id, :group_id, :action, :target_type, :created_at] def up - prepare_async_index :events, COLUMNS, name: INDEX_NAME + prepare_async_index :events, COLUMNS, name: INDEX_NAME # rubocop:disable Migration/PreventIndexCreation -- Legacy migration end def down diff --git a/db/post_migrate/20240104223119_add_index_owasp_top_10_with_project_id_on_vulnerability_reads.rb b/db/post_migrate/20240104223119_add_index_owasp_top_10_with_project_id_on_vulnerability_reads.rb index 99a2dccc8f54ddd006cdfa29db09f130bc4ea8e1..7af57a7f40082907afb0ccd426e89e48466470fd 100644 --- a/db/post_migrate/20240104223119_add_index_owasp_top_10_with_project_id_on_vulnerability_reads.rb +++ b/db/post_migrate/20240104223119_add_index_owasp_top_10_with_project_id_on_vulnerability_reads.rb @@ -8,7 +8,9 @@ class AddIndexOwaspTop10WithProjectIdOnVulnerabilityReads < Gitlab::Database::Mi INDEX_NAME = 'index_vuln_reads_on_project_id_owasp_top_10' def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :vulnerability_reads, [:project_id, :owasp_top_10], name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240112143548_add_index_to_events_author_group_action_target_type.rb b/db/post_migrate/20240112143548_add_index_to_events_author_group_action_target_type.rb index 88e5f95ef68fef44cefedee57ec28a5781bf5645..70d7c325a68d261ee824ffa796dcb39e6bf4f931 100644 --- a/db/post_migrate/20240112143548_add_index_to_events_author_group_action_target_type.rb +++ b/db/post_migrate/20240112143548_add_index_to_events_author_group_action_target_type.rb @@ -9,7 +9,7 @@ class AddIndexToEventsAuthorGroupActionTargetType < Gitlab::Database::Migration[ COLUMNS = [:author_id, :group_id, :action, :target_type, :created_at] def up - add_concurrent_index :events, COLUMNS, name: INDEX_NAME + add_concurrent_index :events, COLUMNS, name: INDEX_NAME # rubocop:disable Migration/PreventIndexCreation -- Legacy migration end def down diff --git a/db/post_migrate/20240201111294_add_index_on_issues_table_tmp_epic_id_column.rb b/db/post_migrate/20240201111294_add_index_on_issues_table_tmp_epic_id_column.rb index 76e8323973b9c29b906c76fb26e4f3191b4708c6..34dbd32d35a89244b62c4ac0d7a2ebfeccf24ce6 100644 --- a/db/post_migrate/20240201111294_add_index_on_issues_table_tmp_epic_id_column.rb +++ b/db/post_migrate/20240201111294_add_index_on_issues_table_tmp_epic_id_column.rb @@ -7,7 +7,9 @@ class AddIndexOnIssuesTableTmpEpicIdColumn < Gitlab::Database::Migration[2.2] INDEX_NAME = "tmp_index_issues_on_tmp_epic_id" def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :issues, :tmp_epic_id, unique: true, name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240213125429_schedule_index_merge_requests_on_unmerged_state_id.rb b/db/post_migrate/20240213125429_schedule_index_merge_requests_on_unmerged_state_id.rb index e7b1fbe68a48e822ffa379e36bcca06033564da2..ef25716edceb556cc06f6ecd3d2d790c93449539 100644 --- a/db/post_migrate/20240213125429_schedule_index_merge_requests_on_unmerged_state_id.rb +++ b/db/post_migrate/20240213125429_schedule_index_merge_requests_on_unmerged_state_id.rb @@ -7,7 +7,9 @@ class ScheduleIndexMergeRequestsOnUnmergedStateId < Gitlab::Database::Migration[ TABLE_NAME = :merge_requests def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index(TABLE_NAME, :id, name: INDEX_NAME, where: "state_id <> 3") + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240325085542_add_index_merge_requests_on_unmerged_state_id.rb b/db/post_migrate/20240325085542_add_index_merge_requests_on_unmerged_state_id.rb index 800dc23e7e56225b9015cc8ab224792af43ee148..9e08088480ec75929146c2cf91af04d51405a82e 100644 --- a/db/post_migrate/20240325085542_add_index_merge_requests_on_unmerged_state_id.rb +++ b/db/post_migrate/20240325085542_add_index_merge_requests_on_unmerged_state_id.rb @@ -9,7 +9,9 @@ class AddIndexMergeRequestsOnUnmergedStateId < Gitlab::Database::Migration[2.2] TABLE_NAME = :merge_requests def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index(TABLE_NAME, :id, name: INDEX_NAME, where: "state_id <> 3") + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240410104838_index_vulnerability_reads_on_state_report_type_severity_traversal_ids_archived.rb b/db/post_migrate/20240410104838_index_vulnerability_reads_on_state_report_type_severity_traversal_ids_archived.rb index 6b750eb3fe0185fe68052aecddbab6f6804d5664..599612f72019bd5b2c08ae5ad486c2d035ed8947 100644 --- a/db/post_migrate/20240410104838_index_vulnerability_reads_on_state_report_type_severity_traversal_ids_archived.rb +++ b/db/post_migrate/20240410104838_index_vulnerability_reads_on_state_report_type_severity_traversal_ids_archived.rb @@ -8,7 +8,9 @@ class IndexVulnerabilityReadsOnStateReportTypeSeverityTraversalIdsArchived < Git COLUMNS = %i[resolved_on_default_branch state report_type severity traversal_ids vulnerability_id].freeze def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :vulnerability_reads, COLUMNS, name: INDEX_NAME, where: 'archived = false' + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240502120047_index_vulnerability_reads_for_common_group_level_query.rb b/db/post_migrate/20240502120047_index_vulnerability_reads_for_common_group_level_query.rb index 7f1eb48e627dd54a63f890cedf56cc5f981562aa..5f3ab47f2c2d881dfb97ff84872cf19fe5c0557f 100644 --- a/db/post_migrate/20240502120047_index_vulnerability_reads_for_common_group_level_query.rb +++ b/db/post_migrate/20240502120047_index_vulnerability_reads_for_common_group_level_query.rb @@ -8,7 +8,9 @@ class IndexVulnerabilityReadsForCommonGroupLevelQuery < Gitlab::Database::Migrat milestone '17.0' def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :vulnerability_reads, COLUMNS, name: INDEX_NAME, where: 'archived = false' + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240514121644_replace_issues_milestone_index.rb b/db/post_migrate/20240514121644_replace_issues_milestone_index.rb index eb3d67ae8dfa4067128ddeb175ea0aeb270f291a..23f50215b4b2e7cb4d75993ec4b6519f320a0f17 100644 --- a/db/post_migrate/20240514121644_replace_issues_milestone_index.rb +++ b/db/post_migrate/20240514121644_replace_issues_milestone_index.rb @@ -7,7 +7,7 @@ class ReplaceIssuesMilestoneIndex < Gitlab::Database::Migration[2.2] # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/461627 def up - prepare_async_index :issues, %i[milestone_id id], name: INDEX_NAME + prepare_async_index :issues, %i[milestone_id id], name: INDEX_NAME # rubocop:disable Migration/PreventIndexCreation -- Legacy migration end def down diff --git a/db/post_migrate/20240531140131_add_issues_milestone_and_id_index_concurrently.rb b/db/post_migrate/20240531140131_add_issues_milestone_and_id_index_concurrently.rb index 94f234f67b912098313b27811839c59a6f625340..10fa634f215499e9d4e1f5a9a21f1672bbacf701 100644 --- a/db/post_migrate/20240531140131_add_issues_milestone_and_id_index_concurrently.rb +++ b/db/post_migrate/20240531140131_add_issues_milestone_and_id_index_concurrently.rb @@ -8,7 +8,7 @@ class AddIssuesMilestoneAndIdIndexConcurrently < Gitlab::Database::Migration[2.2 disable_ddl_transaction! def up - add_concurrent_index :issues, %i[milestone_id id], name: INDEX_NAME + add_concurrent_index :issues, %i[milestone_id id], name: INDEX_NAME # rubocop:disable Migration/PreventIndexCreation -- Legacy migration end def down diff --git a/db/post_migrate/20240610125054_create_idx_vulnerability_occurences_on_prim_iden_id.rb b/db/post_migrate/20240610125054_create_idx_vulnerability_occurences_on_prim_iden_id.rb index e1ca68e1f4046c3b4086738ed83626c6c415db87..5ab8fc80d759d2e4cab4916182fb3faa5277fbde 100644 --- a/db/post_migrate/20240610125054_create_idx_vulnerability_occurences_on_prim_iden_id.rb +++ b/db/post_migrate/20240610125054_create_idx_vulnerability_occurences_on_prim_iden_id.rb @@ -9,7 +9,7 @@ class CreateIdxVulnerabilityOccurencesOnPrimIdenId < Gitlab::Database::Migration # -- This index was created async previously, check https://gitlab.com/gitlab-org/gitlab/-/merge_requests/131647 def up - add_concurrent_index( + add_concurrent_index( # rubocop:disable Migration/PreventIndexCreation -- Legacy migration TABLE_NAME, [:primary_identifier_id, :vulnerability_id], name: NEW_INDEX_NAME ) diff --git a/db/post_migrate/20240703142511_add_index_owasp_top_10_for_group_level_reports.rb b/db/post_migrate/20240703142511_add_index_owasp_top_10_for_group_level_reports.rb index a2631fe43db0aa0e7613974755319c3708a9f8b3..1f8082be5064514ff4c2adeeff187575e9fe2841 100644 --- a/db/post_migrate/20240703142511_add_index_owasp_top_10_for_group_level_reports.rb +++ b/db/post_migrate/20240703142511_add_index_owasp_top_10_for_group_level_reports.rb @@ -8,7 +8,9 @@ class AddIndexOwaspTop10ForGroupLevelReports < Gitlab::Database::Migration[2.2] # -- Legacy migration def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :vulnerability_reads, [:owasp_top_10, :state, :report_type, + # rubocop:enable Migration/PreventIndexCreation :severity, :traversal_ids, :vulnerability_id, :resolved_on_default_branch], where: 'archived = false', name: INDEX_NAME diff --git a/db/post_migrate/20240719033346_tmp_index_on_vulnerability_reads.rb b/db/post_migrate/20240719033346_tmp_index_on_vulnerability_reads.rb index c7117461ac57580242f70f8669fbfabb36bdd61d..725dc037da68fdf0eda0f74b9c85dcc69c559c7a 100644 --- a/db/post_migrate/20240719033346_tmp_index_on_vulnerability_reads.rb +++ b/db/post_migrate/20240719033346_tmp_index_on_vulnerability_reads.rb @@ -13,7 +13,9 @@ class TmpIndexOnVulnerabilityReads < Gitlab::Database::Migration[2.2] # -- Legacy migration def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index TABLE_NAME, :id, name: INDEX_NAME, where: "state = 1" + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240729133633_prepare_index_vulnerability_finding_links_on_project_id.rb b/db/post_migrate/20240729133633_prepare_index_vulnerability_finding_links_on_project_id.rb index 145fb53ad9480fa6be21e385b509531901e6514b..aec20205f5fae4b6478919a46f4e3c30e7e0c616 100644 --- a/db/post_migrate/20240729133633_prepare_index_vulnerability_finding_links_on_project_id.rb +++ b/db/post_migrate/20240729133633_prepare_index_vulnerability_finding_links_on_project_id.rb @@ -8,7 +8,9 @@ class PrepareIndexVulnerabilityFindingLinksOnProjectId < Gitlab::Database::Migra # -- Legacy migration def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :vulnerability_finding_links, :project_id, name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240805205657_tmp_index_for_owasp_on_vulnerability_reads.rb b/db/post_migrate/20240805205657_tmp_index_for_owasp_on_vulnerability_reads.rb index 3158fc7a8e9186a0528fddf24be0e381aaa0ee52..2db1881f74dee1621f8bccfaf6718f4b8eb7ca08 100644 --- a/db/post_migrate/20240805205657_tmp_index_for_owasp_on_vulnerability_reads.rb +++ b/db/post_migrate/20240805205657_tmp_index_for_owasp_on_vulnerability_reads.rb @@ -10,7 +10,9 @@ class TmpIndexForOwaspOnVulnerabilityReads < Gitlab::Database::Migration[2.2] # -- Legacy migration def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :vulnerability_reads, COLUMNS, name: INDEX_NAME, where: WHERE_CLAUSE + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20240828173211_add_revised_idx_owasp_top_10_for_group_level_reports.rb b/db/post_migrate/20240828173211_add_revised_idx_owasp_top_10_for_group_level_reports.rb index 7074e911f7b7f0e530952fdec72766f3d752a56f..d8a45208ed36d94eabf7c87ff8a8364dcd06ffa6 100644 --- a/db/post_migrate/20240828173211_add_revised_idx_owasp_top_10_for_group_level_reports.rb +++ b/db/post_migrate/20240828173211_add_revised_idx_owasp_top_10_for_group_level_reports.rb @@ -11,7 +11,9 @@ class AddRevisedIdxOwaspTop10ForGroupLevelReports < Gitlab::Database::Migration[ # -- Legacy migration def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :vulnerability_reads, [:owasp_top_10, :state, :report_type, :resolved_on_default_branch, + # rubocop:enable Migration/PreventIndexCreation :severity, :traversal_ids, :vulnerability_id], where: 'archived = false', name: INDEX_NAME diff --git a/db/post_migrate/20240905023750_async_add_index_on_events_personal_namespace_id_2.rb b/db/post_migrate/20240905023750_async_add_index_on_events_personal_namespace_id_2.rb index 7d1d9648d156bee75f78a9a95d879dc9235aea7e..3ce6679f1c504ae969277a3dfbc009137a4d90cc 100644 --- a/db/post_migrate/20240905023750_async_add_index_on_events_personal_namespace_id_2.rb +++ b/db/post_migrate/20240905023750_async_add_index_on_events_personal_namespace_id_2.rb @@ -9,7 +9,7 @@ class AsyncAddIndexOnEventsPersonalNamespaceId2 < Gitlab::Database::Migration[2. def up return unless Gitlab.com_except_jh? - prepare_async_index :events, :personal_namespace_id, name: INDEX_NAME, + prepare_async_index :events, :personal_namespace_id, name: INDEX_NAME, # rubocop:disable Migration/PreventIndexCreation -- Legacy migration where: 'personal_namespace_id IS NOT NULL' end diff --git a/db/post_migrate/20240909230748_add_index_on_events_personal_namespace_id_self_managed.rb b/db/post_migrate/20240909230748_add_index_on_events_personal_namespace_id_self_managed.rb index a36498752de5dc6a9c5e20ec26e9525b2d8ab5a1..c3b5de0fa1b6e0ae1e5b266a3b6b7a851976d900 100644 --- a/db/post_migrate/20240909230748_add_index_on_events_personal_namespace_id_self_managed.rb +++ b/db/post_migrate/20240909230748_add_index_on_events_personal_namespace_id_self_managed.rb @@ -11,7 +11,7 @@ class AddIndexOnEventsPersonalNamespaceIdSelfManaged < Gitlab::Database::Migrati def up return if Gitlab.com_except_jh? - add_concurrent_index :events, + add_concurrent_index :events, # rubocop:disable Migration/PreventIndexCreation -- Legacy migration :personal_namespace_id, where: 'personal_namespace_id IS NOT NULL', name: INDEX diff --git a/db/post_migrate/20240923114603_add_index_on_vulnerability_reads_for_filtered_removal.rb b/db/post_migrate/20240923114603_add_index_on_vulnerability_reads_for_filtered_removal.rb index 1d3e5f10a62b6bbfa8600c7ba4852f2e8813f5f2..daa6d7c1e66890ed7b958fc3864c2bce76f0362c 100644 --- a/db/post_migrate/20240923114603_add_index_on_vulnerability_reads_for_filtered_removal.rb +++ b/db/post_migrate/20240923114603_add_index_on_vulnerability_reads_for_filtered_removal.rb @@ -9,7 +9,9 @@ class AddIndexOnVulnerabilityReadsForFilteredRemoval < Gitlab::Database::Migrati # -- Legacy migration def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :vulnerability_reads, %i[project_id resolved_on_default_branch], name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20241021221146_prepare_async_index_on_issues_by_project_correct_type_where_closed.rb b/db/post_migrate/20241021221146_prepare_async_index_on_issues_by_project_correct_type_where_closed.rb index 2f08cec6b0215a299a7b9d75525640989700d4cd..00684157988da226a590ccaa69f0c11b21279e52 100644 --- a/db/post_migrate/20241021221146_prepare_async_index_on_issues_by_project_correct_type_where_closed.rb +++ b/db/post_migrate/20241021221146_prepare_async_index_on_issues_by_project_correct_type_where_closed.rb @@ -8,7 +8,9 @@ class PrepareAsyncIndexOnIssuesByProjectCorrectTypeWhereClosed < Gitlab::Databas def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170005 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:project_id, :correct_work_item_type_id, :closed_at], where: 'state_id = 2', name: INDEX_NAME diff --git a/db/post_migrate/20241021221626_prepare_async_index_on_issues_project_health_id_desc_state_correct_type.rb b/db/post_migrate/20241021221626_prepare_async_index_on_issues_project_health_id_desc_state_correct_type.rb index 4c20d1fe744a7387e988f985d6cf3aba545b6412..8503ccf31a8a47addacfafb64eeca459052cf68b 100644 --- a/db/post_migrate/20241021221626_prepare_async_index_on_issues_project_health_id_desc_state_correct_type.rb +++ b/db/post_migrate/20241021221626_prepare_async_index_on_issues_project_health_id_desc_state_correct_type.rb @@ -9,7 +9,9 @@ class PrepareAsyncIndexOnIssuesProjectHealthIdDescStateCorrectType < Gitlab::Dat def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170005 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:project_id, :health_status, :id, :state_id, :correct_work_item_type_id], order: { health_status: 'DESC NULLS LAST', id: :desc }, name: INDEX_NAME diff --git a/db/post_migrate/20241021221755_prepare_async_index_on_issues_project_health_id_asc_state_correct_type.rb b/db/post_migrate/20241021221755_prepare_async_index_on_issues_project_health_id_asc_state_correct_type.rb index a32e782a7ddd86a7a92a677c25377c5109dac1b5..add09338380b069eb1e3e56cfad753520942e797 100644 --- a/db/post_migrate/20241021221755_prepare_async_index_on_issues_project_health_id_asc_state_correct_type.rb +++ b/db/post_migrate/20241021221755_prepare_async_index_on_issues_project_health_id_asc_state_correct_type.rb @@ -9,7 +9,9 @@ class PrepareAsyncIndexOnIssuesProjectHealthIdAscStateCorrectType < Gitlab::Data def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170005 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:project_id, :health_status, :id, :state_id, :correct_work_item_type_id], order: { health_status: 'ASC NULLS LAST', id: :desc }, name: INDEX_NAME diff --git a/db/post_migrate/20241021221938_prepare_async_index_on_issues_correct_type_project_created_at_state.rb b/db/post_migrate/20241021221938_prepare_async_index_on_issues_correct_type_project_created_at_state.rb index 3103ceebc8dafba6272535fc1d59d33c6a6796ce..e4cf21a27eeb7ad785fb0f48808aec81c77293c7 100644 --- a/db/post_migrate/20241021221938_prepare_async_index_on_issues_correct_type_project_created_at_state.rb +++ b/db/post_migrate/20241021221938_prepare_async_index_on_issues_correct_type_project_created_at_state.rb @@ -9,7 +9,9 @@ class PrepareAsyncIndexOnIssuesCorrectTypeProjectCreatedAtState < Gitlab::Databa def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170005 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:correct_work_item_type_id, :project_id, :created_at, :state_id], name: INDEX_NAME end diff --git a/db/post_migrate/20241105213841_create_tmp_index_on_issues_by_project_correct_type_where_closed.rb b/db/post_migrate/20241105213841_create_tmp_index_on_issues_by_project_correct_type_where_closed.rb index 17a47df2d91e2a4c42f1e3b4e16b25d7d3dd0399..688905c5da9dacdd03fee2c427a2a9f4966dc9f2 100644 --- a/db/post_migrate/20241105213841_create_tmp_index_on_issues_by_project_correct_type_where_closed.rb +++ b/db/post_migrate/20241105213841_create_tmp_index_on_issues_by_project_correct_type_where_closed.rb @@ -8,7 +8,9 @@ class CreateTmpIndexOnIssuesByProjectCorrectTypeWhereClosed < Gitlab::Database:: def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:project_id, :correct_work_item_type_id, :closed_at], where: 'state_id = 2', name: INDEX_NAME diff --git a/db/post_migrate/20241105215409_create_tmp_index_on_issues_project_health_id_desc_state_correct_type.rb b/db/post_migrate/20241105215409_create_tmp_index_on_issues_project_health_id_desc_state_correct_type.rb index c6e1e462b2be8625c7f96b834fff9217f9fc5aa7..12a24feff6921f429accbf4bb8b6556e9ab1c8d6 100644 --- a/db/post_migrate/20241105215409_create_tmp_index_on_issues_project_health_id_desc_state_correct_type.rb +++ b/db/post_migrate/20241105215409_create_tmp_index_on_issues_project_health_id_desc_state_correct_type.rb @@ -8,7 +8,9 @@ class CreateTmpIndexOnIssuesProjectHealthIdDescStateCorrectType < Gitlab::Databa def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:project_id, :health_status, :id, :state_id, :correct_work_item_type_id], order: { health_status: 'DESC NULLS LAST', id: :desc }, name: INDEX_NAME diff --git a/db/post_migrate/20241105215907_create_tmp_index_on_issues_project_health_id_asc_state_correct_type.rb b/db/post_migrate/20241105215907_create_tmp_index_on_issues_project_health_id_asc_state_correct_type.rb index a4091559d2ceda235b22ec6d7265bb4035a7017d..edd2c1f690046837966d5beb0a8cd84ceb2bc188 100644 --- a/db/post_migrate/20241105215907_create_tmp_index_on_issues_project_health_id_asc_state_correct_type.rb +++ b/db/post_migrate/20241105215907_create_tmp_index_on_issues_project_health_id_asc_state_correct_type.rb @@ -8,7 +8,9 @@ class CreateTmpIndexOnIssuesProjectHealthIdAscStateCorrectType < Gitlab::Databas def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:project_id, :health_status, :id, :state_id, :correct_work_item_type_id], order: { health_status: 'ASC NULLS LAST', id: :desc }, name: INDEX_NAME diff --git a/db/post_migrate/20241105220155_create_tmp_index_on_issues_correct_type_project_created_at_state.rb b/db/post_migrate/20241105220155_create_tmp_index_on_issues_correct_type_project_created_at_state.rb index 33dd94372625349b4a473d155c49875820fa867c..99d46fc7e589994d741bda2e35927e1a0ddcf5cf 100644 --- a/db/post_migrate/20241105220155_create_tmp_index_on_issues_correct_type_project_created_at_state.rb +++ b/db/post_migrate/20241105220155_create_tmp_index_on_issues_correct_type_project_created_at_state.rb @@ -8,7 +8,9 @@ class CreateTmpIndexOnIssuesCorrectTypeProjectCreatedAtState < Gitlab::Database: def up # Temporary index to be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/500165 + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :issues, # -- Tmp index needed to fix work item type ids + # rubocop:enable Migration/PreventIndexCreation [:correct_work_item_type_id, :project_id, :created_at, :state_id], name: INDEX_NAME end diff --git a/db/post_migrate/20241106125627_update_sent_notifications_index_on_noteable.rb b/db/post_migrate/20241106125627_update_sent_notifications_index_on_noteable.rb index dc4e4232d6aa6e6ca4eba8c65a26d602b1892605..9354a8a79b38dc39ec4e64cb086d1fe6138f37ee 100644 --- a/db/post_migrate/20241106125627_update_sent_notifications_index_on_noteable.rb +++ b/db/post_migrate/20241106125627_update_sent_notifications_index_on_noteable.rb @@ -15,7 +15,9 @@ class UpdateSentNotificationsIndexOnNoteable < Gitlab::Database::Migration[2.2] # "index_sent_notifications_on_noteable_type_noteable_id_id" btree (noteable_id, id) WHERE noteable_type = 'Issue' # to improve iterating over issue related sent notification records in batches. def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration prepare_async_index :sent_notifications, COLUMN_NAMES, where: "noteable_type = 'Issue'", name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/db/post_migrate/20241129104531_create_sent_notifications_index_on_noteable_synchronously.rb b/db/post_migrate/20241129104531_create_sent_notifications_index_on_noteable_synchronously.rb index 13cb20c5069f478d92981f0c11631fe9113eb1e7..ac02f3da4e15036a02a3a068ce7e1e55b04abc72 100644 --- a/db/post_migrate/20241129104531_create_sent_notifications_index_on_noteable_synchronously.rb +++ b/db/post_migrate/20241129104531_create_sent_notifications_index_on_noteable_synchronously.rb @@ -10,7 +10,9 @@ class CreateSentNotificationsIndexOnNoteableSynchronously < Gitlab::Database::Mi # Creating prepared index in 20241106125627_update_sent_notifications_index_on_noteable # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/171687 def up + # rubocop:disable Migration/PreventIndexCreation -- Legacy migration add_concurrent_index :sent_notifications, COLUMN_NAMES, where: "noteable_type = 'Issue'", name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation end def down diff --git a/rubocop/cop/migration/prevent_index_creation.rb b/rubocop/cop/migration/prevent_index_creation.rb index 8871886588585d205862c31823853f83dc64b716..a1e84ad685d817b16844fc35014089494c25dcb8 100644 --- a/rubocop/cop/migration/prevent_index_creation.rb +++ b/rubocop/cop/migration/prevent_index_creation.rb @@ -74,7 +74,7 @@ def on_def(node) private def forbidden_tables?(node) - FORBIDDEN_TABLES.include?(node.to_sym) || large_tables.include?(node.to_sym) + FORBIDDEN_TABLES.include?(node.to_sym) || large_or_over_limit_tables.include?(node.to_sym) end def offense?(node) diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index eb4d5491ff658eb69ff9437618fc3ac014ba374a..c8727aebc8cdc2112c558f09f89a387fa11ea4e7 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -32,8 +32,8 @@ def over_limit_tables @over_limit_table ||= rubocop_migrations_config.dig('Migration/UpdateLargeTable', 'OverLimitTables') end - def large_tables - @large_tables ||= rubocop_migrations_config.dig('Migration/UpdateLargeTable', 'LargeTables') + def large_or_over_limit_tables + @large_or_over_limit_tables ||= large_tables + over_limit_tables end # Returns true if the given node originated from the db/migrate directory. @@ -87,6 +87,10 @@ def array_column?(node) private + def large_tables + @large_tables ||= rubocop_migrations_config.dig('Migration/UpdateLargeTable', 'LargeTables') + end + def filepath(node) node.location.expression.source_buffer.name end diff --git a/spec/rubocop/cop/migration/prevent_index_creation_spec.rb b/spec/rubocop/cop/migration/prevent_index_creation_spec.rb index 3a3409b67db87d7d32436f84e0c9113b1a838d89..0cb44a4619bab287757deecf4098cdb41796b1b1 100644 --- a/spec/rubocop/cop/migration/prevent_index_creation_spec.rb +++ b/spec/rubocop/cop/migration/prevent_index_creation_spec.rb @@ -7,7 +7,7 @@ include RuboCop::MigrationHelpers let(:forbidden_tables) do - described_class::FORBIDDEN_TABLES + large_tables + described_class::FORBIDDEN_TABLES + large_or_over_limit_tables end context 'when in migration' do