diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /db/post_migrate | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'db/post_migrate')
509 files changed, 2282 insertions, 7934 deletions
diff --git a/db/post_migrate/20220128103042_schedule_delete_invalid_epic_issues_revised.rb b/db/post_migrate/20220128103042_schedule_delete_invalid_epic_issues_revised.rb deleted file mode 100644 index 642bf012ce0..00000000000 --- a/db/post_migrate/20220128103042_schedule_delete_invalid_epic_issues_revised.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDeleteInvalidEpicIssuesRevised < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - MIGRATION = 'DeleteInvalidEpicIssues' - INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 2_000 - SUB_BATCH_SIZE = 50 - - def up - queue_batched_background_migration( - MIGRATION, - :epics, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :epics, :id, []) - end -end diff --git a/db/post_migrate/20220213103859_remove_integrations_type.rb b/db/post_migrate/20220213103859_remove_integrations_type.rb deleted file mode 100644 index 3c420760a2d..00000000000 --- a/db/post_migrate/20220213103859_remove_integrations_type.rb +++ /dev/null @@ -1,132 +0,0 @@ -# frozen_string_literal: true - -class RemoveIntegrationsType < Gitlab::Database::Migration[1.0] - disable_ddl_transaction! - - MIGRATION = 'BackfillIntegrationsTypeNew' - BATCH_SIZE = 50 - TABLE_NAME = :integrations - COLUMN = :type - - # see db/post_migrate/20220213104531_create_indexes_on_integration_type_new.rb - def indices - [ - { - name: "index_integrations_on_project_and_#{COLUMN}_where_inherit_null", - columns: [:project_id, COLUMN], - where: 'inherit_from_id IS NULL' - }, - { - name: "index_integrations_on_project_id_and_#{COLUMN}_unique", - columns: [:project_id, COLUMN], - unique: true - }, - { - name: "index_integrations_on_#{COLUMN}", - columns: [COLUMN] - }, - { - name: "index_integrations_on_#{COLUMN}_and_instance_partial", - columns: [COLUMN, :instance], - where: 'instance = true', - unique: true - }, - { - name: 'index_integrations_on_type_id_when_active_and_project_id_not_nu', - columns: [COLUMN, :id], - where: '((active = true) AND (project_id IS NOT NULL))' - }, - { - name: "index_integrations_on_unique_group_id_and_#{COLUMN}", - columns: [:group_id, COLUMN], - unique: true - } - ] - end - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: TABLE_NAME, - column_name: :id, - job_arguments: []) - - cleanup_unmigrated_rows! - - remove_column :integrations, :type, :text - end - - # WARNING: this migration is not really safe to be reverted, since doing so - # will leave the type column empty. If this migration is reverted, we will - # need to backfill it from type_new - def down - add_column :integrations, :type, 'character varying' - - indices.each do |index| - add_concurrent_index TABLE_NAME, index[:columns], index.except(:columns) - end - end - - # Convert any remaining unmigrated rows - def cleanup_unmigrated_rows! - tmp_index_name = 'tmp_idx_integrations_unmigrated_type_new' - add_concurrent_index :integrations, :id, where: 'type_new is null', name: tmp_index_name - - define_batchable_model(:integrations).where(type_new: nil).each_batch do |batch| - min_id, max_id = batch.pick(Arel.sql('MIN(id), MAX(id)')) - - connection.execute(<<~SQL) - WITH mapping(old_type, new_type) AS (VALUES - ('AsanaService', 'Integrations::Asana'), - ('AssemblaService', 'Integrations::Assembla'), - ('BambooService', 'Integrations::Bamboo'), - ('BugzillaService', 'Integrations::Bugzilla'), - ('BuildkiteService', 'Integrations::Buildkite'), - ('CampfireService', 'Integrations::Campfire'), - ('ConfluenceService', 'Integrations::Confluence'), - ('CustomIssueTrackerService', 'Integrations::CustomIssueTracker'), - ('DatadogService', 'Integrations::Datadog'), - ('DiscordService', 'Integrations::Discord'), - ('DroneCiService', 'Integrations::DroneCi'), - ('EmailsOnPushService', 'Integrations::EmailsOnPush'), - ('EwmService', 'Integrations::Ewm'), - ('ExternalWikiService', 'Integrations::ExternalWiki'), - ('FlowdockService', 'Integrations::Flowdock'), - ('HangoutsChatService', 'Integrations::HangoutsChat'), - ('IrkerService', 'Integrations::Irker'), - ('JenkinsService', 'Integrations::Jenkins'), - ('JiraService', 'Integrations::Jira'), - ('MattermostService', 'Integrations::Mattermost'), - ('MattermostSlashCommandsService', 'Integrations::MattermostSlashCommands'), - ('MicrosoftTeamsService', 'Integrations::MicrosoftTeams'), - ('MockCiService', 'Integrations::MockCi'), - ('MockMonitoringService', 'Integrations::MockMonitoring'), - ('PackagistService', 'Integrations::Packagist'), - ('PipelinesEmailService', 'Integrations::PipelinesEmail'), - ('PivotaltrackerService', 'Integrations::Pivotaltracker'), - ('PrometheusService', 'Integrations::Prometheus'), - ('PushoverService', 'Integrations::Pushover'), - ('RedmineService', 'Integrations::Redmine'), - ('SlackService', 'Integrations::Slack'), - ('SlackSlashCommandsService', 'Integrations::SlackSlashCommands'), - ('TeamcityService', 'Integrations::Teamcity'), - ('UnifyCircuitService', 'Integrations::UnifyCircuit'), - ('WebexTeamsService', 'Integrations::WebexTeams'), - ('YoutrackService', 'Integrations::Youtrack'), - - -- EE-only integrations - ('GithubService', 'Integrations::Github'), - ('GitlabSlackApplicationService', 'Integrations::GitlabSlackApplication') - ) - - UPDATE integrations SET type_new = mapping.new_type - FROM mapping - WHERE integrations.type_new IS NULL - AND integrations.id BETWEEN #{min_id} AND #{max_id} - AND integrations.type = mapping.old_type - SQL - end - ensure - remove_concurrent_index_by_name(:integrations, tmp_index_name) - end -end diff --git a/db/post_migrate/20220314154235_migrate_vulnerability_approval_rules.rb b/db/post_migrate/20220314154235_migrate_vulnerability_approval_rules.rb deleted file mode 100644 index f9ad2ba4f0c..00000000000 --- a/db/post_migrate/20220314154235_migrate_vulnerability_approval_rules.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateVulnerabilityApprovalRules < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # no-op - end - - def down - # no-op - # Vulnerability-Check feature has been removed as part of 15.0 - end -end diff --git a/db/post_migrate/20220324165436_schedule_backfill_project_settings.rb b/db/post_migrate/20220324165436_schedule_backfill_project_settings.rb deleted file mode 100644 index 07a7b8b8989..00000000000 --- a/db/post_migrate/20220324165436_schedule_backfill_project_settings.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillProjectSettings < Gitlab::Database::Migration[1.0] - MIGRATION = 'BackfillProjectSettings' - INTERVAL = 2.minutes - BATCH_SIZE = 5_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - def up - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20220328095848_delete_failed_reset_duplicate_ci_runners_token_migration_records.rb b/db/post_migrate/20220328095848_delete_failed_reset_duplicate_ci_runners_token_migration_records.rb deleted file mode 100644 index 3c1a6a48ef5..00000000000 --- a/db/post_migrate/20220328095848_delete_failed_reset_duplicate_ci_runners_token_migration_records.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DeleteFailedResetDuplicateCiRunnersTokenMigrationRecords < Gitlab::Database::Migration[1.0] - def up - # Delete remaining records of botched migrations before we start the new migrations - Gitlab::Database::BackgroundMigrationJob - .for_migration_class('ResetDuplicateCiRunnersTokenValuesOnProjects') - .delete_all - Gitlab::Database::BackgroundMigrationJob - .for_migration_class('ResetDuplicateCiRunnersTokenEncryptedValuesOnProjects') - .delete_all - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220328100456_schedule20220328_reset_duplicate_ci_runners_token_encrypted_values_on_projects.rb b/db/post_migrate/20220328100456_schedule20220328_reset_duplicate_ci_runners_token_encrypted_values_on_projects.rb deleted file mode 100644 index 326a8e30ecb..00000000000 --- a/db/post_migrate/20220328100456_schedule20220328_reset_duplicate_ci_runners_token_encrypted_values_on_projects.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class Schedule20220328ResetDuplicateCiRunnersTokenEncryptedValuesOnProjects < Gitlab::Database::Migration[1.0] - MIGRATION = 'ResetDuplicateCiRunnersTokenEncryptedValuesOnProjects' - BATCH_SIZE = 2_000 - DELAY_INTERVAL = 2.minutes - - disable_ddl_transaction! - - class Project < ActiveRecord::Base # rubocop:disable Style/Documentation - include ::EachBatch - - self.table_name = 'projects' - - scope :base_query, -> { where.not(runners_token_encrypted: nil) } - end - - def up - queue_background_migration_jobs_by_range_at_intervals( - Project.base_query, - MIGRATION, - DELAY_INTERVAL, - batch_size: BATCH_SIZE, - track_jobs: true - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220328100457_schedule20220328_reset_duplicate_ci_runners_token_values_on_projects.rb b/db/post_migrate/20220328100457_schedule20220328_reset_duplicate_ci_runners_token_values_on_projects.rb deleted file mode 100644 index d999def0078..00000000000 --- a/db/post_migrate/20220328100457_schedule20220328_reset_duplicate_ci_runners_token_values_on_projects.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class Schedule20220328ResetDuplicateCiRunnersTokenValuesOnProjects < Gitlab::Database::Migration[1.0] - MIGRATION = 'ResetDuplicateCiRunnersTokenValuesOnProjects' - BATCH_SIZE = 2_000 - DELAY_INTERVAL = 2.minutes - - disable_ddl_transaction! - - class Project < ActiveRecord::Base # rubocop:disable Style/Documentation - include ::EachBatch - - self.table_name = 'projects' - - scope :base_query, -> { where.not(runners_token: nil) } - end - - def up - queue_background_migration_jobs_by_range_at_intervals( - Project.base_query, - MIGRATION, - DELAY_INTERVAL, - batch_size: BATCH_SIZE, - track_jobs: true - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220331133802_schedule_backfill_topics_title.rb b/db/post_migrate/20220331133802_schedule_backfill_topics_title.rb deleted file mode 100644 index 8e594a9df52..00000000000 --- a/db/post_migrate/20220331133802_schedule_backfill_topics_title.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillTopicsTitle < Gitlab::Database::Migration[1.0] - MIGRATION = 'BackfillTopicsTitle' - DELAY_INTERVAL = 2.minutes - - disable_ddl_transaction! - - def up - queue_background_migration_jobs_by_range_at_intervals( - define_batchable_model('topics'), - MIGRATION, - DELAY_INTERVAL, - track_jobs: true - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220405092619_toggle_vsa_aggregations_enable.rb b/db/post_migrate/20220405092619_toggle_vsa_aggregations_enable.rb deleted file mode 100644 index da1353b5cf9..00000000000 --- a/db/post_migrate/20220405092619_toggle_vsa_aggregations_enable.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class ToggleVsaAggregationsEnable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - model = define_batchable_model('analytics_cycle_analytics_aggregations') - - model.each_batch(of: 100) do |relation| - relation.where('enabled IS FALSE').update_all(enabled: true) - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20220407163559_schedule_purging_stale_security_scans.rb b/db/post_migrate/20220407163559_schedule_purging_stale_security_scans.rb deleted file mode 100644 index fdceb2f2594..00000000000 --- a/db/post_migrate/20220407163559_schedule_purging_stale_security_scans.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class SchedulePurgingStaleSecurityScans < Gitlab::Database::Migration[2.0] - MIGRATION = 'PurgeStaleSecurityScans' - BATCH_SIZE = 10_000 - DELAY_INTERVAL = 2.minutes - - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - def up - return unless should_run? - - queue_background_migration_jobs_by_range_at_intervals( - Gitlab::BackgroundMigration::PurgeStaleSecurityScans::SecurityScan.to_purge, - MIGRATION, - DELAY_INTERVAL, - batch_size: BATCH_SIZE, - track_jobs: true - ) - end - - def down - # no-op - end - - private - - def should_run? - Gitlab.dev_or_test_env? || Gitlab.com? - end -end diff --git a/db/post_migrate/20220411173544_cleanup_orphans_approval_project_rules.rb b/db/post_migrate/20220411173544_cleanup_orphans_approval_project_rules.rb deleted file mode 100644 index f7132407adb..00000000000 --- a/db/post_migrate/20220411173544_cleanup_orphans_approval_project_rules.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CleanupOrphansApprovalProjectRules < Gitlab::Database::Migration[1.0] - class ApprovalProjectRule < ActiveRecord::Base - self.table_name = 'approval_project_rules' - end - - def up - return unless Gitlab.ee? - - ApprovalProjectRule.reset_column_information - - logger = ::Gitlab::BackgroundMigration::Logger.build - records_ids = [] - - # Related enum: report_type: { vulnerability: 1, license_scanning: 2, code_coverage: 3, scan_finding: 4 } - ApprovalProjectRule.where(report_type: 4) - .joins("LEFT JOIN security_orchestration_policy_configurations - ON approval_project_rules.project_id = security_orchestration_policy_configurations.project_id") - .where(security_orchestration_policy_configurations: { project_id: nil }).each do |record| - records_ids << record.id - logger.info( - message: "CleanupOrphansApprovalProjectRules with record id: #{record.id}", - class: ApprovalProjectRule.name, - attributes: record.attributes - ) - end - - ApprovalProjectRule.where(id: records_ids).delete_all - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220415124802_remove_job_artifact_deprecated_geo_fields.rb b/db/post_migrate/20220415124802_remove_job_artifact_deprecated_geo_fields.rb deleted file mode 100644 index 65432ba3ce1..00000000000 --- a/db/post_migrate/20220415124802_remove_job_artifact_deprecated_geo_fields.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RemoveJobArtifactDeprecatedGeoFields < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_column :geo_event_log, :job_artifact_deleted_event_id, :bigint - end - end - - def down - with_lock_retries do - unless column_exists?(:geo_event_log, :job_artifact_deleted_event_id) - add_column(:geo_event_log, :job_artifact_deleted_event_id, :bigint) - end - end - - add_concurrent_foreign_key :geo_event_log, :geo_job_artifact_deleted_events, - column: :job_artifact_deleted_event_id, - name: 'fk_176d3fbb5d', - on_delete: :cascade - - add_concurrent_index :geo_event_log, - :job_artifact_deleted_event_id, - name: 'index_geo_event_log_on_job_artifact_deleted_event_id', - where: "(job_artifact_deleted_event_id IS NOT NULL)" - end -end diff --git a/db/post_migrate/20220415124804_remove_job_artifact_deleted_event_table.rb b/db/post_migrate/20220415124804_remove_job_artifact_deleted_event_table.rb deleted file mode 100644 index 05b716f26ab..00000000000 --- a/db/post_migrate/20220415124804_remove_job_artifact_deleted_event_table.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveJobArtifactDeletedEventTable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - drop_table :geo_job_artifact_deleted_events - end - - def down - create_table :geo_job_artifact_deleted_events, id: :bigserial do |t| - t.bigint :job_artifact_id, null: false, index: true - t.string :file_path, null: false - end - end -end diff --git a/db/post_migrate/20220418180958_remove_integrations_properties.rb b/db/post_migrate/20220418180958_remove_integrations_properties.rb deleted file mode 100644 index 781b8c8ac72..00000000000 --- a/db/post_migrate/20220418180958_remove_integrations_properties.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class RemoveIntegrationsProperties < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def change - remove_column :integrations, :properties, :text - end -end diff --git a/db/post_migrate/20220420061439_add_notes_null_discussion_id_temp_index.rb b/db/post_migrate/20220420061439_add_notes_null_discussion_id_temp_index.rb deleted file mode 100644 index 35a6d5f5b10..00000000000 --- a/db/post_migrate/20220420061439_add_notes_null_discussion_id_temp_index.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddNotesNullDiscussionIdTempIndex < Gitlab::Database::Migration[2.0] - # Temporary index to be removed in 15.0 https://gitlab.com/gitlab-org/gitlab/-/issues/357581 - INDEX_NAME = 'tmp_index_notes_on_id_where_discussion_id_is_null' - - disable_ddl_transaction! - - def up - add_concurrent_index :notes, :id, where: 'discussion_id IS NULL', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :notes, INDEX_NAME - end -end diff --git a/db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb b/db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb deleted file mode 100644 index 8880bc2f748..00000000000 --- a/db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class BackfillNullNoteDiscussionIds < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillNoteDiscussionId' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 10_000 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - disable_ddl_transaction! - - class Note < MigrationRecord - include EachBatch - - self.table_name = 'notes' - self.inheritance_column = :_type_disabled - end - - def up - queue_background_migration_jobs_by_range_at_intervals( - Note.where(discussion_id: nil), - MIGRATION, - DELAY_INTERVAL, - batch_size: BATCH_SIZE - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220420135946_update_batched_background_migration_arguments.rb b/db/post_migrate/20220420135946_update_batched_background_migration_arguments.rb deleted file mode 100644 index 40ed98dcb5e..00000000000 --- a/db/post_migrate/20220420135946_update_batched_background_migration_arguments.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class UpdateBatchedBackgroundMigrationArguments < Gitlab::Database::Migration[1.0] - def up - execute(<<~SQL) - UPDATE batched_background_migrations - SET job_arguments = '[]' - WHERE job_arguments = '"[]"'; - SQL - end - - def down - execute(<<~SQL) - UPDATE batched_background_migrations - SET job_arguments = '"[]"' - WHERE job_arguments = '[]'; - SQL - end -end diff --git a/db/post_migrate/20220420214703_schedule_backfill_draft_status_on_merge_requests_corrected_regex.rb b/db/post_migrate/20220420214703_schedule_backfill_draft_status_on_merge_requests_corrected_regex.rb deleted file mode 100644 index 9640d5d2516..00000000000 --- a/db/post_migrate/20220420214703_schedule_backfill_draft_status_on_merge_requests_corrected_regex.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillDraftStatusOnMergeRequestsCorrectedRegex < Gitlab::Database::Migration[1.0] - INDEX_NAME = "tmp_index_merge_requests_draft_and_status" - MIGRATION = "BackfillDraftStatusOnMergeRequestsWithCorrectedRegex" - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 50 - CORRECTED_REGEXP_STR = "^(\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP)" - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_requests, :id, - where: "draft = false AND state_id = 1 AND ((title)::text ~* '#{CORRECTED_REGEXP_STR}'::text)", - name: INDEX_NAME - - eligible_mrs = MergeRequest.where(state_id: 1) - .where(draft: false) - .where("title ~* ?", CORRECTED_REGEXP_STR) - - queue_background_migration_jobs_by_range_at_intervals( - eligible_mrs, - MIGRATION, - DELAY_INTERVAL, - track_jobs: true, - batch_size: BATCH_SIZE - ) - end - - def down - remove_concurrent_index_by_name :merge_requests, INDEX_NAME - end -end diff --git a/db/post_migrate/20220422121443_add_async_index_for_group_activity_events.rb b/db/post_migrate/20220422121443_add_async_index_for_group_activity_events.rb deleted file mode 100644 index 92b97203eed..00000000000 --- a/db/post_migrate/20220422121443_add_async_index_for_group_activity_events.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexForGroupActivityEvents < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_events_for_group_activity' - - def up - prepare_async_index :events, %I[group_id target_type action id], name: INDEX_NAME, where: 'group_id IS NOT NULL' - end - - def down - unprepare_async_index :events, %I[group_id target_type action id], name: INDEX_NAME, where: 'group_id IS NOT NULL' - end -end diff --git a/db/post_migrate/20220425111114_add_async_index_for_project_activity_events.rb b/db/post_migrate/20220425111114_add_async_index_for_project_activity_events.rb deleted file mode 100644 index b203ceca976..00000000000 --- a/db/post_migrate/20220425111114_add_async_index_for_project_activity_events.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexForProjectActivityEvents < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_events_for_project_activity' - - def up - prepare_async_index :events, %I[project_id target_type action id], name: INDEX_NAME - end - - def down - unprepare_async_index :events, %I[project_id target_type action id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220425111453_add_async_index_to_events_on_group_id_and_id.rb b/db/post_migrate/20220425111453_add_async_index_to_events_on_group_id_and_id.rb deleted file mode 100644 index 313a31d8964..00000000000 --- a/db/post_migrate/20220425111453_add_async_index_to_events_on_group_id_and_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexToEventsOnGroupIdAndId < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_events_on_group_id_and_id' - - def up - prepare_async_index :events, %I[group_id id], name: INDEX_NAME, where: 'group_id IS NOT NULL' - end - - def down - unprepare_async_index :events, %I[group_id id], name: INDEX_NAME, where: 'group_id IS NOT NULL' - end -end diff --git a/db/post_migrate/20220425121410_add_temporary_index_for_backfill_integrations_enable_ssl_verification.rb b/db/post_migrate/20220425121410_add_temporary_index_for_backfill_integrations_enable_ssl_verification.rb deleted file mode 100644 index d0f8e60fa54..00000000000 --- a/db/post_migrate/20220425121410_add_temporary_index_for_backfill_integrations_enable_ssl_verification.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddTemporaryIndexForBackfillIntegrationsEnableSslVerification < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_integrations_on_id_where_type_droneci_or_teamcity' - INDEX_CONDITION = "type_new IN ('Integrations::DroneCi', 'Integrations::Teamcity') " \ - "AND encrypted_properties IS NOT NULL" - - def up - # this index is used in 20220209121435_backfill_integrations_enable_ssl_verification - add_concurrent_index :integrations, :id, where: INDEX_CONDITION, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :integrations, INDEX_NAME - end -end diff --git a/db/post_migrate/20220425121435_backfill_integrations_enable_ssl_verification.rb b/db/post_migrate/20220425121435_backfill_integrations_enable_ssl_verification.rb deleted file mode 100644 index 101bde975db..00000000000 --- a/db/post_migrate/20220425121435_backfill_integrations_enable_ssl_verification.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -class BackfillIntegrationsEnableSslVerification < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'BackfillIntegrationsEnableSslVerification' - INTERVAL = 5.minutes - BATCH_SIZE = 1_000 - - class Integration < MigrationRecord - include EachBatch - include IgnorableColumns - - self.table_name = :integrations - self.inheritance_column = :_type_disabled - - ignore_column :template, remove_with: '15.0', remove_after: '2022-04-22' - ignore_column :type, remove_with: '15.0', remove_after: '2022-04-22' - ignore_column :properties, remove_with: '15.1', remove_after: '2022-05-22' - - scope :affected, -> do - where(type_new: %w[Integrations::DroneCi Integrations::Teamcity]).where.not(encrypted_properties: nil) - end - - attr_encrypted :properties, - mode: :per_attribute_iv, - key: Settings.attr_encrypted_db_key_base_32, - algorithm: 'aes-256-gcm', - marshal: true, - marshaler: ::Gitlab::Json, - encode: false, - encode_iv: false - - # Handle assignment of props with symbol keys. - # To do this correctly, we need to call the method generated by attr_encrypted. - alias_method :attr_encrypted_props=, :properties= - private :attr_encrypted_props= - - def properties=(props) - self.attr_encrypted_props = props&.with_indifferent_access&.freeze - end - end - - def up - queue_background_migration_jobs_by_range_at_intervals( - Integration.affected, - MIGRATION, - INTERVAL, - batch_size: BATCH_SIZE, - track_jobs: true - ) - end - - def down - end -end diff --git a/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb b/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb deleted file mode 100644 index 860756de298..00000000000 --- a/db/post_migrate/20220426185933_backfill_deployments_finished_at.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class BackfillDeploymentsFinishedAt < Gitlab::Database::Migration[2.0] - DEPLOYMENT_STATUS_SUCCESS = 2 # Equivalent to Deployment.statuses[:success] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 100 - - def up - define_batchable_model('deployments') - .where(finished_at: nil) - .where(status: DEPLOYMENT_STATUS_SUCCESS) - .each_batch(of: BATCH_SIZE) { |relation| relation.update_all('finished_at = created_at') } - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220428133724_schedule_expire_o_auth_tokens.rb b/db/post_migrate/20220428133724_schedule_expire_o_auth_tokens.rb deleted file mode 100644 index 3e0e9b8af0e..00000000000 --- a/db/post_migrate/20220428133724_schedule_expire_o_auth_tokens.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class ScheduleExpireOAuthTokens < Gitlab::Database::Migration[2.0] - def up - # reschedulled with db/post_migrate/20220513043344_reschedule_expire_o_auth_tokens.rb - end - - def down - # reschedulled with db/post_migrate/20220513043344_reschedule_expire_o_auth_tokens.rb - end -end diff --git a/db/post_migrate/20220502015011_clean_up_fix_merge_request_diff_commit_users.rb b/db/post_migrate/20220502015011_clean_up_fix_merge_request_diff_commit_users.rb deleted file mode 100644 index a3e59b38975..00000000000 --- a/db/post_migrate/20220502015011_clean_up_fix_merge_request_diff_commit_users.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CleanUpFixMergeRequestDiffCommitUsers < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - MIGRATION_CLASS = 'FixMergeRequestDiffCommitUsers' - - def up - finalize_background_migration(MIGRATION_CLASS) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220502173045_reset_too_many_tags_skipped_registry_imports.rb b/db/post_migrate/20220502173045_reset_too_many_tags_skipped_registry_imports.rb deleted file mode 100644 index e327035d6c9..00000000000 --- a/db/post_migrate/20220502173045_reset_too_many_tags_skipped_registry_imports.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class ResetTooManyTagsSkippedRegistryImports < Gitlab::Database::Migration[2.0] - MIGRATION = 'ResetTooManyTagsSkippedRegistryImports' - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 10_000 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_background_migration_jobs_by_range_at_intervals( - define_batchable_model('container_repositories').where( - migration_state: 'import_skipped', - migration_skipped_reason: 2 - ), - MIGRATION, - DELAY_INTERVAL, - batch_size: BATCH_SIZE, - track_jobs: true - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220503114353_prepare_confidential_note_index.rb b/db/post_migrate/20220503114353_prepare_confidential_note_index.rb deleted file mode 100644 index 08e60f3d935..00000000000 --- a/db/post_migrate/20220503114353_prepare_confidential_note_index.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class PrepareConfidentialNoteIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_notes_on_confidential' - - def up - prepare_async_index :notes, :confidential, where: 'confidential = true', name: INDEX_NAME - end - - def down - unprepare_async_index :notes, :confidential, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220503134610_remove_requirements_management_test_reports_requirement_id.rb b/db/post_migrate/20220503134610_remove_requirements_management_test_reports_requirement_id.rb deleted file mode 100644 index 4c46a02c99f..00000000000 --- a/db/post_migrate/20220503134610_remove_requirements_management_test_reports_requirement_id.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class RemoveRequirementsManagementTestReportsRequirementId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TARGET_TABLE = :requirements_management_test_reports - CONSTRAINT_NAME = 'fk_rails_fb3308ad55' - - def up - with_lock_retries do - remove_column TARGET_TABLE, :requirement_id - end - end - - def down - unless column_exists?(TARGET_TABLE, :requirement_id) - with_lock_retries do - add_column TARGET_TABLE, :requirement_id, :bigint, after: :created_at - end - end - - add_concurrent_index TARGET_TABLE, :requirement_id, - name: :index_requirements_management_test_reports_on_requirement_id - - add_concurrent_foreign_key TARGET_TABLE, :requirements, - column: :requirement_id, name: CONSTRAINT_NAME, on_delete: :cascade - end -end diff --git a/db/post_migrate/20220504083348_add_indexes_for_primary_email_post_regression_cleanup_migration.rb b/db/post_migrate/20220504083348_add_indexes_for_primary_email_post_regression_cleanup_migration.rb deleted file mode 100644 index ba0457fa36e..00000000000 --- a/db/post_migrate/20220504083348_add_indexes_for_primary_email_post_regression_cleanup_migration.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class AddIndexesForPrimaryEmailPostRegressionCleanupMigration < Gitlab::Database::Migration[2.0] - USERS_INDEX = :index_users_on_id_for_primary_email_migration - EMAIL_INDEX = :index_emails_on_email_user_id - - disable_ddl_transaction! - - def up - unless index_exists_by_name?(:users, USERS_INDEX) - - disable_statement_timeout do - execute <<~SQL - CREATE INDEX CONCURRENTLY #{USERS_INDEX} - ON users (id) INCLUDE (email, confirmed_at) - WHERE confirmed_at IS NOT NULL - SQL - end - end - - add_concurrent_index :emails, [:email, :user_id], name: EMAIL_INDEX - end - - def down - remove_concurrent_index_by_name :users, USERS_INDEX - remove_concurrent_index_by_name :emails, EMAIL_INDEX - end -end diff --git a/db/post_migrate/20220504083836_cleanup_after_fixing_regression_with_new_users_emails.rb b/db/post_migrate/20220504083836_cleanup_after_fixing_regression_with_new_users_emails.rb deleted file mode 100644 index 110e2578cd5..00000000000 --- a/db/post_migrate/20220504083836_cleanup_after_fixing_regression_with_new_users_emails.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -class CleanupAfterFixingRegressionWithNewUsersEmails < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 10_000 - - # Stubbed class to access the User table - class User < MigrationRecord - include ::EachBatch - - self.table_name = 'users' - self.inheritance_column = :_type_disabled - - scope :confirmed, -> { where.not(confirmed_at: nil) } - - has_many :emails - end - - # Stubbed class to access the Emails table - class Email < MigrationRecord - self.table_name = 'emails' - self.inheritance_column = :_type_disabled - - belongs_to :user - end - - # rubocop: disable Layout/LineLength - def up - # Select confirmed users that do not have their primary email in the emails table, - # and create the email record. - not_exists_condition = 'NOT EXISTS (SELECT 1 FROM emails WHERE emails.email = users.email AND emails.user_id = users.id)' - - User.confirmed.each_batch(of: BATCH_SIZE) do |user_batch| - user_batch.select(:id, :email, :confirmed_at).where(not_exists_condition).each do |user| - current_time = Time.now.utc - - begin - Email.create( - user_id: user.id, - email: user.email, - confirmed_at: user.confirmed_at, - created_at: current_time, - updated_at: current_time - ) - rescue StandardError => error - Gitlab::AppLogger.error("Could not add primary email #{user.email} to emails for user with ID #{user.id} due to #{error}") - end - end - end - end - # rubocop: enable Layout/LineLength - - def down - # Intentionally left blank - end -end diff --git a/db/post_migrate/20220504084136_drop_temporary_indexes_for_primary_email_post_regression_cleanup.rb b/db/post_migrate/20220504084136_drop_temporary_indexes_for_primary_email_post_regression_cleanup.rb deleted file mode 100644 index 60c69426a8a..00000000000 --- a/db/post_migrate/20220504084136_drop_temporary_indexes_for_primary_email_post_regression_cleanup.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class DropTemporaryIndexesForPrimaryEmailPostRegressionCleanup < Gitlab::Database::Migration[2.0] - USERS_INDEX = :index_users_on_id_for_primary_email_migration - EMAIL_INDEX = :index_emails_on_email_user_id - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :users, USERS_INDEX - remove_concurrent_index_by_name :emails, EMAIL_INDEX - end - - def down - unless index_exists_by_name?(:users, USERS_INDEX) - - disable_statement_timeout do - execute <<~SQL - CREATE INDEX CONCURRENTLY #{USERS_INDEX} - ON users (id) INCLUDE (email, confirmed_at) - WHERE confirmed_at IS NOT NULL - SQL - end - end - - add_concurrent_index :emails, [:email, :user_id], name: EMAIL_INDEX - end -end diff --git a/db/post_migrate/20220505022001_add_index_to_deployments_on_created_at_cluster_id_and_project_id.rb b/db/post_migrate/20220505022001_add_index_to_deployments_on_created_at_cluster_id_and_project_id.rb deleted file mode 100644 index c78c3a86cf3..00000000000 --- a/db/post_migrate/20220505022001_add_index_to_deployments_on_created_at_cluster_id_and_project_id.rb +++ /dev/null @@ -1,29 +0,0 @@ -# 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 diff --git a/db/post_migrate/20220505044348_fix_automatic_iterations_cadences_start_date.rb b/db/post_migrate/20220505044348_fix_automatic_iterations_cadences_start_date.rb deleted file mode 100644 index 90d70da1a28..00000000000 --- a/db/post_migrate/20220505044348_fix_automatic_iterations_cadences_start_date.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class FixAutomaticIterationsCadencesStartDate < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - execute(<<~SQL) - UPDATE iterations_cadences - SET start_date=COALESCE( - ( - SELECT start_date - FROM sprints - WHERE iterations_cadences.id=sprints.iterations_cadence_id - ORDER BY sprints.start_date ASC - LIMIT 1 - ), - start_date - ) - WHERE iterations_cadences.automatic=true; - SQL - end - - def down - # no-op - # The migration updates the records for the feature used behind a non-default feature flag. - # The correct data can be computed with the records from 'sprints' table. - end -end diff --git a/db/post_migrate/20220505053504_remove_namespaces_id_parent_id_inverse_partial_index.rb b/db/post_migrate/20220505053504_remove_namespaces_id_parent_id_inverse_partial_index.rb deleted file mode 100644 index aca3ccaa03e..00000000000 --- a/db/post_migrate/20220505053504_remove_namespaces_id_parent_id_inverse_partial_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveNamespacesIdParentIdInversePartialIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NAME = 'index_namespaces_id_parent_id_is_not_null' - - def up - remove_concurrent_index :namespaces, :id, name: NAME - end - - def down - add_concurrent_index :namespaces, :id, where: 'parent_id IS NOT NULL', name: NAME - end -end diff --git a/db/post_migrate/20220505060011_remove_namespaces_id_parent_id_partial_index.rb b/db/post_migrate/20220505060011_remove_namespaces_id_parent_id_partial_index.rb deleted file mode 100644 index 5125a97af7e..00000000000 --- a/db/post_migrate/20220505060011_remove_namespaces_id_parent_id_partial_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveNamespacesIdParentIdPartialIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NAME = 'index_namespaces_id_parent_id_is_null' - - def up - remove_concurrent_index :namespaces, :id, name: NAME - end - - def down - add_concurrent_index :namespaces, :id, where: 'parent_id IS NULL', name: NAME - end -end diff --git a/db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb b/db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb deleted file mode 100644 index 5cffdb641d6..00000000000 --- a/db/post_migrate/20220505174658_update_index_on_alerts_to_exclude_null_fingerprints.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class UpdateIndexOnAlertsToExcludeNullFingerprints < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - OLD_INDEX_NAME = 'index_partial_am_alerts_on_project_id_and_fingerprint' - NEW_INDEX_NAME = 'index_unresolved_alerts_on_project_id_and_fingerprint' - - def up - add_concurrent_index :alert_management_alerts, - [:project_id, :fingerprint], - where: "fingerprint IS NOT NULL and status <> 2", - name: NEW_INDEX_NAME, - unique: true - - remove_concurrent_index_by_name :alert_management_alerts, OLD_INDEX_NAME - end - - def down - add_concurrent_index :alert_management_alerts, - [:project_id, :fingerprint], - where: "status <> 2", - name: OLD_INDEX_NAME, - unique: true - - remove_concurrent_index_by_name :alert_management_alerts, NEW_INDEX_NAME - end -end diff --git a/db/post_migrate/20220505193512_add_not_null_constraint_to_issues_work_item_type.rb b/db/post_migrate/20220505193512_add_not_null_constraint_to_issues_work_item_type.rb deleted file mode 100644 index 3ea003383a6..00000000000 --- a/db/post_migrate/20220505193512_add_not_null_constraint_to_issues_work_item_type.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullConstraintToIssuesWorkItemType < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_not_null_constraint :issues, :work_item_type_id, validate: false - end - - def down - remove_not_null_constraint :issues, :work_item_type_id - end -end diff --git a/db/post_migrate/20220506123922_add_not_null_constraint_without_validation_to_requirements_issue_id.rb b/db/post_migrate/20220506123922_add_not_null_constraint_without_validation_to_requirements_issue_id.rb deleted file mode 100644 index 1484a96d27b..00000000000 --- a/db/post_migrate/20220506123922_add_not_null_constraint_without_validation_to_requirements_issue_id.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullConstraintWithoutValidationToRequirementsIssueId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - CONSTRAINT_NAME = 'check_requirement_issue_not_null' - - def up - add_not_null_constraint( - :requirements, - :issue_id, - constraint_name: CONSTRAINT_NAME, - validate: false - ) - end - - def down - remove_not_null_constraint :requirements, :issue_id, constraint_name: CONSTRAINT_NAME - end -end diff --git a/db/post_migrate/20220506124021_schedule_populate_requirements_issue_id.rb b/db/post_migrate/20220506124021_schedule_populate_requirements_issue_id.rb deleted file mode 100644 index 8f22324bf8d..00000000000 --- a/db/post_migrate/20220506124021_schedule_populate_requirements_issue_id.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -class SchedulePopulateRequirementsIssueId < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - # 2022-05-06 There are no requirements with nil issue_id on .com - # this migration is supposed to fix records that could have nil issue_id - # on self managed instances. - BATCH_SIZE = 100 - - MIGRATION = 'MigrateRequirementsToWorkItems' - - disable_ddl_transaction! - - class Requirement < MigrationRecord - include EachBatch - - self.table_name = 'requirements' - end - - def up - queue_background_migration_jobs_by_range_at_intervals( - Requirement.where(issue_id: nil), - MIGRATION, - 2.minutes, - batch_size: BATCH_SIZE, - track_jobs: true - ) - end - - def down - # NO OP - end -end diff --git a/db/post_migrate/20220506201639_remove_devops_adoption_security_scan_succeeded_column.rb b/db/post_migrate/20220506201639_remove_devops_adoption_security_scan_succeeded_column.rb deleted file mode 100644 index 64722919aff..00000000000 --- a/db/post_migrate/20220506201639_remove_devops_adoption_security_scan_succeeded_column.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveDevopsAdoptionSecurityScanSucceededColumn < Gitlab::Database::Migration[2.0] - def up - remove_column :analytics_devops_adoption_snapshots, :security_scan_succeeded - end - - def down - add_column :analytics_devops_adoption_snapshots, :security_scan_succeeded, :boolean - end -end diff --git a/db/post_migrate/20220510003916_remove_tmp_empty_traversal_ids_root_namespace_index.rb b/db/post_migrate/20220510003916_remove_tmp_empty_traversal_ids_root_namespace_index.rb deleted file mode 100644 index 424c6f164e7..00000000000 --- a/db/post_migrate/20220510003916_remove_tmp_empty_traversal_ids_root_namespace_index.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpEmptyTraversalIdsRootNamespaceIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - ROOT_NS_INDEX_NAME = 'tmp_index_namespaces_empty_traversal_ids_with_root_namespaces' - - def up - remove_concurrent_index :namespaces, :id, name: ROOT_NS_INDEX_NAME - end - - def down - where_sql = "parent_id IS NULL AND traversal_ids = '{}'" - add_concurrent_index :namespaces, :id, where: where_sql, name: ROOT_NS_INDEX_NAME - end -end diff --git a/db/post_migrate/20220510004501_remove_tmp_empty_traversal_ids_child_namespace_index.rb b/db/post_migrate/20220510004501_remove_tmp_empty_traversal_ids_child_namespace_index.rb deleted file mode 100644 index 804b20a38e9..00000000000 --- a/db/post_migrate/20220510004501_remove_tmp_empty_traversal_ids_child_namespace_index.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpEmptyTraversalIdsChildNamespaceIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - CHILD_INDEX_NAME = 'tmp_index_namespaces_empty_traversal_ids_with_child_namespaces' - - def up - remove_concurrent_index :namespaces, :id, name: CHILD_INDEX_NAME - end - - def down - where_sql = "parent_id IS NOT NULL AND traversal_ids = '{}'" - add_concurrent_index :namespaces, :id, where: where_sql, name: CHILD_INDEX_NAME - end -end diff --git a/db/post_migrate/20220510121338_remove_threat_monitoring_alerts.rb b/db/post_migrate/20220510121338_remove_threat_monitoring_alerts.rb deleted file mode 100644 index ff171ee516c..00000000000 --- a/db/post_migrate/20220510121338_remove_threat_monitoring_alerts.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveThreatMonitoringAlerts < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - execute("DELETE FROM alert_management_alerts WHERE domain = 1") - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220510192117_index_expirable_unknown_artifacts_for_removal.rb b/db/post_migrate/20220510192117_index_expirable_unknown_artifacts_for_removal.rb deleted file mode 100644 index 3e25ca6c7b9..00000000000 --- a/db/post_migrate/20220510192117_index_expirable_unknown_artifacts_for_removal.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class IndexExpirableUnknownArtifactsForRemoval < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = 'ci_job_artifacts' - INDEX_NAME = 'tmp_index_ci_job_artifacts_on_expire_at_where_locked_unknown' - CONDITIONS = 'locked = 2 AND expire_at IS NOT NULL' - - def up - prepare_async_index TABLE_NAME, [:expire_at, :job_id], name: INDEX_NAME, where: CONDITIONS - end - - def down - unprepare_async_index_by_name TABLE_NAME, INDEX_NAME - end -end diff --git a/db/post_migrate/20220511152439_remove_not_null_constraint_from_work_item_type.rb b/db/post_migrate/20220511152439_remove_not_null_constraint_from_work_item_type.rb deleted file mode 100644 index f56763cdafb..00000000000 --- a/db/post_migrate/20220511152439_remove_not_null_constraint_from_work_item_type.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveNotNullConstraintFromWorkItemType < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/85866 introduced a NOT NULL constraint on - # `issues` which caused QA failures (https://gitlab.com/gitlab-org/gitlab/-/issues/362023), and - # Helm database issues resulting in broken tests after restoring the database. - def up - remove_not_null_constraint :issues, :work_item_type_id, constraint_name: 'check_2addf801cd' - end - - def down - add_not_null_constraint :issues, :work_item_type_id, validate: false - end -end diff --git a/db/post_migrate/20220511212620_add_index_on_expirable_unknown_artifacts_for_removal.rb b/db/post_migrate/20220511212620_add_index_on_expirable_unknown_artifacts_for_removal.rb deleted file mode 100644 index fc9912d714e..00000000000 --- a/db/post_migrate/20220511212620_add_index_on_expirable_unknown_artifacts_for_removal.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnExpirableUnknownArtifactsForRemoval < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = 'ci_job_artifacts' - INDEX_NAME = 'tmp_index_ci_job_artifacts_on_expire_at_where_locked_unknown' - CONDITIONS = 'locked = 2 AND expire_at IS NOT NULL' - - def up - add_concurrent_index TABLE_NAME, [:expire_at, :job_id], name: INDEX_NAME, where: CONDITIONS - end - - def down - remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME - end -end diff --git a/db/post_migrate/20220512190659_remove_web_hooks_web_hook_logs_web_hook_id_fk.rb b/db/post_migrate/20220512190659_remove_web_hooks_web_hook_logs_web_hook_id_fk.rb deleted file mode 100644 index b73d3a7f102..00000000000 --- a/db/post_migrate/20220512190659_remove_web_hooks_web_hook_logs_web_hook_id_fk.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -class RemoveWebHooksWebHookLogsWebHookIdFk < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - PARENT_TABLE_NAME = :web_hook_logs - FK_NAME = "fk_rails_bb3355782d" - - def up - with_lock_retries do - execute('LOCK web_hooks, web_hook_logs IN ACCESS EXCLUSIVE MODE') if transaction_open? - - remove_foreign_key_if_exists(:web_hook_logs, :web_hooks, name: FK_NAME) - end - end - - def down - fk_attrs = { - name: FK_NAME, # Note we need the same name for every partition - column: :web_hook_id, - target_column: :id, - on_delete: :cascade - } - - # Must add child FK's first, then to the partitioned table. - child_tables.each do |tbl| - add_concurrent_foreign_key( - tbl, :web_hooks, - # This embeds the lock table statement in the with_lock_retries inside add_concurrent_foreign_key - reverse_lock_order: true, - **fk_attrs) - end - - with_lock_retries do - execute("LOCK web_hooks, #{PARENT_TABLE_NAME} IN ACCESS EXCLUSIVE MODE") if transaction_open? - add_foreign_key(:web_hook_logs, :web_hooks, **fk_attrs) - end - end - - # This table is partitioned: we need to apply the index changes to each - # partition separately. - def child_tables - @child_tables ||= execute(<<~SQL.squish).pluck("child") - SELECT inhrelid::regclass AS child - FROM pg_catalog.pg_inherits - WHERE inhparent = '#{PARENT_TABLE_NAME}'::regclass - ORDER BY inhrelid ASC - SQL - end -end diff --git a/db/post_migrate/20220513043344_reschedule_expire_o_auth_tokens.rb b/db/post_migrate/20220513043344_reschedule_expire_o_auth_tokens.rb deleted file mode 100644 index 4b24b1cf65a..00000000000 --- a/db/post_migrate/20220513043344_reschedule_expire_o_auth_tokens.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class RescheduleExpireOAuthTokens < Gitlab::Database::Migration[2.0] - MIGRATION = 'ExpireOAuthTokens' - INTERVAL = 2.minutes.freeze - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # remove the original migration from db/post_migrate/20220428133724_schedule_expire_o_auth_tokens.rb - delete_batched_background_migration(MIGRATION, :oauth_access_tokens, :id, []) - - # reschedule - queue_batched_background_migration( - MIGRATION, - :oauth_access_tokens, - :id, - job_interval: INTERVAL - ) - end - - def down - delete_batched_background_migration(MIGRATION, :oauth_access_tokens, :id, []) - end -end diff --git a/db/post_migrate/20220516054011_schedule_backfill_project_member_namespace_id.rb b/db/post_migrate/20220516054011_schedule_backfill_project_member_namespace_id.rb deleted file mode 100644 index e721fdf8c44..00000000000 --- a/db/post_migrate/20220516054011_schedule_backfill_project_member_namespace_id.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillProjectMemberNamespaceId < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'BackfillProjectMemberNamespaceId' - INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 2_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - def up - queue_batched_background_migration( - MIGRATION, - :members, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :members, :id, []) - end -end diff --git a/db/post_migrate/20220516100652_drop_compliance_management_frameworks_regulated.rb b/db/post_migrate/20220516100652_drop_compliance_management_frameworks_regulated.rb deleted file mode 100644 index f9d3405d486..00000000000 --- a/db/post_migrate/20220516100652_drop_compliance_management_frameworks_regulated.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class DropComplianceManagementFrameworksRegulated < Gitlab::Database::Migration[2.0] - def up - remove_column :compliance_management_frameworks, :regulated - end - - def down - add_column :compliance_management_frameworks, :regulated, :boolean, default: true - end -end diff --git a/db/post_migrate/20220516103353_finalize_routes_backfilling_for_projects.rb b/db/post_migrate/20220516103353_finalize_routes_backfilling_for_projects.rb deleted file mode 100644 index f65003b5da9..00000000000 --- a/db/post_migrate/20220516103353_finalize_routes_backfilling_for_projects.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class FinalizeRoutesBackfillingForProjects < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'BackfillNamespaceIdForProjectRoute' - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :routes, - column_name: :id, - job_arguments: [] - ) - end - - def down - # noop - end -end diff --git a/db/post_migrate/20220517101119_create_confidential_notes_index_synchronously.rb b/db/post_migrate/20220517101119_create_confidential_notes_index_synchronously.rb deleted file mode 100644 index 25b7fe7f7bb..00000000000 --- a/db/post_migrate/20220517101119_create_confidential_notes_index_synchronously.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CreateConfidentialNotesIndexSynchronously < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_notes_on_confidential' - - disable_ddl_transaction! - - def up - add_concurrent_index :notes, :confidential, where: 'confidential = true', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :notes, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220517133753_migrate_free_user_cap_remediation.rb b/db/post_migrate/20220517133753_migrate_free_user_cap_remediation.rb deleted file mode 100644 index 44f30134c94..00000000000 --- a/db/post_migrate/20220517133753_migrate_free_user_cap_remediation.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class MigrateFreeUserCapRemediation < Gitlab::Database::Migration[2.0] - def up - sidekiq_queue_migrate 'cronjob:namespaces_free_user_cap', to: 'cronjob:namespaces_free_user_cap_remediation' - end - - def down - sidekiq_queue_migrate 'cronjob:namespaces_free_user_cap_remediation', to: 'cronjob:namespaces_free_user_cap' - end -end diff --git a/db/post_migrate/20220517144749_remove_vulnerability_approval_rules.rb b/db/post_migrate/20220517144749_remove_vulnerability_approval_rules.rb deleted file mode 100644 index 83e3784c3aa..00000000000 --- a/db/post_migrate/20220517144749_remove_vulnerability_approval_rules.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RemoveVulnerabilityApprovalRules < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class ApprovalProjectRule < MigrationRecord - self.table_name = 'approval_project_rules' - - enum report_type: { vulnerability: 1, license_scanning: 2, code_coverage: 3, scan_finding: 4 } - end - - def up - return unless Gitlab.ee? - - ApprovalProjectRule.reset_column_information - - ApprovalProjectRule.vulnerability.delete_all - end - - def down - # no-op - # Vulnerability-Check feature has been removed as part of 15.0 - end -end diff --git a/db/post_migrate/20220518102414_add_index_to_error_tracking_client_keys.rb b/db/post_migrate/20220518102414_add_index_to_error_tracking_client_keys.rb deleted file mode 100644 index 25923bf00f6..00000000000 --- a/db/post_migrate/20220518102414_add_index_to_error_tracking_client_keys.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToErrorTrackingClientKeys < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_error_tracking_client_for_enabled_check' - - def up - add_concurrent_index( - :error_tracking_client_keys, - [:project_id, :public_key], - where: 'active = true', - name: INDEX_NAME - ) - end - - def down - remove_concurrent_index_by_name(:error_tracking_client_keys, INDEX_NAME) - end -end diff --git a/db/post_migrate/20220519045133_bulk_insert_cluster_enabled_grants.rb b/db/post_migrate/20220519045133_bulk_insert_cluster_enabled_grants.rb deleted file mode 100644 index 6c1d9058673..00000000000 --- a/db/post_migrate/20220519045133_bulk_insert_cluster_enabled_grants.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -class BulkInsertClusterEnabledGrants < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - disable_ddl_transaction! - - def up - return unless Gitlab.dev_or_test_env? || Gitlab.com? - - define_batchable_model('cluster_groups').each_batch do |batch| - min, max = batch.pick('MIN(id), MAX(id)') - - bulk_insert = <<-SQL - INSERT INTO cluster_enabled_grants (namespace_id, created_at) - SELECT DISTINCT(traversal_ids[1]), NOW() - FROM cluster_groups - INNER JOIN namespaces ON cluster_groups.group_id = namespaces.id - WHERE cluster_groups.id BETWEEN #{min} AND #{max} - ON CONFLICT (namespace_id) DO NOTHING - SQL - - connection.execute(bulk_insert) - end - - define_batchable_model('cluster_projects').each_batch do |batch| - min, max = batch.pick('MIN(id), MAX(id)') - - bulk_insert = <<-SQL - INSERT INTO cluster_enabled_grants (namespace_id, created_at) - SELECT DISTINCT(traversal_ids[1]), NOW() - FROM cluster_projects - INNER JOIN projects ON cluster_projects.project_id = projects.id - INNER JOIN namespaces on projects.namespace_id = namespaces.id - WHERE cluster_projects.id BETWEEN #{min} AND #{max} - ON CONFLICT (namespace_id) DO NOTHING - SQL - - connection.execute(bulk_insert) - end - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb b/db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb deleted file mode 100644 index a9bb09b3378..00000000000 --- a/db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class ScheduleSetLegacyOpenSourceLicenseAvailableForNonPublicProjects < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # Replaced by 20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb - end - - def down - # Replaced by 20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb - end -end diff --git a/db/post_migrate/20220523164734_add_foreign_key_to_vulnerability_reads_casted_cluster_agent_id.rb b/db/post_migrate/20220523164734_add_foreign_key_to_vulnerability_reads_casted_cluster_agent_id.rb deleted file mode 100644 index 364570973ab..00000000000 --- a/db/post_migrate/20220523164734_add_foreign_key_to_vulnerability_reads_casted_cluster_agent_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToVulnerabilityReadsCastedClusterAgentId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :vulnerability_reads, :cluster_agents, - column: :casted_cluster_agent_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key :vulnerability_reads, :cluster_agents, column: :casted_cluster_agent_id - end - end -end diff --git a/db/post_migrate/20220523165734_add_index_to_vulnerability_reads_casted_cluster_agent_id.rb b/db/post_migrate/20220523165734_add_index_to_vulnerability_reads_casted_cluster_agent_id.rb deleted file mode 100644 index 51842af3f12..00000000000 --- a/db/post_migrate/20220523165734_add_index_to_vulnerability_reads_casted_cluster_agent_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToVulnerabilityReadsCastedClusterAgentId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_cis_vulnerability_reads_on_cluster_agent_id' - - def up - add_concurrent_index :vulnerability_reads, :casted_cluster_agent_id, name: INDEX_NAME, where: 'report_type = 7' - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb b/db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb deleted file mode 100644 index 79a145bc466..00000000000 --- a/db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class DropDeployTokensTokenColumn < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - COMPOSITE_INDEX_NAME = 'index_deploy_tokens_on_token_and_expires_at_and_id' - - def up - remove_column :deploy_tokens, :token - end - - def down - unless column_exists?(:deploy_tokens, :token) - add_column :deploy_tokens, :token, :string - end - - add_concurrent_index(:deploy_tokens, :token, unique: true) - add_concurrent_index(:deploy_tokens, %i[token expires_at id], where: 'revoked IS FALSE', name: COMPOSITE_INDEX_NAME) - end -end diff --git a/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb b/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb deleted file mode 100644 index 45dbc028b18..00000000000 --- a/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class FinalizeBackfillNullNoteDiscussionIds < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillNoteDiscussionId' - BATCH_SIZE = 10_000 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - disable_ddl_transaction! - - def up - Gitlab::BackgroundMigration.steal(MIGRATION) - - define_batchable_model('notes').where(discussion_id: nil).each_batch(of: BATCH_SIZE) do |batch| - range = batch.pick('MIN(id)', 'MAX(id)') - - Gitlab::BackgroundMigration::BackfillNoteDiscussionId.new.perform(*range) - end - end - - def down - end -end diff --git a/db/post_migrate/20220524080944_cleanup_orphaned_routes.rb b/db/post_migrate/20220524080944_cleanup_orphaned_routes.rb deleted file mode 100644 index a5ce0ba4646..00000000000 --- a/db/post_migrate/20220524080944_cleanup_orphaned_routes.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class CleanupOrphanedRoutes < Gitlab::Database::Migration[2.0] - MIGRATION = 'CleanupOrphanedRoutes' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 100_000 - MAX_BATCH_SIZE = 100_000 - SUB_BATCH_SIZE = 100 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :routes, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE, - gitlab_schema: :gitlab_main - ) - end - - def down - delete_batched_background_migration(MIGRATION, :routes, :id, []) - end -end diff --git a/db/post_migrate/20220524081955_remove_notes_null_discussion_id_temp_index.rb b/db/post_migrate/20220524081955_remove_notes_null_discussion_id_temp_index.rb deleted file mode 100644 index caca7b0b092..00000000000 --- a/db/post_migrate/20220524081955_remove_notes_null_discussion_id_temp_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveNotesNullDiscussionIdTempIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_notes_on_id_where_discussion_id_is_null' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :notes, INDEX_NAME - end - - def down - add_concurrent_index :notes, :id, where: 'discussion_id IS NULL', name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220524132416_prepare_job_artifact_project_id_index.rb b/db/post_migrate/20220524132416_prepare_job_artifact_project_id_index.rb deleted file mode 100644 index 4e27e7f0624..00000000000 --- a/db/post_migrate/20220524132416_prepare_job_artifact_project_id_index.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class PrepareJobArtifactProjectIdIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_ci_job_artifacts_on_project_id_and_id' - - def up - prepare_async_index :ci_job_artifacts, [:project_id, :id], name: INDEX_NAME - end - - def down - unprepare_async_index :notes, [:project_id, :id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220524202158_drop_index_on_deployments_on_created_at_cluster_id_and_project_id.rb b/db/post_migrate/20220524202158_drop_index_on_deployments_on_created_at_cluster_id_and_project_id.rb deleted file mode 100644 index 91b1e5f8ce3..00000000000 --- a/db/post_migrate/20220524202158_drop_index_on_deployments_on_created_at_cluster_id_and_project_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnDeploymentsOnCreatedAtClusterIdAndProjectId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tp_index_created_at_cluster_id_project_id_on_deployments' - - def up - remove_concurrent_index_by_name :deployments, INDEX_NAME - end - - def down - # no-op - # - # There's no need to re-add this index as it's purpose was temporary, served only - # for a specific CR query which is now closed, and should not be re-opened. - end -end diff --git a/db/post_migrate/20220525131557_cleanup_backfill_integrations_enable_ssl_verification.rb b/db/post_migrate/20220525131557_cleanup_backfill_integrations_enable_ssl_verification.rb deleted file mode 100644 index 3bd4b21c6fd..00000000000 --- a/db/post_migrate/20220525131557_cleanup_backfill_integrations_enable_ssl_verification.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CleanupBackfillIntegrationsEnableSslVerification < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - MIGRATION = 'BackfillIntegrationsEnableSslVerification' - - def up - finalize_background_migration(MIGRATION) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220525131624_drop_temporary_index_for_backfill_integrations_enable_ssl_verification.rb b/db/post_migrate/20220525131624_drop_temporary_index_for_backfill_integrations_enable_ssl_verification.rb deleted file mode 100644 index 95abac4b7ac..00000000000 --- a/db/post_migrate/20220525131624_drop_temporary_index_for_backfill_integrations_enable_ssl_verification.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class DropTemporaryIndexForBackfillIntegrationsEnableSslVerification < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_integrations_on_id_where_type_droneci_or_teamcity' - INDEX_CONDITION = "type_new IN ('Integrations::DroneCi', 'Integrations::Teamcity') " \ - "AND encrypted_properties IS NOT NULL" - - def up - remove_concurrent_index_by_name :integrations, INDEX_NAME - end - - def down - # this index is used in 20220209121435_backfill_integrations_enable_ssl_verification - add_concurrent_index :integrations, :id, where: INDEX_CONDITION, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220525141540_migrate_project_service_worker_queue.rb b/db/post_migrate/20220525141540_migrate_project_service_worker_queue.rb deleted file mode 100644 index acfb8b227fe..00000000000 --- a/db/post_migrate/20220525141540_migrate_project_service_worker_queue.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class MigrateProjectServiceWorkerQueue < Gitlab::Database::Migration[2.0] - def up - sidekiq_queue_migrate 'project_service', to: 'integrations_execute' - end - - def down - sidekiq_queue_migrate 'integrations_execute', to: 'project_service' - end -end diff --git a/db/post_migrate/20220525165334_migrate_irker_worker_queue.rb b/db/post_migrate/20220525165334_migrate_irker_worker_queue.rb deleted file mode 100644 index 19454c007c8..00000000000 --- a/db/post_migrate/20220525165334_migrate_irker_worker_queue.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class MigrateIrkerWorkerQueue < Gitlab::Database::Migration[2.0] - def up - sidekiq_queue_migrate 'irker', to: 'integrations_irker' - end - - def down - sidekiq_queue_migrate 'integrations_irker', to: 'irker' - end -end diff --git a/db/post_migrate/20220525172001_migrate_cluster_integration_worker_queues.rb b/db/post_migrate/20220525172001_migrate_cluster_integration_worker_queues.rb deleted file mode 100644 index 4372ca9f965..00000000000 --- a/db/post_migrate/20220525172001_migrate_cluster_integration_worker_queues.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class MigrateClusterIntegrationWorkerQueues < Gitlab::Database::Migration[2.0] - def up - sidekiq_queue_migrate 'gcp_cluster:clusters_applications_activate_service', - to: 'gcp_cluster:clusters_applications_activate_integration' - sidekiq_queue_migrate 'gcp_cluster:clusters_applications_deactivate_service', - to: 'gcp_cluster:clusters_applications_deactivate_integration' - end - - def down - sidekiq_queue_migrate 'gcp_cluster:clusters_applications_activate_integration', - to: 'gcp_cluster:clusters_applications_activate_service' - sidekiq_queue_migrate 'gcp_cluster:clusters_applications_deactivate_integration', - to: 'gcp_cluster:clusters_applications_deactivate_service' - end -end diff --git a/db/post_migrate/20220525201022_add_temporary_index_for_vulnerability_reads_cluster_agent_id_migration.rb b/db/post_migrate/20220525201022_add_temporary_index_for_vulnerability_reads_cluster_agent_id_migration.rb deleted file mode 100644 index b795a41e9cd..00000000000 --- a/db/post_migrate/20220525201022_add_temporary_index_for_vulnerability_reads_cluster_agent_id_migration.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddTemporaryIndexForVulnerabilityReadsClusterAgentIdMigration < Gitlab::Database::Migration[2.0] - INDEX_VULNERABILITY_READS_NAME = 'tmp_index_cis_vulnerability_reads_on_id' - - disable_ddl_transaction! - - def up - # this index is used in 20220525221133_schedule_backfill_vulnerability_reads_cluster_agent - add_concurrent_index :vulnerability_reads, :id, name: INDEX_VULNERABILITY_READS_NAME, where: 'report_type = 7' - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_VULNERABILITY_READS_NAME - end -end diff --git a/db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb b/db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb deleted file mode 100644 index bf83781e89c..00000000000 --- a/db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillVulnerabilityReadsClusterAgent < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 1_000 - DELAY_INTERVAL = 2.minutes - MIGRATION_NAME = 'BackfillVulnerabilityReadsClusterAgent' - BATCH_CLASS_NAME = 'BackfillVulnerabilityReadsClusterAgentBatchingStrategy' - - disable_ddl_transaction! - - def up - queue_batched_background_migration( - MIGRATION_NAME, - :vulnerability_reads, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - batch_class_name: BATCH_CLASS_NAME, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION_NAME, :vulnerability_reads, :id, []) - end -end diff --git a/db/post_migrate/20220526042017_remove_geo_lfs_object_deleted_event_references.rb b/db/post_migrate/20220526042017_remove_geo_lfs_object_deleted_event_references.rb deleted file mode 100644 index 4569424dca0..00000000000 --- a/db/post_migrate/20220526042017_remove_geo_lfs_object_deleted_event_references.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RemoveGeoLfsObjectDeletedEventReferences < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_column :geo_event_log, :lfs_object_deleted_event_id, :bigint - end - end - - def down - with_lock_retries do - unless column_exists?(:geo_event_log, :lfs_object_deleted_event_id) - add_column(:geo_event_log, :lfs_object_deleted_event_id, :bigint) - end - end - - add_concurrent_foreign_key :geo_event_log, :geo_lfs_object_deleted_events, - column: :lfs_object_deleted_event_id, - name: 'fk_d5af95fcd9', - on_delete: :cascade - - add_concurrent_index :geo_event_log, - :lfs_object_deleted_event_id, - name: 'index_geo_event_log_on_lfs_object_deleted_event_id', - where: "(lfs_object_deleted_event_id IS NOT NULL)" - end -end diff --git a/db/post_migrate/20220526044516_remove_geo_lfs_object_deleted_events_table.rb b/db/post_migrate/20220526044516_remove_geo_lfs_object_deleted_events_table.rb deleted file mode 100644 index 29a2e34aefa..00000000000 --- a/db/post_migrate/20220526044516_remove_geo_lfs_object_deleted_events_table.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveGeoLfsObjectDeletedEventsTable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - drop_table :geo_lfs_object_deleted_events - end - - def down - create_table :geo_lfs_object_deleted_events, id: :bigserial do |t| - t.integer :lfs_object_id, null: false, index: true - t.string :oid, null: false - t.string :file_path, null: false - end - end -end diff --git a/db/post_migrate/20220530044712_add_index_for_vulnerability_reads_location_image.rb b/db/post_migrate/20220530044712_add_index_for_vulnerability_reads_location_image.rb deleted file mode 100644 index 384924941c1..00000000000 --- a/db/post_migrate/20220530044712_add_index_for_vulnerability_reads_location_image.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForVulnerabilityReadsLocationImage < Gitlab::Database::Migration[2.0] - INDEX = :index_vulnerability_reads_on_location_image_partial - - disable_ddl_transaction! - - REPORT_TYPES = { - container_scanning: 2, - cluster_image_scanning: 7 - } - - QUERY = <<~SQL - report_type in (#{REPORT_TYPES[:container_scanning]}, #{REPORT_TYPES[:cluster_image_scanning]}) AND - location_image IS NOT NULL - SQL - - def up - add_concurrent_index :vulnerability_reads, [:project_id, :location_image], - where: QUERY, - name: INDEX - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX - end -end diff --git a/db/post_migrate/20220530074027_add_project_id_index_to_job_artifacts.rb b/db/post_migrate/20220530074027_add_project_id_index_to_job_artifacts.rb deleted file mode 100644 index fb75f368835..00000000000 --- a/db/post_migrate/20220530074027_add_project_id_index_to_job_artifacts.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddProjectIdIndexToJobArtifacts < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_ci_job_artifacts_on_project_id_and_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_job_artifacts, [:project_id, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :ci_job_artifacts, INDEX_NAME - end -end diff --git a/db/post_migrate/20220530082653_add_traversal_id_type_group_index.rb b/db/post_migrate/20220530082653_add_traversal_id_type_group_index.rb deleted file mode 100644 index e8080bc89dc..00000000000 --- a/db/post_migrate/20220530082653_add_traversal_id_type_group_index.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddTraversalIdTypeGroupIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_namespaces_on_traversal_ids_for_groups_btree' - - disable_ddl_transaction! - - # rubocop:disable Migration/PreventIndexCreation - def up - add_concurrent_index :namespaces, :traversal_ids, using: :btree, where: "type='Group'", name: INDEX_NAME - end - # rubocop:enable Migration/PreventIndexCreation - - def down - remove_concurrent_index_by_name :namespaces, INDEX_NAME - end -end diff --git a/db/post_migrate/20220530170915_add_index_for_vulnerability_state_transition.rb b/db/post_migrate/20220530170915_add_index_for_vulnerability_state_transition.rb deleted file mode 100644 index 46ff79c2441..00000000000 --- a/db/post_migrate/20220530170915_add_index_for_vulnerability_state_transition.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForVulnerabilityStateTransition < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - NEW_INDEX_NAME = 'index_vulnerability_state_transitions_id_and_vulnerability_id' - OLD_INDEX_NAME = 'index_vulnerability_state_transitions_on_vulnerability_id' - - def up - add_concurrent_index(:vulnerability_state_transitions, [:vulnerability_id, :id], name: NEW_INDEX_NAME) - - remove_concurrent_index_by_name(:vulnerability_state_transitions, OLD_INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(:vulnerability_state_transitions, NEW_INDEX_NAME) - - add_concurrent_index(:vulnerability_state_transitions, [:vulnerability_id], name: OLD_INDEX_NAME) - end -end diff --git a/db/post_migrate/20220531024142_track_clusters_deletions.rb b/db/post_migrate/20220531024142_track_clusters_deletions.rb deleted file mode 100644 index a9c4e50f7dc..00000000000 --- a/db/post_migrate/20220531024142_track_clusters_deletions.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class TrackClustersDeletions < Gitlab::Database::Migration[2.0] - include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers - - enable_lock_retries! - - def up - track_record_deletions(:clusters) - end - - def down - untrack_record_deletions(:clusters) - end -end diff --git a/db/post_migrate/20220531024143_remove_clusters_deployments_cluster_id_fk.rb b/db/post_migrate/20220531024143_remove_clusters_deployments_cluster_id_fk.rb deleted file mode 100644 index 261a06a9b9c..00000000000 --- a/db/post_migrate/20220531024143_remove_clusters_deployments_cluster_id_fk.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RemoveClustersDeploymentsClusterIdFk < Gitlab::Database::Migration[2.0] - FK_NAME = 'fk_289bba3222' - - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists( - :deployments, - :clusters, - name: FK_NAME, - reverse_lock_order: true - ) - end - end - - def down - add_concurrent_foreign_key( - :deployments, - :clusters, - name: FK_NAME, - column: :cluster_id, - target_column: :id, - on_delete: :nullify - ) - end -end diff --git a/db/post_migrate/20220531035113_populate_operation_visibility_permissions.rb b/db/post_migrate/20220531035113_populate_operation_visibility_permissions.rb deleted file mode 100644 index 1d385b13f75..00000000000 --- a/db/post_migrate/20220531035113_populate_operation_visibility_permissions.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class PopulateOperationVisibilityPermissions < Gitlab::Database::Migration[2.0] - BATCH_SIZE = 50_000 - MAX_BATCH_SIZE = 50_000 - SUB_BATCH_SIZE = 1_000 - INTERVAL = 2.minutes - MIGRATION = 'PopulateOperationVisibilityPermissionsFromOperations' - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :project_features, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :project_features, :id, []) - end -end diff --git a/db/post_migrate/20220531233600_remove_sse_usage_data_from_redis.rb b/db/post_migrate/20220531233600_remove_sse_usage_data_from_redis.rb deleted file mode 100644 index 26ae9aed5cc..00000000000 --- a/db/post_migrate/20220531233600_remove_sse_usage_data_from_redis.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveSseUsageDataFromRedis < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - Gitlab::Redis::SharedState.with { |r| r.del("USAGE_STATIC_SITE_EDITOR_VIEWS") } - Gitlab::Redis::SharedState.with { |r| r.del("USAGE_STATIC_SITE_EDITOR_COMMITS") } - Gitlab::Redis::SharedState.with { |r| r.del("USAGE_STATIC_SITE_EDITOR_MERGE_REQUESTS") } - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220601110011_schedule_remove_self_managed_wiki_notes.rb b/db/post_migrate/20220601110011_schedule_remove_self_managed_wiki_notes.rb deleted file mode 100644 index 9e6594bb9b6..00000000000 --- a/db/post_migrate/20220601110011_schedule_remove_self_managed_wiki_notes.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class ScheduleRemoveSelfManagedWikiNotes < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'RemoveSelfManagedWikiNotes' - INTERVAL = 2.minutes - - disable_ddl_transaction! - - def up - return if skip_migration? - - queue_batched_background_migration( - MIGRATION, - :notes, - :id, - job_interval: INTERVAL, - batch_size: 10_000, - sub_batch_size: 1_000 - ) - end - - def down - return if skip_migration? - - delete_batched_background_migration(MIGRATION, :notes, :id, []) - end - - private - - def skip_migration? - Gitlab.staging? || Gitlab.com? - end -end diff --git a/db/post_migrate/20220601151900_schedule_backfill_ci_runner_semver.rb b/db/post_migrate/20220601151900_schedule_backfill_ci_runner_semver.rb deleted file mode 100644 index 9c62ec1b87b..00000000000 --- a/db/post_migrate/20220601151900_schedule_backfill_ci_runner_semver.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillCiRunnerSemver < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - MIGRATION = 'BackfillCiRunnerSemver' - INTERVAL = 2.minutes.freeze - BATCH_SIZE = 500 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 100 - - disable_ddl_transaction! - - def up - # Disabled background migration introduced in same milestone as it was decided to change approach - # and the semver column will no longer be needed - # queue_batched_background_migration( - # MIGRATION, - # :ci_runners, - # :id, - # job_interval: INTERVAL, - # batch_size: BATCH_SIZE, - # max_batch_size: MAX_BATCH_SIZE, - # sub_batch_size: SUB_BATCH_SIZE - # ) - end - - def down - delete_batched_background_migration(MIGRATION, :ci_runners, :id, []) - end -end diff --git a/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb b/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb deleted file mode 100644 index aa860959c20..00000000000 --- a/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddUserIdAndIpAddressSuccessIndexToAuthenticationEvents < Gitlab::Database::Migration[2.0] - OLD_INDEX_NAME = 'index_authentication_events_on_user_id' - NEW_INDEX_NAME = 'index_authentication_events_on_user_and_ip_address_and_result' - - disable_ddl_transaction! - - def up - add_concurrent_index :authentication_events, [:user_id, :ip_address, :result], name: NEW_INDEX_NAME - remove_concurrent_index_by_name :authentication_events, OLD_INDEX_NAME - end - - def down - add_concurrent_index :authentication_events, :user_id, name: OLD_INDEX_NAME - remove_concurrent_index_by_name :authentication_events, NEW_INDEX_NAME - end -end diff --git a/db/post_migrate/20220602070502_queue_backfill_project_feature_package_registry_access_level.rb b/db/post_migrate/20220602070502_queue_backfill_project_feature_package_registry_access_level.rb deleted file mode 100644 index 2c772a79327..00000000000 --- a/db/post_migrate/20220602070502_queue_backfill_project_feature_package_registry_access_level.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class QueueBackfillProjectFeaturePackageRegistryAccessLevel < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - MIGRATION = 'BackfillProjectFeaturePackageRegistryAccessLevel' - DELAY_INTERVAL = 2.minutes - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: DELAY_INTERVAL - ) - end - - def down - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20220602111923_prepare_index_for_open_issues_count.rb b/db/post_migrate/20220602111923_prepare_index_for_open_issues_count.rb deleted file mode 100644 index e90524df1ba..00000000000 --- a/db/post_migrate/20220602111923_prepare_index_for_open_issues_count.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class PrepareIndexForOpenIssuesCount < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'idx_open_issues_on_project_id_and_confidential' - - def up - prepare_async_index :issues, [:project_id, :confidential], where: 'state_id = 1', name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb b/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb deleted file mode 100644 index 8f10fd61273..00000000000 --- a/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class UpdateVulnerabilitiesProjectIdIdIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'idx_vulnerabilities_partial_devops_adoption_and_default_branch' - OLD_INDEX_NAME = 'idx_vulnerabilities_partial_devops_adoption' - - def up - add_concurrent_index :vulnerabilities, [:project_id, :created_at, :present_on_default_branch], - where: 'state != 1', - name: NEW_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME) - end - - def down - add_concurrent_index :vulnerabilities, [:project_id, :created_at], where: 'state != 1', name: OLD_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME) - end -end diff --git a/db/post_migrate/20220606054503_add_tmp_index_job_artifacts_id_and_expire_at.rb b/db/post_migrate/20220606054503_add_tmp_index_job_artifacts_id_and_expire_at.rb deleted file mode 100644 index 28346eb1a97..00000000000 --- a/db/post_migrate/20220606054503_add_tmp_index_job_artifacts_id_and_expire_at.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexJobArtifactsIdAndExpireAt < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_expire_at_file_type_trace' - - EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE = <<~SQL - (EXTRACT(day FROM timezone('UTC', expire_at)) IN (21, 22, 23) - AND EXTRACT(minute FROM timezone('UTC', expire_at)) IN (0, 30, 45) - AND EXTRACT(second FROM timezone('UTC', expire_at)) = 0) - OR file_type = 3 - SQL - - def up - return if Gitlab.com? - return if index_exists_by_name?(:ci_job_artifacts, INDEX_NAME) - - add_concurrent_index :ci_job_artifacts, :id, - where: EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE, name: INDEX_NAME - end - - def down - return if Gitlab.com? - return unless index_exists_by_name?(:ci_job_artifacts, INDEX_NAME) - - remove_concurrent_index_by_name :ci_job_artifacts, INDEX_NAME - end -end diff --git a/db/post_migrate/20220606060825_set_on_delete_cascade_on_namespace_id_on_routes_table.rb b/db/post_migrate/20220606060825_set_on_delete_cascade_on_namespace_id_on_routes_table.rb deleted file mode 100644 index 74660d1474c..00000000000 --- a/db/post_migrate/20220606060825_set_on_delete_cascade_on_namespace_id_on_routes_table.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -class SetOnDeleteCascadeOnNamespaceIdOnRoutesTable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TARGET_COLUMN = :namespace_id - - def up - # add the new FK before removing the old one - add_concurrent_foreign_key( - :routes, - :namespaces, - column: TARGET_COLUMN, - name: fk_name("#{TARGET_COLUMN}_new"), - on_delete: :cascade - ) - - with_lock_retries do - remove_foreign_key_if_exists(:routes, column: TARGET_COLUMN, name: fk_name(TARGET_COLUMN)) - end - end - - def down - add_concurrent_foreign_key( - :routes, - :namespaces, - column: TARGET_COLUMN, - name: fk_name(TARGET_COLUMN), - on_delete: :nullify - ) - - with_lock_retries do - remove_foreign_key_if_exists(:routes, column: TARGET_COLUMN, name: fk_name("#{TARGET_COLUMN}_new")) - end - end - - def fk_name(column_name) - # generate a FK name - concurrent_foreign_key_name(:routes, column_name) - end -end diff --git a/db/post_migrate/20220606060850_add_not_null_constraint_on_routes_namespace_id.rb b/db/post_migrate/20220606060850_add_not_null_constraint_on_routes_namespace_id.rb deleted file mode 100644 index 4c9f087f62d..00000000000 --- a/db/post_migrate/20220606060850_add_not_null_constraint_on_routes_namespace_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullConstraintOnRoutesNamespaceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_not_null_constraint :routes, :namespace_id, validate: false - end - - def down - remove_not_null_constraint :routes, :namespace_id - end -end diff --git a/db/post_migrate/20220606080509_fix_incorrect_job_artifacts_expire_at.rb b/db/post_migrate/20220606080509_fix_incorrect_job_artifacts_expire_at.rb deleted file mode 100644 index 8fea22f5579..00000000000 --- a/db/post_migrate/20220606080509_fix_incorrect_job_artifacts_expire_at.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class FixIncorrectJobArtifactsExpireAt < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - MIGRATION = 'RemoveBackfilledJobArtifactsExpireAt' - BATCH_CLASS = 'RemoveBackfilledJobArtifactsExpireAtBatchingStrategy' - BATCH_SIZE = 500 - INTERVAL = 2.minutes.freeze - - def up - return if Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - :ci_job_artifacts, - :id, - job_interval: INTERVAL, - batch_class_name: BATCH_CLASS, - batch_size: BATCH_SIZE - ) - end - - def down - return if Gitlab.com? - - delete_batched_background_migration(MIGRATION, :ci_job_artifacts, :id, []) - end -end diff --git a/db/post_migrate/20220606082910_add_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb b/db/post_migrate/20220606082910_add_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb deleted file mode 100644 index 1207b51f190..00000000000 --- a/db/post_migrate/20220606082910_add_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_vulnerability_occurrences_on_id_and_scanner_id" - REPORT_TYPES = { cluster_image_scanning: 7, generic: 99 }.freeze - CLAUSE = "report_type IN (#{REPORT_TYPES.values.join(',')})" - - disable_ddl_transaction! - - def up - prepare_async_index :vulnerability_occurrences, - [:id, :scanner_id], - where: CLAUSE, - name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :vulnerability_occurrences, INDEX_NAME - end -end diff --git a/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb b/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb deleted file mode 100644 index fe4ffbf6cc3..00000000000 --- a/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddSyncTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_vulnerability_occurrences_on_id_and_scanner_id" - REPORT_TYPES = { cluster_image_scanning: 7, generic: 99 }.freeze - CLAUSE = "report_type IN (#{REPORT_TYPES.values.join(',')})" - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerability_occurrences, - [:id, :scanner_id], - where: CLAUSE, - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME - end -end diff --git a/db/post_migrate/20220607140222_remove_invalid_integrations.rb b/db/post_migrate/20220607140222_remove_invalid_integrations.rb deleted file mode 100644 index 49834d7b120..00000000000 --- a/db/post_migrate/20220607140222_remove_invalid_integrations.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class RemoveInvalidIntegrations < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 100 - - def up - loop do - deleted = Integration.where(type_new: nil).limit(BATCH_SIZE).delete_all - - break if deleted < BATCH_SIZE - end - end - - # Isolated version of the Integration model - class Integration < MigrationRecord - self.table_name = 'integrations' - self.inheritance_column = :_type_disabled - end -end diff --git a/db/post_migrate/20220609195803_remove_deployment_clusters_cluster_id_fk.rb b/db/post_migrate/20220609195803_remove_deployment_clusters_cluster_id_fk.rb deleted file mode 100644 index 2d81816fcfd..00000000000 --- a/db/post_migrate/20220609195803_remove_deployment_clusters_cluster_id_fk.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RemoveDeploymentClustersClusterIdFk < Gitlab::Database::Migration[2.0] - FK_NAME = 'fk_rails_4e6243e120' - - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists( - :deployment_clusters, - :clusters, - name: FK_NAME, - reverse_lock_order: true - ) - end - end - - def down - add_concurrent_foreign_key( - :deployment_clusters, - :clusters, - name: FK_NAME, - column: :cluster_id, - target_column: :id, - on_delete: :cascade - ) - end -end diff --git a/db/post_migrate/20220610223040_add_index_on_available_pypi_packages.rb b/db/post_migrate/20220610223040_add_index_on_available_pypi_packages.rb deleted file mode 100644 index 891272c8a51..00000000000 --- a/db/post_migrate/20220610223040_add_index_on_available_pypi_packages.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnAvailablePypiPackages < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_packages_on_available_pypi_packages' - - def up - add_concurrent_index :packages_packages, - [:project_id, :id], - where: "status IN (0,1) AND package_type = 5 AND version IS NOT NULL", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_packages, INDEX_NAME - end -end diff --git a/db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb b/db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb deleted file mode 100644 index 80c26c3ea8a..00000000000 --- a/db/post_migrate/20220613095911_create_confidential_notes_index_on_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class CreateConfidentialNotesIndexOnId < Gitlab::Database::Migration[2.0] - OLD_INDEX_NAME = 'index_notes_on_confidential' - INDEX_NAME = 'index_notes_on_id_where_confidential' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :notes, name: OLD_INDEX_NAME - add_concurrent_index :notes, :id, where: 'confidential = true', name: INDEX_NAME - end - - def down - # we don't have to re-create OLD_INDEX_NAME index - # because it wasn't used yet, also its creation might be expensive - remove_concurrent_index_by_name :notes, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220614185644_update_index_vulnerabilities_project_id_id.rb b/db/post_migrate/20220614185644_update_index_vulnerabilities_project_id_id.rb deleted file mode 100644 index 142cac09a01..00000000000 --- a/db/post_migrate/20220614185644_update_index_vulnerabilities_project_id_id.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class UpdateIndexVulnerabilitiesProjectIdId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'index_vulnerabilities_project_id_and_id_on_default_branch' - OLD_INDEX_NAME = 'index_vulnerabilities_on_project_id_and_id' - - def up - add_concurrent_index :vulnerabilities, [:project_id, :id], - where: 'present_on_default_branch IS TRUE', - name: NEW_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME) - end - - def down - add_concurrent_index :vulnerabilities, [:project_id, :id], name: OLD_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME) - end -end diff --git a/db/post_migrate/20220615154500_schedule_backfill_cluster_agents_has_vulnerabilities.rb b/db/post_migrate/20220615154500_schedule_backfill_cluster_agents_has_vulnerabilities.rb deleted file mode 100644 index 74aeb2947a9..00000000000 --- a/db/post_migrate/20220615154500_schedule_backfill_cluster_agents_has_vulnerabilities.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillClusterAgentsHasVulnerabilities < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - MIGRATION = 'BackfillClusterAgentsHasVulnerabilities' - DELAY_INTERVAL = 2.minutes - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - ensure_batched_background_migration_is_finished( - job_class_name: 'BackfillVulnerabilityReadsClusterAgent', - table_name: :vulnerability_reads, - column_name: :id, - job_arguments: [] - ) - - queue_batched_background_migration( - MIGRATION, - :cluster_agents, - :id, - job_interval: DELAY_INTERVAL - ) - end - - def down - delete_batched_background_migration(MIGRATION, :cluster_agents, :id, []) - end -end diff --git a/db/post_migrate/20220616092541_prepare_index_issues_on_project_id_and_closed_at.rb b/db/post_migrate/20220616092541_prepare_index_issues_on_project_id_and_closed_at.rb deleted file mode 100644 index 084cdb6166d..00000000000 --- a/db/post_migrate/20220616092541_prepare_index_issues_on_project_id_and_closed_at.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class PrepareIndexIssuesOnProjectIdAndClosedAt < Gitlab::Database::Migration[2.0] - NEW_INDEX_NAME_1 = 'index_issues_on_project_id_closed_at_desc_state_id_and_id' - NEW_INDEX_NAME_2 = 'index_issues_on_project_id_closed_at_state_id_and_id' - - def up - # Index to improve performance when sorting issues by closed_at desc - prepare_async_index :issues, 'project_id, closed_at DESC NULLS LAST, state_id, id', name: NEW_INDEX_NAME_1 - - # Index to improve performance when sorting issues by closed_at asc - # This replaces the old index which didn't account for state_id and id - prepare_async_index :issues, [:project_id, :closed_at, :state_id, :id], name: NEW_INDEX_NAME_2 - end - - def down - unprepare_async_index_by_name :issues, NEW_INDEX_NAME_1 - unprepare_async_index_by_name :issues, NEW_INDEX_NAME_2 - end -end diff --git a/db/post_migrate/20220616171355_update_vulnerabilities_project_id_id_active_cis_index.rb b/db/post_migrate/20220616171355_update_vulnerabilities_project_id_id_active_cis_index.rb deleted file mode 100644 index 047ae0d1132..00000000000 --- a/db/post_migrate/20220616171355_update_vulnerabilities_project_id_id_active_cis_index.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class UpdateVulnerabilitiesProjectIdIdActiveCisIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'idx_vulnerabilities_on_project_id_and_id_active_cis_dft_branch' - OLD_INDEX_NAME = 'index_vulnerabilities_on_project_id_and_id_active_cis' - OLD_INDEX_FILTER_CONDITION = 'report_type = 7 AND state = ANY(ARRAY[1, 4])' - NEW_INDEX_FILTER_CONDITION = 'report_type = 7 AND state = ANY(ARRAY[1, 4]) AND present_on_default_branch IS TRUE' - - def up - add_concurrent_index :vulnerabilities, [:project_id, :id], - where: NEW_INDEX_FILTER_CONDITION, - name: NEW_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME) - end - - def down - add_concurrent_index :vulnerabilities, [:project_id, :id], where: OLD_INDEX_FILTER_CONDITION, name: OLD_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME) - end -end diff --git a/db/post_migrate/20220616222253_remove_ci_secure_files_permissions_column.rb b/db/post_migrate/20220616222253_remove_ci_secure_files_permissions_column.rb deleted file mode 100644 index 31c559a9d44..00000000000 --- a/db/post_migrate/20220616222253_remove_ci_secure_files_permissions_column.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveCiSecureFilesPermissionsColumn < Gitlab::Database::Migration[2.0] - def up - remove_column :ci_secure_files, :permissions - end - - def down - add_column :ci_secure_files, :permissions, :integer, null: false, default: 0, limit: 2 - end -end diff --git a/db/post_migrate/20220617073407_add_index_for_open_issues_count.rb b/db/post_migrate/20220617073407_add_index_for_open_issues_count.rb deleted file mode 100644 index 5c11e7b1b9a..00000000000 --- a/db/post_migrate/20220617073407_add_index_for_open_issues_count.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForOpenIssuesCount < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'idx_open_issues_on_project_id_and_confidential' - - def up - add_concurrent_index :issues, [:project_id, :confidential], where: 'state_id = 1', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20220617123022_add_unique_index_on_projects_on_runners_token.rb b/db/post_migrate/20220617123022_add_unique_index_on_projects_on_runners_token.rb deleted file mode 100644 index abd730685d7..00000000000 --- a/db/post_migrate/20220617123022_add_unique_index_on_projects_on_runners_token.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexOnProjectsOnRunnersToken < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_uniq_projects_on_runners_token' - - def up - # rubocop:disable Migration/PreventIndexCreation - add_concurrent_index :projects, - :runners_token, - name: INDEX_NAME, - unique: true - # rubocop:enable Migration/PreventIndexCreation - end - - def down - remove_concurrent_index_by_name :projects, INDEX_NAME - end -end diff --git a/db/post_migrate/20220617123034_add_unique_index_on_projects_on_runners_token_encrypted.rb b/db/post_migrate/20220617123034_add_unique_index_on_projects_on_runners_token_encrypted.rb deleted file mode 100644 index 51b630397dc..00000000000 --- a/db/post_migrate/20220617123034_add_unique_index_on_projects_on_runners_token_encrypted.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexOnProjectsOnRunnersTokenEncrypted < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_uniq_projects_on_runners_token_encrypted' - - def up - # rubocop:disable Migration/PreventIndexCreation - add_concurrent_index :projects, - :runners_token_encrypted, - name: INDEX_NAME, - unique: true - # rubocop:enable Migration/PreventIndexCreation - end - - def down - remove_concurrent_index_by_name :projects, INDEX_NAME - end -end diff --git a/db/post_migrate/20220617123105_drop_index_on_projects_on_runners_token.rb b/db/post_migrate/20220617123105_drop_index_on_projects_on_runners_token.rb deleted file mode 100644 index 6b76a92a9f4..00000000000 --- a/db/post_migrate/20220617123105_drop_index_on_projects_on_runners_token.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnProjectsOnRunnersToken < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_projects_on_runners_token' - - def up - remove_concurrent_index_by_name :projects, INDEX_NAME - end - - def down - add_concurrent_index :projects, - :runners_token, - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220617123113_drop_index_on_projects_on_runners_token_encrypted.rb b/db/post_migrate/20220617123113_drop_index_on_projects_on_runners_token_encrypted.rb deleted file mode 100644 index 213f55bfcc4..00000000000 --- a/db/post_migrate/20220617123113_drop_index_on_projects_on_runners_token_encrypted.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnProjectsOnRunnersTokenEncrypted < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_projects_on_runners_token_encrypted' - - def up - remove_concurrent_index_by_name :projects, INDEX_NAME - end - - def down - add_concurrent_index :projects, - :runners_token_encrypted, - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb b/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb deleted file mode 100644 index e74c6c0935e..00000000000 --- a/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnInstallablePackageFiles < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'idx_pkgs_installable_package_files_on_package_id_id_file_name' - # See https://gitlab.com/gitlab-org/gitlab/-/blob/e3ed2c1f65df2e137fc714485d7d42264a137968/app/models/packages/package_file.rb#L16 - DEFAULT_STATUS = 0 - - def up - add_concurrent_index :packages_package_files, - [:package_id, :id, :file_name], - where: "(status = #{DEFAULT_STATUS})", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_package_files, INDEX_NAME - end -end diff --git a/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb b/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb deleted file mode 100644 index d1e70f04468..00000000000 --- a/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class ReplacePackagesIndexOnProjectIdAndStatus < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'index_packages_packages_on_project_id_and_status_and_id' - OLD_INDEX_NAME = 'index_packages_packages_on_project_id_and_status' - - def up - add_concurrent_index :packages_packages, - [:project_id, :status, :id], - name: NEW_INDEX_NAME - remove_concurrent_index_by_name :packages_packages, OLD_INDEX_NAME - end - - def down - add_concurrent_index :packages_packages, - [:project_id, :status], - name: OLD_INDEX_NAME - remove_concurrent_index_by_name :packages_packages, NEW_INDEX_NAME - end -end diff --git a/db/post_migrate/20220620060633_finalize_orphaned_routes_cleanup.rb b/db/post_migrate/20220620060633_finalize_orphaned_routes_cleanup.rb deleted file mode 100644 index 4a3218af2c0..00000000000 --- a/db/post_migrate/20220620060633_finalize_orphaned_routes_cleanup.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class FinalizeOrphanedRoutesCleanup < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'CleanupOrphanedRoutes' - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :routes, - column_name: :id, - job_arguments: [] - ) - end - - def down - # noop - end -end diff --git a/db/post_migrate/20220620132300_update_last_run_date_for_iterations_cadences.rb b/db/post_migrate/20220620132300_update_last_run_date_for_iterations_cadences.rb deleted file mode 100644 index 50b0b25d469..00000000000 --- a/db/post_migrate/20220620132300_update_last_run_date_for_iterations_cadences.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class UpdateLastRunDateForIterationsCadences < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - execute <<~SQL - UPDATE iterations_cadences SET last_run_date=CURRENT_DATE WHERE automatic=true; - SQL - end - - def down - # no op - # 'last_run_date' stores the date on which the cadence record should be - # updated using `CreateIterationsInAdvance` service that is idempotent - # and the column is only useful for optimizing when to run the service - # ('last_run_date' is also a misnomer as it can be better-named 'next_run_date'.) - end -end diff --git a/db/post_migrate/20220620151740_add_indexes_issues_on_project_id_and_closed_at.rb b/db/post_migrate/20220620151740_add_indexes_issues_on_project_id_and_closed_at.rb deleted file mode 100644 index 066e72dce45..00000000000 --- a/db/post_migrate/20220620151740_add_indexes_issues_on_project_id_and_closed_at.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class AddIndexesIssuesOnProjectIdAndClosedAt < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - OLD_INDEX_NAME = 'index_issues_on_project_id_and_closed_at' - NEW_INDEX_NAME_1 = 'index_issues_on_project_id_closed_at_desc_state_id_and_id' - NEW_INDEX_NAME_2 = 'index_issues_on_project_id_closed_at_state_id_and_id' - - def up - # Index to improve performance when sorting issues by closed_at desc - unless index_exists_by_name?(:issues, NEW_INDEX_NAME_1) - add_concurrent_index :issues, 'project_id, closed_at DESC NULLS LAST, state_id, id', name: NEW_INDEX_NAME_1 - end - - # Index to improve performance when sorting issues by closed_at asc - # This replaces the old index which didn't account for state_id and id - unless index_exists_by_name?(:issues, NEW_INDEX_NAME_2) - add_concurrent_index :issues, [:project_id, :closed_at, :state_id, :id], name: NEW_INDEX_NAME_2 - end - - remove_concurrent_index_by_name :issues, OLD_INDEX_NAME - end - - def down - add_concurrent_index :issues, [:project_id, :closed_at], name: OLD_INDEX_NAME - - remove_concurrent_index_by_name :issues, NEW_INDEX_NAME_1 - remove_concurrent_index_by_name :issues, NEW_INDEX_NAME_2 - end -end diff --git a/db/post_migrate/20220621040800_backfill_imported_issue_search_data.rb b/db/post_migrate/20220621040800_backfill_imported_issue_search_data.rb deleted file mode 100644 index bc7d0eb3a13..00000000000 --- a/db/post_migrate/20220621040800_backfill_imported_issue_search_data.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class BackfillImportedIssueSearchData < Gitlab::Database::Migration[2.0] - def up - # replaced by 20220707075300_reschedule_backfill_imported_issue_search_data.rb - end - - def down - # replaced by 20220707075300_reschedule_backfill_imported_issue_search_data.rb - end -end diff --git a/db/post_migrate/20220621082245_remove_tmp_index_on_routes_namespace_id_column.rb b/db/post_migrate/20220621082245_remove_tmp_index_on_routes_namespace_id_column.rb deleted file mode 100644 index 4aa125d3c14..00000000000 --- a/db/post_migrate/20220621082245_remove_tmp_index_on_routes_namespace_id_column.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIndexOnRoutesNamespaceIdColumn < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_for_namespace_id_migration_on_routes' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :routes, INDEX_NAME - end - - def down - add_concurrent_index :routes, - :id, - where: "routes.namespace_id is null and routes.source_type = 'Namespace'", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220621092245_validate_not_null_constraint_on_routes_namespace_id_column.rb b/db/post_migrate/20220621092245_validate_not_null_constraint_on_routes_namespace_id_column.rb deleted file mode 100644 index 73e2f6b2b38..00000000000 --- a/db/post_migrate/20220621092245_validate_not_null_constraint_on_routes_namespace_id_column.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class ValidateNotNullConstraintOnRoutesNamespaceIdColumn < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - validate_not_null_constraint :routes, :namespace_id - end - - def down - remove_not_null_constraint :routes, :namespace_id - add_not_null_constraint :routes, :namespace_id, validate: false - end -end diff --git a/db/post_migrate/20220621192541_add_project_id_state_severity_default_branch_index_for_vulnerabilities.rb b/db/post_migrate/20220621192541_add_project_id_state_severity_default_branch_index_for_vulnerabilities.rb deleted file mode 100644 index 76753cdd737..00000000000 --- a/db/post_migrate/20220621192541_add_project_id_state_severity_default_branch_index_for_vulnerabilities.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddProjectIdStateSeverityDefaultBranchIndexForVulnerabilities < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_vulnerabilities_project_id_state_severity_default_branch' - - def up - add_concurrent_index :vulnerabilities, [:project_id, :state, :severity, :present_on_default_branch], - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME - end -end diff --git a/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb b/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb deleted file mode 100644 index 1533c502b3d..00000000000 --- a/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddTempIndexForContainerRegistrySizeMigration < Gitlab::Database::Migration[2.0] - INDEX_CONTAINER_REGISTRY_SIZE = 'tmp_index_migrated_container_registries' - INDEX_PROJECT_STATS_CONT_REG_SIZE = 'tmp_index_project_statistics_cont_registry_size' - - disable_ddl_transaction! - - def up - # Temporary index used in 20220622080547_backfill_project_statistics_with_container_registry_size - # Temporary index to be remove via https://gitlab.com/gitlab-org/gitlab/-/issues/366392 - add_concurrent_index :container_repositories, [:project_id], - name: INDEX_CONTAINER_REGISTRY_SIZE, - where: "migration_state = 'import_done' OR created_at >= '2022-01-23'" - add_concurrent_index :project_statistics, [:project_id], - name: INDEX_PROJECT_STATS_CONT_REG_SIZE, - where: "container_registry_size = 0" - end - - def down - remove_concurrent_index_by_name :container_repositories, INDEX_CONTAINER_REGISTRY_SIZE - remove_concurrent_index_by_name :project_statistics, INDEX_PROJECT_STATS_CONT_REG_SIZE - end -end diff --git a/db/post_migrate/20220622080547_backfill_project_statistics_with_container_registry_size.rb b/db/post_migrate/20220622080547_backfill_project_statistics_with_container_registry_size.rb deleted file mode 100644 index 2cab7ae25f5..00000000000 --- a/db/post_migrate/20220622080547_backfill_project_statistics_with_container_registry_size.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class BackfillProjectStatisticsWithContainerRegistrySize < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 500 - MIGRATION_CLASS = 'BackfillProjectStatisticsContainerRepositorySize' - BATCH_CLASS_NAME = 'BackfillProjectStatisticsWithContainerRegistrySizeBatchingStrategy' - SUB_BATCH_SIZE = 100 - - disable_ddl_transaction! - - def up - return unless Gitlab.dev_or_test_env? || Gitlab.com? - - queue_batched_background_migration( - MIGRATION_CLASS, - :container_repositories, - :project_id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - batch_class_name: BATCH_CLASS_NAME, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.dev_or_test_env? || Gitlab.com? - - delete_batched_background_migration(MIGRATION_CLASS, :container_repositories, :project_id, []) - end -end diff --git a/db/post_migrate/20220624062300_delete_backfill_ci_runner_semver_migration.rb b/db/post_migrate/20220624062300_delete_backfill_ci_runner_semver_migration.rb deleted file mode 100644 index 4632d9104ea..00000000000 --- a/db/post_migrate/20220624062300_delete_backfill_ci_runner_semver_migration.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class DeleteBackfillCiRunnerSemverMigration < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - MIGRATION = 'BackfillCiRunnerSemver' - - disable_ddl_transaction! - - def up - # Disabled background migration introduced in same milestone as it was decided to change approach - # and the semver column will no longer be needed - delete_batched_background_migration(MIGRATION, :ci_runners, :id, []) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220627090231_schedule_disable_legacy_open_source_license_for_inactive_public_projects.rb b/db/post_migrate/20220627090231_schedule_disable_legacy_open_source_license_for_inactive_public_projects.rb deleted file mode 100644 index 06bdb78698d..00000000000 --- a/db/post_migrate/20220627090231_schedule_disable_legacy_open_source_license_for_inactive_public_projects.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDisableLegacyOpenSourceLicenseForInactivePublicProjects < Gitlab::Database::Migration[2.0] - MIGRATION = 'DisableLegacyOpenSourceLicenseForInactivePublicProjects' - INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 5_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20220627152642_queue_update_delayed_project_removal_to_null_for_user_namespace.rb b/db/post_migrate/20220627152642_queue_update_delayed_project_removal_to_null_for_user_namespace.rb deleted file mode 100644 index 2f407b78b6d..00000000000 --- a/db/post_migrate/20220627152642_queue_update_delayed_project_removal_to_null_for_user_namespace.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class QueueUpdateDelayedProjectRemovalToNullForUserNamespace < Gitlab::Database::Migration[2.0] - MIGRATION = 'UpdateDelayedProjectRemovalToNullForUserNamespaces' - INTERVAL = 2.minutes - BATCH_SIZE = 10_000 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :namespace_settings, - :namespace_id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :namespace_settings, :namespace_id, []) - end -end diff --git a/db/post_migrate/20220627223041_add_post_migrate_test_table.rb b/db/post_migrate/20220627223041_add_post_migrate_test_table.rb deleted file mode 100644 index 8d97444f8c1..00000000000 --- a/db/post_migrate/20220627223041_add_post_migrate_test_table.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddPostMigrateTestTable < Gitlab::Database::Migration[2.0] - # Fake table to be used for testing the post-deploy pipeline, - # details can be seen on https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/2352. - # - # It should be deleted after the testing is completed. - def change - create_table :post_migration_test_table do |t| - t.integer :status, null: false - end - end -end diff --git a/db/post_migrate/20220628110823_add_issues_namespace_id_fk_and_index.rb b/db/post_migrate/20220628110823_add_issues_namespace_id_fk_and_index.rb deleted file mode 100644 index 5a7ca428383..00000000000 --- a/db/post_migrate/20220628110823_add_issues_namespace_id_fk_and_index.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddIssuesNamespaceIdFkAndIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - INDEX_NAME = 'index_issues_on_namespace_id' - - def up - add_concurrent_index :issues, :namespace_id, name: INDEX_NAME - add_concurrent_foreign_key :issues, :namespaces, - column: :namespace_id, - on_delete: :nullify, - reverse_lock_order: true - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :issues, column: :namespace_id - end - - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20220628111752_drop_token_index_from_ci_builds.rb b/db/post_migrate/20220628111752_drop_token_index_from_ci_builds.rb deleted file mode 100644 index d551eeebeb6..00000000000 --- a/db/post_migrate/20220628111752_drop_token_index_from_ci_builds.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropTokenIndexFromCiBuilds < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_builds_on_token_partial' - - def up - remove_concurrent_index_by_name :ci_builds, INDEX_NAME - end - - # rubocop:disable Migration/PreventIndexCreation - def down - add_concurrent_index :ci_builds, :token, unique: true, where: 'token IS NOT NULL', name: INDEX_NAME - end - # rubocop:enable Migration/PreventIndexCreation -end diff --git a/db/post_migrate/20220628122622_rename_builds_sidekiq_queues_to_namespaces.rb b/db/post_migrate/20220628122622_rename_builds_sidekiq_queues_to_namespaces.rb deleted file mode 100644 index f692d1476ce..00000000000 --- a/db/post_migrate/20220628122622_rename_builds_sidekiq_queues_to_namespaces.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class RenameBuildsSidekiqQueuesToNamespaces < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - BUILD_OLD_QUEUE = 'pipeline_processing:build_finished' - BUILD_NEW_QUEUE = 'pipeline_processing:ci_build_finished' - - TRACE_OLD_QUEUE = 'pipeline_background:archive_trace' - TRACE_NEW_QUEUE = 'pipeline_background:ci_archive_trace' - - def up - sidekiq_queue_migrate BUILD_OLD_QUEUE, to: BUILD_NEW_QUEUE - sidekiq_queue_migrate TRACE_OLD_QUEUE, to: TRACE_NEW_QUEUE - end - - def down - sidekiq_queue_migrate BUILD_NEW_QUEUE, to: BUILD_OLD_QUEUE - sidekiq_queue_migrate TRACE_NEW_QUEUE, to: TRACE_OLD_QUEUE - end -end diff --git a/db/post_migrate/20220629124942_remove_vulnerability_occurrences_migrated_to_new_structure_column.rb b/db/post_migrate/20220629124942_remove_vulnerability_occurrences_migrated_to_new_structure_column.rb deleted file mode 100644 index 2a980290cc9..00000000000 --- a/db/post_migrate/20220629124942_remove_vulnerability_occurrences_migrated_to_new_structure_column.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveVulnerabilityOccurrencesMigratedToNewStructureColumn < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_vulnerability_occurrences_on_migrated_to_new_structure' - - def up - with_lock_retries do - remove_column :vulnerability_occurrences, :migrated_to_new_structure - end - end - - def down - unless column_exists?(:vulnerability_occurrences, :migrated_to_new_structure) - add_column :vulnerability_occurrences, :migrated_to_new_structure, :boolean, default: false, null: false - end - - add_concurrent_index :vulnerability_occurrences, [:migrated_to_new_structure, :id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb b/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb deleted file mode 100644 index 89adc4b2703..00000000000 --- a/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -class UnsetEscalationPoliciesForAlertIncidents < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class EscalationStatus < MigrationRecord - include EachBatch - - self.table_name = 'incident_management_issuable_escalation_statuses' - - scope :having_alert_policy, -> do - joins( - 'INNER JOIN alert_management_alerts ' \ - 'ON alert_management_alerts.issue_id ' \ - '= incident_management_issuable_escalation_statuses.issue_id' - ) - end - end - - def up - EscalationStatus.each_batch do |escalation_statuses| - escalation_statuses - .where.not(policy_id: nil) - .having_alert_policy - .update_all(policy_id: nil, escalations_started_at: nil) - end - end - - def down - # no-op - # - # We cannot retrieve the exact nullified values. We could - # approximately guess what the values are via the alert's - # escalation policy. However, that may not be accurate - # in all cases, as an alert's escalation policy is implictly - # inferred from the project rather than explicit, like an incident. - # So we won't backfill potentially incorrect data. - # - # This data is functionally safe to delete, as the relevant - # fields are read-only, and exclusively informational. - # - # Re-running the migration will have no effect. - end -end diff --git a/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb b/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb deleted file mode 100644 index 58b6342e30f..00000000000 --- a/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class IndexVulnerabilityReadsOnCastedClusterAgentIdFull < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_vuln_reads_on_casted_cluster_agent_id_where_it_is_null' - - def up - add_concurrent_index :vulnerability_reads, - :casted_cluster_agent_id, - name: INDEX_NAME, - where: 'casted_cluster_agent_id IS NOT NULL' - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/post_migrate/20220630085003_drop_project_successfull_pages_deploy_index_from_ci_builds.rb b/db/post_migrate/20220630085003_drop_project_successfull_pages_deploy_index_from_ci_builds.rb deleted file mode 100644 index 0810419a4e8..00000000000 --- a/db/post_migrate/20220630085003_drop_project_successfull_pages_deploy_index_from_ci_builds.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class DropProjectSuccessfullPagesDeployIndexFromCiBuilds < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_builds_on_project_id_for_successfull_pages_deploy' - - def up - remove_concurrent_index_by_name :ci_builds, INDEX_NAME - end - - # rubocop:disable Migration/PreventIndexCreation - def down - add_concurrent_index :ci_builds, - :project_id, - where: "(((type)::text = 'GenericCommitStatus'::text) AND ((stage)::text = 'deploy'::text) AND " \ - "((name)::text = 'pages:deploy'::text) AND ((status)::text = 'success'::text))", - name: INDEX_NAME - end - # rubocop:enable Migration/PreventIndexCreation -end diff --git a/db/post_migrate/20220630091409_add_index_on_events_for_contribution_analytics_optimization.rb b/db/post_migrate/20220630091409_add_index_on_events_for_contribution_analytics_optimization.rb deleted file mode 100644 index de16b17f489..00000000000 --- a/db/post_migrate/20220630091409_add_index_on_events_for_contribution_analytics_optimization.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnEventsForContributionAnalyticsOptimization < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_on_events_to_improve_contribution_analytics_performance' - - def up - add_concurrent_index :events, [:project_id, :target_type, :action, :created_at, :author_id, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :events, INDEX_NAME - end -end diff --git a/db/post_migrate/20220630151641_schedule_set_correct_vulnerability_state.rb b/db/post_migrate/20220630151641_schedule_set_correct_vulnerability_state.rb deleted file mode 100644 index 7c9211ff282..00000000000 --- a/db/post_migrate/20220630151641_schedule_set_correct_vulnerability_state.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class ScheduleSetCorrectVulnerabilityState < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MAX_BATCH_SIZE = 5_000 - JOB_INTERVAL = 2.minutes - MIGRATION_NAME = 'SetCorrectVulnerabilityState' - BATCH_CLASS_NAME = 'DismissedVulnerabilitiesStrategy' - SUB_BATCH_SIZE = 100 - - def up - queue_batched_background_migration( - MIGRATION_NAME, - :vulnerabilities, - :id, - job_interval: JOB_INTERVAL, - batch_size: MAX_BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - batch_class_name: BATCH_CLASS_NAME, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION_NAME, :vulnerabilities, :id, []) - end -end diff --git a/db/post_migrate/20220701085523_schedule_index_on_events_for_contribution_analytics_optimization.rb b/db/post_migrate/20220701085523_schedule_index_on_events_for_contribution_analytics_optimization.rb deleted file mode 100644 index 10be7a25965..00000000000 --- a/db/post_migrate/20220701085523_schedule_index_on_events_for_contribution_analytics_optimization.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class ScheduleIndexOnEventsForContributionAnalyticsOptimization < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_on_events_to_improve_contribution_analytics_performance' - - def up - prepare_async_index :events, [:project_id, :target_type, :action, :created_at, :author_id, :id], name: INDEX_NAME - end - - def down - unprepare_async_index :events, INDEX_NAME - end -end diff --git a/db/post_migrate/20220703182314_add_check_constraint_for_security_findings_partition_number.rb b/db/post_migrate/20220703182314_add_check_constraint_for_security_findings_partition_number.rb deleted file mode 100644 index 82b5d0b165d..00000000000 --- a/db/post_migrate/20220703182314_add_check_constraint_for_security_findings_partition_number.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddCheckConstraintForSecurityFindingsPartitionNumber < Gitlab::Database::Migration[2.0] - CONSTRAINT_NAME = 'check_partition_number' - - disable_ddl_transaction! - - def up - add_check_constraint(:security_findings, 'partition_number = 1', CONSTRAINT_NAME) - end - - def down - remove_check_constraint(:security_findings, CONSTRAINT_NAME) - end -end diff --git a/db/post_migrate/20220704044408_remove_foreign_key_in_project_tracing_settings.rb b/db/post_migrate/20220704044408_remove_foreign_key_in_project_tracing_settings.rb deleted file mode 100644 index 95eb461238f..00000000000 --- a/db/post_migrate/20220704044408_remove_foreign_key_in_project_tracing_settings.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveForeignKeyInProjectTracingSettings < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists(:project_tracing_settings, column: :project_id) - end - end - - def down - add_concurrent_foreign_key :project_tracing_settings, :projects, - column: :project_id, on_delete: :cascade, name: 'fk_rails_fe56f57fc6' - end -end diff --git a/db/post_migrate/20220704045440_drop_project_tracing_settings_table.rb b/db/post_migrate/20220704045440_drop_project_tracing_settings_table.rb deleted file mode 100644 index 1ce8b05a08d..00000000000 --- a/db/post_migrate/20220704045440_drop_project_tracing_settings_table.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropProjectTracingSettingsTable < Gitlab::Database::Migration[2.0] - def up - drop_table :project_tracing_settings - end - - def down - create_table :project_tracing_settings, id: :bigserial do |t| - t.timestamps_with_timezone null: false - - t.references :project, type: :integer, null: false, index: { unique: true } - - t.string :external_url, null: false - end - end -end diff --git a/db/post_migrate/20220705114635_drop_index_on_ci_runner_versions_on_version.rb b/db/post_migrate/20220705114635_drop_index_on_ci_runner_versions_on_version.rb deleted file mode 100644 index 22ff65f6fc3..00000000000 --- a/db/post_migrate/20220705114635_drop_index_on_ci_runner_versions_on_version.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnCiRunnerVersionsOnVersion < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_runner_versions_on_version' - - def up - remove_concurrent_index_by_name :ci_runner_versions, INDEX_NAME - end - - def down - add_concurrent_index :ci_runner_versions, :version, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220705180843_validate_requirements_issue_id_not_null.rb b/db/post_migrate/20220705180843_validate_requirements_issue_id_not_null.rb deleted file mode 100644 index a0c8954b481..00000000000 --- a/db/post_migrate/20220705180843_validate_requirements_issue_id_not_null.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ValidateRequirementsIssueIdNotNull < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - constraint_name = 'check_requirement_issue_not_null' - - validate_not_null_constraint(:requirements, :issue_id, constraint_name: constraint_name) - end - - def down - # No op - end -end diff --git a/db/post_migrate/20220706065245_remove_foreign_key_in_clusters_applications_elastic_stacks.rb b/db/post_migrate/20220706065245_remove_foreign_key_in_clusters_applications_elastic_stacks.rb deleted file mode 100644 index bfe60099bfa..00000000000 --- a/db/post_migrate/20220706065245_remove_foreign_key_in_clusters_applications_elastic_stacks.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveForeignKeyInClustersApplicationsElasticStacks < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists(:clusters_applications_elastic_stacks, column: :cluster_id) - end - end - - def down - add_concurrent_foreign_key :clusters_applications_elastic_stacks, :clusters, - column: :cluster_id, on_delete: :cascade, name: 'fk_rails_026f219f46' - end -end diff --git a/db/post_migrate/20220706065611_remove_foreign_key_in_clusters_integration_elasticstack.rb b/db/post_migrate/20220706065611_remove_foreign_key_in_clusters_integration_elasticstack.rb deleted file mode 100644 index eeec465f6b9..00000000000 --- a/db/post_migrate/20220706065611_remove_foreign_key_in_clusters_integration_elasticstack.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveForeignKeyInClustersIntegrationElasticstack < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists(:clusters_integration_elasticstack, column: :cluster_id) - end - end - - def down - add_concurrent_foreign_key :clusters_integration_elasticstack, :clusters, - column: :cluster_id, on_delete: :cascade, name: 'fk_rails_cc5ba8f658' - end -end diff --git a/db/post_migrate/20220706070804_drop_clusters_applications_elastic_stacks_table.rb b/db/post_migrate/20220706070804_drop_clusters_applications_elastic_stacks_table.rb deleted file mode 100644 index cedf666e428..00000000000 --- a/db/post_migrate/20220706070804_drop_clusters_applications_elastic_stacks_table.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropClustersApplicationsElasticStacksTable < Gitlab::Database::Migration[2.0] - def up - drop_table :clusters_applications_elastic_stacks - end - - def down - create_table :clusters_applications_elastic_stacks do |t| - t.timestamps_with_timezone null: false - t.references :cluster, type: :bigint, null: false, index: { unique: true } - t.integer :status, null: false - t.string :version, null: false, limit: 255 - t.text :status_reason - end - end -end diff --git a/db/post_migrate/20220706071304_drop_clusters_integration_elasticstack_table.rb b/db/post_migrate/20220706071304_drop_clusters_integration_elasticstack_table.rb deleted file mode 100644 index 206652b5dcf..00000000000 --- a/db/post_migrate/20220706071304_drop_clusters_integration_elasticstack_table.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class DropClustersIntegrationElasticstackTable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_clusters_integration_elasticstack_enabled' - - def up - drop_table :clusters_integration_elasticstack - end - - def down - create_table :clusters_integration_elasticstack, id: false do |t| - t.timestamps_with_timezone null: false - t.references :cluster, primary_key: true, type: :bigint, default: nil, index: false - t.boolean :enabled, null: false, default: false - t.text :chart_version, limit: 10 - end - - add_concurrent_index(:clusters_integration_elasticstack, [:enabled, :created_at, :cluster_id], name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20220706115138_create_async_index_on_security_findings.rb b/db/post_migrate/20220706115138_create_async_index_on_security_findings.rb deleted file mode 100644 index 30baa1af91c..00000000000 --- a/db/post_migrate/20220706115138_create_async_index_on_security_findings.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class CreateAsyncIndexOnSecurityFindings < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_on_security_findings_uuid_and_id_order_desc' - - def up - prepare_async_index( - :security_findings, - %i[uuid id], - order: { id: :desc }, - name: INDEX_NAME - ) - end - - def down - unprepare_async_index( - :security_findings, - %i[uuid id], - name: INDEX_NAME - ) - end -end diff --git a/db/post_migrate/20220706122719_create_index_on_security_findings_uuid_id_desc.rb b/db/post_migrate/20220706122719_create_index_on_security_findings_uuid_id_desc.rb deleted file mode 100644 index 0c2e2cb4b70..00000000000 --- a/db/post_migrate/20220706122719_create_index_on_security_findings_uuid_id_desc.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class CreateIndexOnSecurityFindingsUuidIdDesc < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_on_security_findings_uuid_and_id_order_desc' - - def up - add_concurrent_index( - :security_findings, - %i[uuid id], - order: { id: :desc }, - name: INDEX_NAME - ) - end - - def down - remove_concurrent_index_by_name( - :security_findings, - INDEX_NAME - ) - end -end diff --git a/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb b/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb deleted file mode 100644 index 48dc5b5d84a..00000000000 --- a/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class AddIndicesOnSecurityScansInfoColumn < Gitlab::Database::Migration[2.0] - INDEX_NAME_ON_ERRORS = :index_security_scans_on_length_of_errors - INDEX_NAME_ON_WARNINGS = :index_security_scans_on_length_of_warnings - - disable_ddl_transaction! - - def up - add_concurrent_index( - :security_scans, - "pipeline_id, jsonb_array_length(COALESCE((security_scans.info -> 'errors'::text), '[]'::jsonb))", - name: INDEX_NAME_ON_ERRORS - ) - - add_concurrent_index( - :security_scans, - "pipeline_id, jsonb_array_length(COALESCE((security_scans.info -> 'warnings'::text), '[]'::jsonb))", - name: INDEX_NAME_ON_WARNINGS - ) - end - - def down - remove_concurrent_index_by_name :security_scans, INDEX_NAME_ON_ERRORS - remove_concurrent_index_by_name :security_scans, INDEX_NAME_ON_WARNINGS - end -end diff --git a/db/post_migrate/20220706145113_backfill_namespace_id_on_issues.rb b/db/post_migrate/20220706145113_backfill_namespace_id_on_issues.rb deleted file mode 100644 index 8114967ac8e..00000000000 --- a/db/post_migrate/20220706145113_backfill_namespace_id_on_issues.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class BackfillNamespaceIdOnIssues < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - MIGRATION = 'BackfillProjectNamespaceOnIssues' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 500 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 10 - - def up - queue_batched_background_migration( - MIGRATION, - :issues, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :issues, :id, []) - end -end diff --git a/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb b/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb deleted file mode 100644 index 912578d6b7c..00000000000 --- a/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -class RescheduleBackfillImportedIssueSearchData < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'BackfillImportedIssueSearchData' - DELAY_INTERVAL = 120.seconds - BATCH_SIZE = 50_000 - SUB_BATCH_SIZE = 1_000 - - def up - # remove the original migration - delete_batched_background_migration(MIGRATION, :issues, :id, []) - - # reschedule the migration - queue_batched_background_migration( - MIGRATION, - :issues, - :id, - job_interval: DELAY_INTERVAL, - batch_min_value: min_value, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :issues, :id, []) - end - - private - - def min_value - start_value = Gitlab::Database::BackgroundMigration::BatchedMigration.find_by( - job_class_name: "BackfillIssueSearchData" - )&.max_value - - return BATCH_MIN_VALUE unless start_value - - max_value = Issue.maximum(:id) - - return BATCH_MIN_VALUE unless max_value - - # Just in case the issue's max ID is now lower than the history in the table - [start_value, max_value].min - end -end diff --git a/db/post_migrate/20220707105529_cleanup_chat_name_service_id.rb b/db/post_migrate/20220707105529_cleanup_chat_name_service_id.rb deleted file mode 100644 index aa3af4acf31..00000000000 --- a/db/post_migrate/20220707105529_cleanup_chat_name_service_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupChatNameServiceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :chat_names, :service_id, :integration_id - end - - def down - undo_cleanup_concurrent_column_rename :chat_names, :service_id, :integration_id - end -end diff --git a/db/post_migrate/20220707160921_cleanup_slack_integration_service_id.rb b/db/post_migrate/20220707160921_cleanup_slack_integration_service_id.rb deleted file mode 100644 index 25b4252e48b..00000000000 --- a/db/post_migrate/20220707160921_cleanup_slack_integration_service_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupSlackIntegrationServiceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :slack_integrations, :service_id, :integration_id - end - - def down - undo_cleanup_concurrent_column_rename :slack_integrations, :service_id, :integration_id - end -end diff --git a/db/post_migrate/20220707192420_remove_tmp_idx_merge_requests_draft_and_status.rb b/db/post_migrate/20220707192420_remove_tmp_idx_merge_requests_draft_and_status.rb deleted file mode 100644 index a8cfea02463..00000000000 --- a/db/post_migrate/20220707192420_remove_tmp_idx_merge_requests_draft_and_status.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIdxMergeRequestsDraftAndStatus < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = "tmp_index_merge_requests_draft_and_status" - CORRECTED_REGEXP_STR = "^(\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP)" - - def up - remove_concurrent_index_by_name :merge_requests, INDEX_NAME - end - - def down - add_concurrent_index :merge_requests, :id, - where: "draft = false AND state_id = 1 AND ((title)::text ~* '#{CORRECTED_REGEXP_STR}'::text)", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220708100508_drop_index_on_ci_runner_versions_on_status.rb b/db/post_migrate/20220708100508_drop_index_on_ci_runner_versions_on_status.rb deleted file mode 100644 index 71eb5a0867e..00000000000 --- a/db/post_migrate/20220708100508_drop_index_on_ci_runner_versions_on_status.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnCiRunnerVersionsOnStatus < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_runner_versions_on_status' - - def up - remove_concurrent_index_by_name :ci_runner_versions, INDEX_NAME - end - - def down - add_concurrent_index :ci_runner_versions, :version, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220712131533_cleanup_issue_tracker_data_service_id.rb b/db/post_migrate/20220712131533_cleanup_issue_tracker_data_service_id.rb deleted file mode 100644 index be304c5fe6d..00000000000 --- a/db/post_migrate/20220712131533_cleanup_issue_tracker_data_service_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupIssueTrackerDataServiceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :issue_tracker_data, :service_id, :integration_id - end - - def down - undo_cleanup_concurrent_column_rename :issue_tracker_data, :service_id, :integration_id - end -end diff --git a/db/post_migrate/20220712144900_cleanup_jira_tracker_data_service_id.rb b/db/post_migrate/20220712144900_cleanup_jira_tracker_data_service_id.rb deleted file mode 100644 index 90b35f03054..00000000000 --- a/db/post_migrate/20220712144900_cleanup_jira_tracker_data_service_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupJiraTrackerDataServiceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :jira_tracker_data, :service_id, :integration_id - end - - def down - undo_cleanup_concurrent_column_rename :jira_tracker_data, :service_id, :integration_id - end -end diff --git a/db/post_migrate/20220712175029_add_index_with_target_type_to_todos.rb b/db/post_migrate/20220712175029_add_index_with_target_type_to_todos.rb deleted file mode 100644 index 077e8ed4bbe..00000000000 --- a/db/post_migrate/20220712175029_add_index_with_target_type_to_todos.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexWithTargetTypeToTodos < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_FOR_PROJECTS_NAME = 'index_requirements_project_id_user_id_id_and_target_type' - INDEX_FOR_TARGET_TYPE_NAME = 'index_requirements_user_id_and_target_type' - - def up - add_concurrent_index :todos, [:project_id, :user_id, :id, :target_type], name: INDEX_FOR_PROJECTS_NAME - add_concurrent_index :todos, [:user_id, :target_type], name: INDEX_FOR_TARGET_TYPE_NAME - end - - def down - remove_concurrent_index_by_name :todos, INDEX_FOR_PROJECTS_NAME - remove_concurrent_index_by_name :todos, INDEX_FOR_TARGET_TYPE_NAME - end -end diff --git a/db/post_migrate/20220712181304_remove_deprecated_indexes_from_todos.rb b/db/post_migrate/20220712181304_remove_deprecated_indexes_from_todos.rb deleted file mode 100644 index 4f99caa10a4..00000000000 --- a/db/post_migrate/20220712181304_remove_deprecated_indexes_from_todos.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class RemoveDeprecatedIndexesFromTodos < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - PROJECTS_INDEX = 'index_todos_on_project_id_and_user_id_and_id' - USERS_INDEX = 'index_todos_on_user_id' - - # These indexes are deprecated in favor of two new ones - # added in a previous migration: - # - # * index_requirements_project_id_user_id_target_type_and_id - # * index_requirements_user_id_and_target_type - def up - remove_concurrent_index_by_name :todos, PROJECTS_INDEX - remove_concurrent_index_by_name :todos, USERS_INDEX - end - - def down - add_concurrent_index :todos, [:project_id, :user_id, :id], name: PROJECTS_INDEX - add_concurrent_index :todos, :user_id, name: USERS_INDEX - end -end diff --git a/db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb b/db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb deleted file mode 100644 index eb612a98ae6..00000000000 --- a/db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class CleanupBackfillDraftStatusesOnMergeRequests < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - MIGRATION = 'BackfillDraftStatusOnMergeRequests' - - def up - finalize_background_migration(MIGRATION) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220714122311_add_async_index_on_security_findings_id_and_partition_number.rb b/db/post_migrate/20220714122311_add_async_index_on_security_findings_id_and_partition_number.rb deleted file mode 100644 index 02d18ba8b40..00000000000 --- a/db/post_migrate/20220714122311_add_async_index_on_security_findings_id_and_partition_number.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexOnSecurityFindingsIdAndPartitionNumber < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'security_findings_partitioned_pkey' - - disable_ddl_transaction! - - def up - prepare_async_index :security_findings, [:id, :partition_number], unique: true, name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :security_findings, INDEX_NAME - end -end diff --git a/db/post_migrate/20220714122418_add_async_index_on_security_findings_unique_columns.rb b/db/post_migrate/20220714122418_add_async_index_on_security_findings_unique_columns.rb deleted file mode 100644 index e21d3db6798..00000000000 --- a/db/post_migrate/20220714122418_add_async_index_on_security_findings_unique_columns.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexOnSecurityFindingsUniqueColumns < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_security_findings_on_unique_columns' - - disable_ddl_transaction! - - def up - prepare_async_index :security_findings, [:uuid, :scan_id, :partition_number], unique: true, name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :security_findings, INDEX_NAME - end -end diff --git a/db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb b/db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb deleted file mode 100644 index ed5b85b711c..00000000000 --- a/db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddParentLinkUniqueWorkItemIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_work_item_parent_links_on_work_item_id' - OLD_INDEX_NAME = 'index_parent_links_on_work_item_id_and_work_item_parent_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :work_item_parent_links, :work_item_id, unique: true, name: INDEX_NAME - remove_concurrent_index_by_name :work_item_parent_links, OLD_INDEX_NAME - end - - def down - add_concurrent_index :work_item_parent_links, [:work_item_id, :work_item_parent_id], - unique: true, name: OLD_INDEX_NAME - remove_concurrent_index_by_name :work_item_parent_links, INDEX_NAME - end -end diff --git a/db/post_migrate/20220715152108_backfill_project_import_level.rb b/db/post_migrate/20220715152108_backfill_project_import_level.rb deleted file mode 100644 index 65a0dc0a58a..00000000000 --- a/db/post_migrate/20220715152108_backfill_project_import_level.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class BackfillProjectImportLevel < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'BackfillProjectImportLevel' - INTERVAL = 120.seconds - - def up - queue_batched_background_migration( - MIGRATION, - :namespaces, - :id, - job_interval: INTERVAL - ) - end - - def down - delete_batched_background_migration(MIGRATION, :namespaces, :id, []) - end -end diff --git a/db/post_migrate/20220715160023_drop_post_migration_test_table.rb b/db/post_migrate/20220715160023_drop_post_migration_test_table.rb deleted file mode 100644 index 98b4cbcf972..00000000000 --- a/db/post_migrate/20220715160023_drop_post_migration_test_table.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class DropPostMigrationTestTable < Gitlab::Database::Migration[2.0] - def up - drop_table :post_migration_test_table - end - - def down - create_table :post_migration_test_table do |t| - t.integer :status, null: false - end - end -end diff --git a/db/post_migrate/20220715163254_update_notes_in_past.rb b/db/post_migrate/20220715163254_update_notes_in_past.rb deleted file mode 100644 index 1c46a3bc9dc..00000000000 --- a/db/post_migrate/20220715163254_update_notes_in_past.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class UpdateNotesInPast < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - loop do - update_count = define_batchable_model('notes') - .where('created_at < ?', '1970-01-01').limit(100) - .update_all(created_at: '1970-01-01 00:00:00') - - break if update_count == 0 - end - end - - def down - # no op - end -end diff --git a/db/post_migrate/20220715185348_add_index_on_security_findings_id_and_partition_number.rb b/db/post_migrate/20220715185348_add_index_on_security_findings_id_and_partition_number.rb deleted file mode 100644 index e867ef81381..00000000000 --- a/db/post_migrate/20220715185348_add_index_on_security_findings_id_and_partition_number.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnSecurityFindingsIdAndPartitionNumber < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'security_findings_partitioned_pkey' - - disable_ddl_transaction! - - def up - add_concurrent_index :security_findings, [:id, :partition_number], unique: true, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :security_findings, INDEX_NAME - end -end diff --git a/db/post_migrate/20220715185436_add_index_on_security_findings_unique_columns.rb b/db/post_migrate/20220715185436_add_index_on_security_findings_unique_columns.rb deleted file mode 100644 index 33b069a27d4..00000000000 --- a/db/post_migrate/20220715185436_add_index_on_security_findings_unique_columns.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnSecurityFindingsUniqueColumns < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_security_findings_on_unique_columns' - - disable_ddl_transaction! - - def up - add_concurrent_index :security_findings, [:uuid, :scan_id, :partition_number], unique: true, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :security_findings, INDEX_NAME - end -end diff --git a/db/post_migrate/20220715190612_drop_index_on_security_findings_uuid_and_scan_id.rb b/db/post_migrate/20220715190612_drop_index_on_security_findings_uuid_and_scan_id.rb deleted file mode 100644 index a8a9bab2c84..00000000000 --- a/db/post_migrate/20220715190612_drop_index_on_security_findings_uuid_and_scan_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnSecurityFindingsUuidAndScanId < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_security_findings_on_uuid_and_scan_id' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :security_findings, INDEX_NAME - end - - def down - add_concurrent_index :security_findings, [:uuid, :scan_id], unique: true, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb b/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb deleted file mode 100644 index c2859c68c52..00000000000 --- a/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class ChangePrimaryKeyOfSecurityFindingsTable < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def up - execute(<<~SQL) - ALTER TABLE security_findings DROP CONSTRAINT security_findings_pkey; - SQL - - execute(<<~SQL) - ALTER TABLE security_findings ADD CONSTRAINT security_findings_pkey PRIMARY KEY USING index security_findings_partitioned_pkey; - SQL - end - - def down - execute(<<~SQL) - ALTER TABLE security_findings DROP CONSTRAINT security_findings_pkey; - SQL - - execute(<<~SQL) - ALTER TABLE security_findings ADD CONSTRAINT security_findings_pkey PRIMARY KEY (id); - SQL - - execute(<<~SQL) - CREATE UNIQUE INDEX security_findings_partitioned_pkey ON security_findings USING btree(id, partition_number); - SQL - end -end diff --git a/db/post_migrate/20220719081542_drop_queued_at_index_from_ci_builds.rb b/db/post_migrate/20220719081542_drop_queued_at_index_from_ci_builds.rb deleted file mode 100644 index 4a16d022c70..00000000000 --- a/db/post_migrate/20220719081542_drop_queued_at_index_from_ci_builds.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropQueuedAtIndexFromCiBuilds < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_builds_on_queued_at' - - def up - remove_concurrent_index_by_name :ci_builds, INDEX_NAME - end - - # rubocop:disable Migration/PreventIndexCreation - def down - add_concurrent_index :ci_builds, :queued_at, name: INDEX_NAME - end - # rubocop:enable Migration/PreventIndexCreation -end diff --git a/db/post_migrate/20220719165537_remove_ci_runners_semver_column.rb b/db/post_migrate/20220719165537_remove_ci_runners_semver_column.rb deleted file mode 100644 index a6929153d10..00000000000 --- a/db/post_migrate/20220719165537_remove_ci_runners_semver_column.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveCiRunnersSemverColumn < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_runners_on_id_and_semver_cidr' - - def up - with_lock_retries do - remove_column :ci_runners, :semver - end - end - - def down - with_lock_retries do - add_column :ci_runners, :semver, :text, null: true - end - add_text_limit :ci_runners, :semver, 16 - add_concurrent_index :ci_runners, 'id, (semver::cidr)', name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb b/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb deleted file mode 100644 index fb3d12840cc..00000000000 --- a/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class RemovePendingBuildsCoveringIndexFromCiBuilds < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_builds_runner_id_pending_covering' - - def up - remove_concurrent_index_by_name :ci_builds, INDEX_NAME - end - - # rubocop:disable Migration/PreventIndexCreation - def down - disable_statement_timeout do - unless index_exists_by_name?(:ci_builds, INDEX_NAME) - execute <<~SQL.squish - CREATE INDEX CONCURRENTLY #{INDEX_NAME} - ON ci_builds (runner_id, id) - INCLUDE (project_id) - WHERE status = 'pending' AND type = 'Ci::Build' - SQL - end - end - end - # rubocop:enable Migration/PreventIndexCreation -end diff --git a/db/post_migrate/20220720121421_remove_pat_and_ssh_enforcement_columns_from_application_settings.rb b/db/post_migrate/20220720121421_remove_pat_and_ssh_enforcement_columns_from_application_settings.rb deleted file mode 100644 index b03cad08f35..00000000000 --- a/db/post_migrate/20220720121421_remove_pat_and_ssh_enforcement_columns_from_application_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class RemovePatAndSshEnforcementColumnsFromApplicationSettings < Gitlab::Database::Migration[2.0] - def change - remove_column :application_settings, :enforce_pat_expiration, :boolean, default: true, null: false - remove_column :application_settings, :enforce_ssh_key_expiration, :boolean, default: true, null: false - end -end diff --git a/db/post_migrate/20220720123249_remove_token_column_from_ci_builds.rb b/db/post_migrate/20220720123249_remove_token_column_from_ci_builds.rb deleted file mode 100644 index 1bc13b6ea05..00000000000 --- a/db/post_migrate/20220720123249_remove_token_column_from_ci_builds.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class RemoveTokenColumnFromCiBuilds < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_builds, :token, :string - end -end diff --git a/db/post_migrate/20220720171102_add_index_on_vulnerability_reads_namespace_id.rb b/db/post_migrate/20220720171102_add_index_on_vulnerability_reads_namespace_id.rb deleted file mode 100644 index e90fcfd3016..00000000000 --- a/db/post_migrate/20220720171102_add_index_on_vulnerability_reads_namespace_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnVulnerabilityReadsNamespaceId < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_vuln_reads_on_namespace_id_state_severity_and_vuln_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerability_reads, - [:namespace_id, :state, :severity, :vulnerability_id], - name: INDEX_NAME, - order: { vulnerability_id: :desc } - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/post_migrate/20220720171801_add_foreign_key_on_vulnerability_reads_namespace_id.rb b/db/post_migrate/20220720171801_add_foreign_key_on_vulnerability_reads_namespace_id.rb deleted file mode 100644 index c1b6a9d6909..00000000000 --- a/db/post_migrate/20220720171801_add_foreign_key_on_vulnerability_reads_namespace_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyOnVulnerabilityReadsNamespaceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :vulnerability_reads, :namespaces, column: :namespace_id, on_delete: :cascade - end - - def down - with_lock_retries do - remove_foreign_key_if_exists :vulnerability_reads, column: :namespace_id - end - end -end diff --git a/db/post_migrate/20220721031446_schedule_disable_legacy_open_source_license_for_one_member_no_repo_projects.rb b/db/post_migrate/20220721031446_schedule_disable_legacy_open_source_license_for_one_member_no_repo_projects.rb deleted file mode 100644 index 7665d49b1d9..00000000000 --- a/db/post_migrate/20220721031446_schedule_disable_legacy_open_source_license_for_one_member_no_repo_projects.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDisableLegacyOpenSourceLicenseForOneMemberNoRepoProjects < Gitlab::Database::Migration[2.0] - MIGRATION = 'DisableLegacyOpenSourceLicenseForOneMemberNoRepoProjects' - INTERVAL = 2.minutes - BATCH_SIZE = 5_000 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 500 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20220721140252_prepare_partial_trigram_indexes_for_issues.rb b/db/post_migrate/20220721140252_prepare_partial_trigram_indexes_for_issues.rb deleted file mode 100644 index 00a51f3024e..00000000000 --- a/db/post_migrate/20220721140252_prepare_partial_trigram_indexes_for_issues.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class PreparePartialTrigramIndexesForIssues < Gitlab::Database::Migration[2.0] - TITLE_INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - def up - prepare_async_index :issues, :title, - name: TITLE_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'" - - prepare_async_index :issues, :description, - name: DESCRIPTION_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'" - end - - def down - unprepare_async_index_by_name :issues, DESCRIPTION_INDEX_NAME - unprepare_async_index_by_name :issues, TITLE_INDEX_NAME - end -end diff --git a/db/post_migrate/20220722084543_schedule_disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb b/db/post_migrate/20220722084543_schedule_disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb deleted file mode 100644 index 7fbf09846cf..00000000000 --- a/db/post_migrate/20220722084543_schedule_disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDisableLegacyOpenSourceLicenseForNoIssuesNoRepoProjects < Gitlab::Database::Migration[2.0] - MIGRATION = 'DisableLegacyOpenSourceLicenseForNoIssuesNoRepoProjects' - INTERVAL = 2.minutes - BATCH_SIZE = 5_000 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb b/db/post_migrate/20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb deleted file mode 100644 index 546923141e2..00000000000 --- a/db/post_migrate/20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class RescheduleSetLegacyOpenSourceLicenseAvailableForNonPublicProjects < Gitlab::Database::Migration[2.0] - MIGRATION = 'SetLegacyOpenSourceLicenseAvailableForNonPublicProjects' - INTERVAL = 2.minutes - BATCH_SIZE = 5_000 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, :projects, :id, []) - - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20220722145845_schedule_backfilling_the_namespace_id_for_vulnerability_reads.rb b/db/post_migrate/20220722145845_schedule_backfilling_the_namespace_id_for_vulnerability_reads.rb deleted file mode 100644 index e2d1846f8f6..00000000000 --- a/db/post_migrate/20220722145845_schedule_backfilling_the_namespace_id_for_vulnerability_reads.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillingTheNamespaceIdForVulnerabilityReads < Gitlab::Database::Migration[2.0] - MIGRATION_NAME = 'BackfillNamespaceIdOfVulnerabilityReads' - - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - def up - queue_batched_background_migration( - MIGRATION_NAME, - :vulnerability_reads, - :vulnerability_id, - job_interval: 2.minutes, - batch_size: 10_000, - sub_batch_size: 200 - ) - end - - def down - delete_batched_background_migration(MIGRATION_NAME, :vulnerability_reads, :vulnerability_id, []) - end -end diff --git a/db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb b/db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb deleted file mode 100644 index 0deba9b3e81..00000000000 --- a/db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class UpdateJiraTrackerDataDeploymentTypeBasedOnUrl < Gitlab::Database::Migration[2.0] - MIGRATION = 'UpdateJiraTrackerDataDeploymentTypeBasedOnUrl' - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 2_500 - SUB_BATCH_SIZE = 2_500 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - say "Scheduling #{MIGRATION} jobs" - delete_queued_jobs(MIGRATION) - queue_batched_background_migration( - MIGRATION, - :jira_tracker_data, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220726182310_add_user_fk_to_vulnerability_state_transitions.rb b/db/post_migrate/20220726182310_add_user_fk_to_vulnerability_state_transitions.rb deleted file mode 100644 index ad0bf6141b2..00000000000 --- a/db/post_migrate/20220726182310_add_user_fk_to_vulnerability_state_transitions.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddUserFkToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_vulnerability_state_transitions_on_author_id' - - def up - add_concurrent_index :vulnerability_state_transitions, :author_id, name: INDEX_NAME - add_concurrent_foreign_key :vulnerability_state_transitions, :users, column: :author_id, on_delete: :nullify - end - - def down - with_lock_retries do - remove_foreign_key :vulnerability_state_transitions, column: :author_id - end - - remove_concurrent_index_by_name :vulnerability_state_transitions, INDEX_NAME - end -end diff --git a/db/post_migrate/20220726225114_remove_tmp_index_group_membership_namespace_id_column.rb b/db/post_migrate/20220726225114_remove_tmp_index_group_membership_namespace_id_column.rb deleted file mode 100644 index db47be6a1e3..00000000000 --- a/db/post_migrate/20220726225114_remove_tmp_index_group_membership_namespace_id_column.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIndexGroupMembershipNamespaceIdColumn < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_for_namespace_id_migration_on_group_members' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :members, INDEX_NAME - end - - def down - add_concurrent_index :members, :id, - where: "members.member_namespace_id IS NULL and members.type = 'GroupMember'", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220728134255_update_index_vulnerabilities_common_finder.rb b/db/post_migrate/20220728134255_update_index_vulnerabilities_common_finder.rb deleted file mode 100644 index 617d7661b5b..00000000000 --- a/db/post_migrate/20220728134255_update_index_vulnerabilities_common_finder.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class UpdateIndexVulnerabilitiesCommonFinder < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'index_vulnerabilities_common_finder_query_on_default_branch' - OLD_INDEX_NAME = 'index_vulnerabilites_common_finder_query' - - def up - add_concurrent_index :vulnerabilities, [:project_id, :state, :report_type, :present_on_default_branch, - :severity, :id], name: NEW_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME) - end - - def down - add_concurrent_index :vulnerabilities, [:project_id, :state, :report_type, :severity, :id], name: OLD_INDEX_NAME - - remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME) - end -end diff --git a/db/post_migrate/20220729033851_add_partial_legacy_open_source_license_available_index.rb b/db/post_migrate/20220729033851_add_partial_legacy_open_source_license_available_index.rb deleted file mode 100644 index c99c452c149..00000000000 --- a/db/post_migrate/20220729033851_add_partial_legacy_open_source_license_available_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddPartialLegacyOpenSourceLicenseAvailableIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_project_settings_on_legacy_open_source_license_available' - - def up - add_concurrent_index :project_settings, - %i[legacy_open_source_license_available], - where: "legacy_open_source_license_available = TRUE", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name(:project_settings, INDEX_NAME) - end -end diff --git a/db/post_migrate/20220729052031_add_index_on_vulnerability_reads_namespace_id_with_report_type.rb b/db/post_migrate/20220729052031_add_index_on_vulnerability_reads_namespace_id_with_report_type.rb deleted file mode 100644 index 53b2c1728e1..00000000000 --- a/db/post_migrate/20220729052031_add_index_on_vulnerability_reads_namespace_id_with_report_type.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnVulnerabilityReadsNamespaceIdWithReportType < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_vulnerability_reads_common_finder_query_with_namespace_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerability_reads, - [:namespace_id, :state, :report_type, :severity, :vulnerability_id], - name: INDEX_NAME, - order: { vulnerability_id: :desc } - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/post_migrate/20220801144713_add_partial_trigram_index_for_issue_title.rb b/db/post_migrate/20220801144713_add_partial_trigram_index_for_issue_title.rb deleted file mode 100644 index c4db8232eba..00000000000 --- a/db/post_migrate/20220801144713_add_partial_trigram_index_for_issue_title.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddPartialTrigramIndexForIssueTitle < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - - def up - add_concurrent_index :issues, :title, - name: INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'" - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20220801150028_add_partial_trigram_index_for_issue_description.rb b/db/post_migrate/20220801150028_add_partial_trigram_index_for_issue_description.rb deleted file mode 100644 index 79f25718e15..00000000000 --- a/db/post_migrate/20220801150028_add_partial_trigram_index_for_issue_description.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddPartialTrigramIndexForIssueDescription < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - def up - add_concurrent_index :issues, :description, - name: INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'" - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20220801155858_schedule_disable_legacy_open_source_licence_for_recent_public_projects.rb b/db/post_migrate/20220801155858_schedule_disable_legacy_open_source_licence_for_recent_public_projects.rb deleted file mode 100644 index a662cfe4be3..00000000000 --- a/db/post_migrate/20220801155858_schedule_disable_legacy_open_source_licence_for_recent_public_projects.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDisableLegacyOpenSourceLicenceForRecentPublicProjects < Gitlab::Database::Migration[2.0] - MIGRATION = 'DisableLegacyOpenSourceLicenceForRecentPublicProjects' - INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 5_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20220802112102_schedule_migrate_shared_vulnerability_scanners.rb b/db/post_migrate/20220802112102_schedule_migrate_shared_vulnerability_scanners.rb deleted file mode 100644 index 724bd323169..00000000000 --- a/db/post_migrate/20220802112102_schedule_migrate_shared_vulnerability_scanners.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class ScheduleMigrateSharedVulnerabilityScanners < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics.rb b/db/post_migrate/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics.rb deleted file mode 100644 index 46b98d319fd..00000000000 --- a/db/post_migrate/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class RescheduleBackfillContainerRegistrySizeIntoProjectStatistics < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 500 - MIGRATION_CLASS = 'BackfillProjectStatisticsContainerRepositorySize' - BATCH_CLASS_NAME = 'BackfillProjectStatisticsWithContainerRegistrySizeBatchingStrategy' - SUB_BATCH_SIZE = 100 - - disable_ddl_transaction! - - def up - return unless Gitlab.dev_or_test_env? || Gitlab.com? - - # remove the original migration - delete_batched_background_migration(MIGRATION_CLASS, :container_repositories, :project_id, []) - - # reschedule the migration - queue_batched_background_migration( - MIGRATION_CLASS, - :container_repositories, - :project_id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - batch_class_name: BATCH_CLASS_NAME, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.dev_or_test_env? || Gitlab.com? - - delete_batched_background_migration(MIGRATION_CLASS, :container_repositories, :project_id, []) - end -end diff --git a/db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb b/db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb deleted file mode 100644 index 81e95f531c1..00000000000 --- a/db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class IndexOnIntegrationTypeNewIdWhenActiveAndHasGroup < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_integrations_on_type_new_id_when_active_and_has_group' - - disable_ddl_transaction! - - def up - add_concurrent_index :integrations, - [:type_new, :id, :inherit_from_id], - name: INDEX_NAME, - where: '((active = true) AND (group_id IS NOT NULL))' - end - - def down - remove_concurrent_index_by_name :integrations, INDEX_NAME - end -end diff --git a/db/post_migrate/20220802204737_remove_deactivated_user_highest_role_stats.rb b/db/post_migrate/20220802204737_remove_deactivated_user_highest_role_stats.rb deleted file mode 100644 index e23fbfdf7f2..00000000000 --- a/db/post_migrate/20220802204737_remove_deactivated_user_highest_role_stats.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class RemoveDeactivatedUserHighestRoleStats < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # This migration is applicable to self-managed instances that may utilize the - # dormant user deactivation feature. This feature is not enabled on Gitlab.com. - return if Gitlab.com? - - users_table = define_batchable_model('users') - user_highest_roles_table = define_batchable_model('user_highest_roles') - - users_table.where(state: 'deactivated').each_batch do |users_batch| - user_ids = users_batch.pluck(:id) - user_highest_roles_table.where(user_id: user_ids).delete_all - end - end - - def down - # no-op - - # This migration removes entries from the UserHighestRole table and cannot be reversed - end -end diff --git a/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb b/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb deleted file mode 100644 index fa80b2b95e7..00000000000 --- a/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexTodosAttentionRequestAction < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_todos_attention_request_action" - ATTENTION_REQUESTED = 10 - - disable_ddl_transaction! - - def up - add_concurrent_index :todos, [:id], - where: "action = #{ATTENTION_REQUESTED}", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :todos, INDEX_NAME - end -end diff --git a/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb b/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb deleted file mode 100644 index d3b281b08ad..00000000000 --- a/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class CleanupMrAttentionRequestTodos < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class Todo < MigrationRecord - self.table_name = 'todos' - - include ::EachBatch - - ATTENTION_REQUESTED = 10 - end - - def up - Todo.where(action: Todo::ATTENTION_REQUESTED).each_batch do |todos_batch| - todos_batch.delete_all - end - end - - def down - # Attention request feature has been reverted. - end -end diff --git a/db/post_migrate/20220804235614_add_comment_to_vulnerability_state_transitions.rb b/db/post_migrate/20220804235614_add_comment_to_vulnerability_state_transitions.rb deleted file mode 100644 index 3e3cb5746bc..00000000000 --- a/db/post_migrate/20220804235614_add_comment_to_vulnerability_state_transitions.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class AddCommentToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.0] - # rubocop:disable Migration/AddLimitToTextColumns - # limit is added in db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb - def change - add_column :vulnerability_state_transitions, :comment, :text - end - # rubocop:enable Migration/AddLimitToTextColumns -end diff --git a/db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb b/db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb deleted file mode 100644 index dd84c0620ce..00000000000 --- a/db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddTextLimitToVulnerabilityStateTransitionsComment < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_text_limit :vulnerability_state_transitions, :comment, 255 - end - - def down - remove_text_limit :vulnerability_state_transitions, :comment - end -end diff --git a/db/post_migrate/20220808072054_prepare_index_removal_security_findings.rb b/db/post_migrate/20220808072054_prepare_index_removal_security_findings.rb deleted file mode 100644 index eb4158fa9dd..00000000000 --- a/db/post_migrate/20220808072054_prepare_index_removal_security_findings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class PrepareIndexRemovalSecurityFindings < Gitlab::Database::Migration[2.0] - INDEX_NAME = :index_on_security_findings_uuid_and_id_order_desc - - def up - prepare_async_index_removal :security_findings, [:uuid, :id], name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :security_findings, INDEX_NAME - end -end diff --git a/db/post_migrate/20220808131659_remove_ci_namespace_monthly_usages_additional_amount_available_column.rb b/db/post_migrate/20220808131659_remove_ci_namespace_monthly_usages_additional_amount_available_column.rb deleted file mode 100644 index 70a1e425e0d..00000000000 --- a/db/post_migrate/20220808131659_remove_ci_namespace_monthly_usages_additional_amount_available_column.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveCiNamespaceMonthlyUsagesAdditionalAmountAvailableColumn < Gitlab::Database::Migration[2.0] - def up - remove_column :ci_namespace_monthly_usages, :additional_amount_available - end - - def down - add_column :ci_namespace_monthly_usages, :additional_amount_available, :integer, default: 0, null: false - end -end diff --git a/db/post_migrate/20220809002011_schedule_destroy_invalid_group_members.rb b/db/post_migrate/20220809002011_schedule_destroy_invalid_group_members.rb deleted file mode 100644 index e5d97d890ab..00000000000 --- a/db/post_migrate/20220809002011_schedule_destroy_invalid_group_members.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDestroyInvalidGroupMembers < Gitlab::Database::Migration[2.0] - MIGRATION = 'DestroyInvalidGroupMembers' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 2_000 - SUB_BATCH_SIZE = 50 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - disable_ddl_transaction! - - def up - # no-op - # We want to no-op this due to potential inconsistencies in SM upgrade path - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220809214730_add_note_metadata_temp_index_on_id_where_task.rb b/db/post_migrate/20220809214730_add_note_metadata_temp_index_on_id_where_task.rb deleted file mode 100644 index 1c5a1b68041..00000000000 --- a/db/post_migrate/20220809214730_add_note_metadata_temp_index_on_id_where_task.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddNoteMetadataTempIndexOnIdWhereTask < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_system_note_metadata_on_id_where_task' - - disable_ddl_transaction! - - def up - add_concurrent_index :system_note_metadata, [:id, :action], where: "action = 'task'", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :system_note_metadata, INDEX_NAME - end -end diff --git a/db/post_migrate/20220810093742_add_async_tmp_index_job_artifacts_id_and_expire_at.rb b/db/post_migrate/20220810093742_add_async_tmp_index_job_artifacts_id_and_expire_at.rb deleted file mode 100644 index 5a52b26ed92..00000000000 --- a/db/post_migrate/20220810093742_add_async_tmp_index_job_artifacts_id_and_expire_at.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncTmpIndexJobArtifactsIdAndExpireAt < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_expire_at_file_type_trace' - - EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE = <<~SQL - (EXTRACT(day FROM timezone('UTC', expire_at)) IN (21, 22, 23) - AND EXTRACT(minute FROM timezone('UTC', expire_at)) IN (0, 30, 45) - AND EXTRACT(second FROM timezone('UTC', expire_at)) = 0) - OR file_type = 3 - SQL - - def up - prepare_async_index :ci_job_artifacts, :id, - where: EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE, name: INDEX_NAME - end - - def down - unprepare_async_index :ci_job_artifacts, INDEX_NAME - end -end diff --git a/db/post_migrate/20220815061621_rename_web_hooks_service_id_to_integration_id.rb b/db/post_migrate/20220815061621_rename_web_hooks_service_id_to_integration_id.rb deleted file mode 100644 index 6bcee7f51df..00000000000 --- a/db/post_migrate/20220815061621_rename_web_hooks_service_id_to_integration_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class RenameWebHooksServiceIdToIntegrationId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - rename_column_concurrently :web_hooks, :service_id, :integration_id - end - - def down - undo_rename_column_concurrently :web_hooks, :service_id, :integration_id - end -end diff --git a/db/post_migrate/20220816075638_drop_uuid_and_id_index_from_security_findings.rb b/db/post_migrate/20220816075638_drop_uuid_and_id_index_from_security_findings.rb deleted file mode 100644 index 7a41e0b7835..00000000000 --- a/db/post_migrate/20220816075638_drop_uuid_and_id_index_from_security_findings.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropUuidAndIdIndexFromSecurityFindings < Gitlab::Database::Migration[2.0] - INDEX_NAME = :index_on_security_findings_uuid_and_id_order_desc - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :security_findings, name: INDEX_NAME - end - - def down - add_concurrent_index :security_findings, [:uuid, :id], order: { id: :desc }, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220816163444_update_start_date_for_iterations_cadences.rb b/db/post_migrate/20220816163444_update_start_date_for_iterations_cadences.rb deleted file mode 100644 index 631e8941add..00000000000 --- a/db/post_migrate/20220816163444_update_start_date_for_iterations_cadences.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -class UpdateStartDateForIterationsCadences < Gitlab::Database::Migration[2.0] - include ::Gitlab::Database::DynamicModelHelpers - - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - def up - each_batch_range('iterations_cadences', connection: connection) do |min, max| - execute(<<~SQL) - UPDATE iterations_cadences - SET start_date=ic.first_upcoming_iteration_start_date - FROM ( - SELECT ic.id, sprints2.first_upcoming_iteration_start_date - FROM iterations_cadences as ic, - LATERAL ( - -- For each cadence, query for the due date of its current iteration - SELECT due_date as current_iteration_due_date FROM sprints - WHERE iterations_cadence_id=ic.id AND start_date <= current_date AND due_date >= current_date - LIMIT 1 - ) as sprints1, - LATERAL ( - -- For each cadence, query for the start date of the first upcoming iteration (i.e, it starts after the current iteration) - SELECT start_date as first_upcoming_iteration_start_date FROM sprints - WHERE iterations_cadence_id=ic.id AND start_date > sprints1.current_iteration_due_date - ORDER BY start_date ASC LIMIT 1 - ) as sprints2 - WHERE ic.automatic=true AND ic.id BETWEEN #{min} AND #{max} - ) as ic - WHERE iterations_cadences.id=ic.id; - SQL - end - end - - def down - each_batch_range('iterations_cadences', connection: connection) do |min, max| - execute(<<~SQL) - UPDATE iterations_cadences - SET start_date=ic.first_iteration_start_date - FROM ( - SELECT ic.id, sprints.start_date as first_iteration_start_date - FROM iterations_cadences as ic, - LATERAL ( - SELECT start_date FROM sprints WHERE iterations_cadence_id=ic.id ORDER BY start_date ASC LIMIT 1 - ) as sprints - WHERE ic.automatic=true AND ic.id BETWEEN #{min} AND #{max} - ) as ic - WHERE iterations_cadences.id=ic.id; - SQL - end - end -end diff --git a/db/post_migrate/20220820221036_update_tmp_non_migrated_index_on_container_repositories.rb b/db/post_migrate/20220820221036_update_tmp_non_migrated_index_on_container_repositories.rb deleted file mode 100644 index eea58ad7951..00000000000 --- a/db/post_migrate/20220820221036_update_tmp_non_migrated_index_on_container_repositories.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class UpdateTmpNonMigratedIndexOnContainerRepositories < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'tmp_index_container_repos_on_non_migrated' - OLD_INDEX_NAME = 'tmp_idx_container_repos_on_non_migrated' - MIGRATION_PHASE_1_ENDED_AT = '2022-01-23' - - def up - add_concurrent_index :container_repositories, - [:project_id, :id], - name: NEW_INDEX_NAME, - where: "migration_state != 'import_done'" - remove_concurrent_index_by_name :container_repositories, OLD_INDEX_NAME - end - - def down - add_concurrent_index :container_repositories, - [:project_id, :id], - name: OLD_INDEX_NAME, - where: "migration_state != 'import_done' AND created_at < '#{MIGRATION_PHASE_1_ENDED_AT}'" - remove_concurrent_index_by_name :container_repositories, NEW_INDEX_NAME - end -end diff --git a/db/post_migrate/20220822071909_remove_other_role_from_user_details.rb b/db/post_migrate/20220822071909_remove_other_role_from_user_details.rb deleted file mode 100644 index a0177bf2605..00000000000 --- a/db/post_migrate/20220822071909_remove_other_role_from_user_details.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class RemoveOtherRoleFromUserDetails < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :user_details, :other_role, :text - end -end diff --git a/db/post_migrate/20220822090656_drop_build_coverage_regex_from_project.rb b/db/post_migrate/20220822090656_drop_build_coverage_regex_from_project.rb deleted file mode 100644 index 70c6b660318..00000000000 --- a/db/post_migrate/20220822090656_drop_build_coverage_regex_from_project.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class DropBuildCoverageRegexFromProject < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def up - remove_column :projects, :build_coverage_regex - end - - def down - add_column :projects, :build_coverage_regex, :string # rubocop: disable Migration/AddColumnsToWideTables - end -end diff --git a/db/post_migrate/20220822094804_add_issues_authorization_index.rb b/db/post_migrate/20220822094804_add_issues_authorization_index.rb deleted file mode 100644 index e09b5f8d93b..00000000000 --- a/db/post_migrate/20220822094804_add_issues_authorization_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIssuesAuthorizationIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'idx_open_issues_on_project_and_confidential_and_author_and_id' - - def up - prepare_async_index :issues, [:project_id, :confidential, :author_id, :id], name: INDEX_NAME, where: 'state_id = 1' - end - - def down - unprepare_async_index :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20220823084747_prepare_removal_partial_trigram_indexes_for_issues.rb b/db/post_migrate/20220823084747_prepare_removal_partial_trigram_indexes_for_issues.rb deleted file mode 100644 index a8ea6abdcba..00000000000 --- a/db/post_migrate/20220823084747_prepare_removal_partial_trigram_indexes_for_issues.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class PrepareRemovalPartialTrigramIndexesForIssues < Gitlab::Database::Migration[2.0] - TITLE_INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - def up - prepare_async_index_removal :issues, :title, name: TITLE_INDEX_NAME - prepare_async_index_removal :issues, :description, name: DESCRIPTION_INDEX_NAME - end - - def down - unprepare_async_index_by_name :issues, DESCRIPTION_INDEX_NAME - unprepare_async_index_by_name :issues, TITLE_INDEX_NAME - end -end diff --git a/db/post_migrate/20220824114218_add_tmp_index_approval_merge_request_rules.rb b/db/post_migrate/20220824114218_add_tmp_index_approval_merge_request_rules.rb deleted file mode 100644 index 64171b3053e..00000000000 --- a/db/post_migrate/20220824114218_add_tmp_index_approval_merge_request_rules.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexApprovalMergeRequestRules < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TMP_INDEX_NAME = 'tmp_index_approval_merge_request_rules_on_report_type_equal_one' - - def up - # to be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/372224 - add_concurrent_index :approval_merge_request_rules, - [:id, :report_type], - name: TMP_INDEX_NAME, - where: "report_type = 1" - end - - def down - remove_concurrent_index_by_name :approval_merge_request_rules, TMP_INDEX_NAME - end -end diff --git a/db/post_migrate/20220825061250_drop_tmp_index_todos_attention_request_action_idx.rb b/db/post_migrate/20220825061250_drop_tmp_index_todos_attention_request_action_idx.rb deleted file mode 100644 index 091de49e1c9..00000000000 --- a/db/post_migrate/20220825061250_drop_tmp_index_todos_attention_request_action_idx.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class DropTmpIndexTodosAttentionRequestActionIdx < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_todos_attention_request_action" - ATTENTION_REQUESTED = 10 - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :todos, INDEX_NAME - end - - def down - add_concurrent_index :todos, [:id], - where: "action = #{ATTENTION_REQUESTED}", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220825142324_replace_issues_authorization_index.rb b/db/post_migrate/20220825142324_replace_issues_authorization_index.rb deleted file mode 100644 index b033cb22490..00000000000 --- a/db/post_migrate/20220825142324_replace_issues_authorization_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class ReplaceIssuesAuthorizationIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'idx_open_issues_on_project_and_confidential_and_author_and_id' - OLD_INDEX_NAME = 'idx_open_issues_on_project_id_and_confidential' - - def up - add_concurrent_index :issues, [:project_id, :confidential, :author_id, :id], name: INDEX_NAME, where: 'state_id = 1' - remove_concurrent_index_by_name :issues, OLD_INDEX_NAME - end - - def down - add_concurrent_index :issues, [:project_id, :confidential], name: OLD_INDEX_NAME, where: 'state_id = 1' - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20220826165048_drop_temporary_job_trace_index.rb b/db/post_migrate/20220826165048_drop_temporary_job_trace_index.rb deleted file mode 100644 index 0cad7cd1968..00000000000 --- a/db/post_migrate/20220826165048_drop_temporary_job_trace_index.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class DropTemporaryJobTraceIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_where_trace_and_expire_at' - - def up - prepare_async_index_removal :ci_job_artifacts, :id, name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :ci_job_artifacts, INDEX_NAME - end -end diff --git a/db/post_migrate/20220826175058_fully_remove_temporary_job_trace_index.rb b/db/post_migrate/20220826175058_fully_remove_temporary_job_trace_index.rb deleted file mode 100644 index 2a18e63106a..00000000000 --- a/db/post_migrate/20220826175058_fully_remove_temporary_job_trace_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class FullyRemoveTemporaryJobTraceIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_where_trace_and_expire_at' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :ci_job_artifacts, name: INDEX_NAME - end - - def down - add_concurrent_index :ci_job_artifacts, :id, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220830051704_add_temporary_index_for_orphaned_invited_members.rb b/db/post_migrate/20220830051704_add_temporary_index_for_orphaned_invited_members.rb deleted file mode 100644 index 90254ac3d86..00000000000 --- a/db/post_migrate/20220830051704_add_temporary_index_for_orphaned_invited_members.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddTemporaryIndexForOrphanedInvitedMembers < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TMP_INDEX_NAME = 'tmp_idx_orphaned_invited_members' - - def up - add_concurrent_index('members', :id, where: query_condition, name: TMP_INDEX_NAME) - end - - def down - remove_concurrent_index_by_name('members', TMP_INDEX_NAME) if index_exists_by_name?('members', TMP_INDEX_NAME) - end - - private - - def query_condition - 'invite_token IS NULL and invite_accepted_at IS NOT NULL AND user_id IS NULL' - end -end diff --git a/db/post_migrate/20220830061704_orphaned_invited_members_cleanup.rb b/db/post_migrate/20220830061704_orphaned_invited_members_cleanup.rb deleted file mode 100644 index c5249510164..00000000000 --- a/db/post_migrate/20220830061704_orphaned_invited_members_cleanup.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class OrphanedInvitedMembersCleanup < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # rubocop:disable Style/SymbolProc - membership.where(query_condition).each_batch(of: 100) do |relation| - relation.delete_all - end - # rubocop:enable Style/SymbolProc - end - - def down - # This migration is irreversible - end - - private - - def membership - @membership ||= define_batchable_model('members') - end - - def query_condition - 'invite_token IS NULL and invite_accepted_at IS NOT NULL AND user_id IS NULL' - end -end diff --git a/db/post_migrate/20220830071704_remove_temporary_index_for_orphaned_invited_members.rb b/db/post_migrate/20220830071704_remove_temporary_index_for_orphaned_invited_members.rb deleted file mode 100644 index c6b712da4c0..00000000000 --- a/db/post_migrate/20220830071704_remove_temporary_index_for_orphaned_invited_members.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveTemporaryIndexForOrphanedInvitedMembers < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TMP_INDEX_NAME = 'tmp_idx_orphaned_invited_members' - - def up - remove_concurrent_index_by_name('members', TMP_INDEX_NAME) if index_exists_by_name?('members', TMP_INDEX_NAME) - end - - def down - add_concurrent_index('members', :id, where: query_condition, name: TMP_INDEX_NAME) - end - - private - - def query_condition - 'invite_token IS NULL and invite_accepted_at IS NOT NULL AND user_id IS NULL' - end -end diff --git a/db/post_migrate/20220830172142_reschedule_issue_work_item_type_id_backfill.rb b/db/post_migrate/20220830172142_reschedule_issue_work_item_type_id_backfill.rb deleted file mode 100644 index 5495f0e53b4..00000000000 --- a/db/post_migrate/20220830172142_reschedule_issue_work_item_type_id_backfill.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class RescheduleIssueWorkItemTypeIdBackfill < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillWorkItemTypeIdForIssues' - BATCH_SIZE = 10_000 - MAX_BATCH_SIZE = 30_000 - SUB_BATCH_SIZE = 100 - INTERVAL = 1.minute - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class MigrationWorkItemType < MigrationRecord - self.table_name = 'work_item_types' - - def self.id_by_type - where(namespace_id: nil).order(:base_type).pluck(:base_type, :id).to_h - end - end - - def up - # We expect no more than 5 types. Only 3 of them are expected to have associated issues at the moment - MigrationWorkItemType.id_by_type.each do |base_type, type_id| - queue_batched_background_migration( - MIGRATION, - :issues, - :id, - base_type, - type_id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - end - - def down - Gitlab::Database::BackgroundMigration::BatchedMigration.where(job_class_name: MIGRATION).delete_all - end -end diff --git a/db/post_migrate/20220831021358_add_index_on_issue_health_status.rb b/db/post_migrate/20220831021358_add_index_on_issue_health_status.rb deleted file mode 100644 index 940bf6b5c38..00000000000 --- a/db/post_migrate/20220831021358_add_index_on_issue_health_status.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnIssueHealthStatus < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = :issues - INDEX_NAME = 'index_issues_on_project_id_health_status_created_at_id' - - def up - add_concurrent_index TABLE_NAME, [:project_id, :health_status, :created_at, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index TABLE_NAME, [:project_id, :health_status, :created_at, :id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220831090454_cleanup_web_hooks_service_id.rb b/db/post_migrate/20220831090454_cleanup_web_hooks_service_id.rb deleted file mode 100644 index 7beb89038e5..00000000000 --- a/db/post_migrate/20220831090454_cleanup_web_hooks_service_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupWebHooksServiceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :web_hooks, :service_id, :integration_id - end - - def down - undo_cleanup_concurrent_column_rename :web_hooks, :service_id, :integration_id - end -end diff --git a/db/post_migrate/20220831132802_delete_approval_rules_for_vulnerability.rb b/db/post_migrate/20220831132802_delete_approval_rules_for_vulnerability.rb deleted file mode 100644 index b29678f1826..00000000000 --- a/db/post_migrate/20220831132802_delete_approval_rules_for_vulnerability.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -class DeleteApprovalRulesForVulnerability < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - BATCH_SIZE = 500 - MAX_BATCH_SIZE = 1_000 - SUB_BATCH_SIZE = 10 - MIGRATION = 'DeleteApprovalRulesWithVulnerability' - INTERVAL = 2.minutes - - def up - return unless Gitlab.ee? - - queue_batched_background_migration( - MIGRATION, - :approval_project_rules, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - - queue_batched_background_migration( - MIGRATION, - :approval_merge_request_rules, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - # the data deleted is related to a feature removed in 15.0: https://gitlab.com/gitlab-org/gitlab/-/issues/357300 - delete_batched_background_migration(MIGRATION, :approval_project_rules, :id, []) - delete_batched_background_migration(MIGRATION, :approval_merge_request_rules, :id, []) - end -end diff --git a/db/post_migrate/20220901035725_schedule_destroy_invalid_project_members.rb b/db/post_migrate/20220901035725_schedule_destroy_invalid_project_members.rb deleted file mode 100644 index 9de3ac34669..00000000000 --- a/db/post_migrate/20220901035725_schedule_destroy_invalid_project_members.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDestroyInvalidProjectMembers < Gitlab::Database::Migration[2.0] - MIGRATION = 'DestroyInvalidProjectMembers' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 50_000 - MAX_BATCH_SIZE = 100_000 - SUB_BATCH_SIZE = 200 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # no-op - # We want to no-op this due to potential inconsistencies in SM upgrade path - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220901071310_add_tmp_index_user_callouts_on_attention_request_feature_names.rb b/db/post_migrate/20220901071310_add_tmp_index_user_callouts_on_attention_request_feature_names.rb deleted file mode 100644 index 10b339b90c1..00000000000 --- a/db/post_migrate/20220901071310_add_tmp_index_user_callouts_on_attention_request_feature_names.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_user_callouts_on_attention_request_feature_names" - ATTENTION_REQUEST_CALLOUTS = [47, 48] - - disable_ddl_transaction! - - def up - add_concurrent_index :user_callouts, [:id], - where: "feature_name IN (#{ATTENTION_REQUEST_CALLOUTS.join(',')})", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :user_callouts, INDEX_NAME - end -end diff --git a/db/post_migrate/20220901071355_cleanup_attention_request_user_callouts.rb b/db/post_migrate/20220901071355_cleanup_attention_request_user_callouts.rb deleted file mode 100644 index cbd0d120bb8..00000000000 --- a/db/post_migrate/20220901071355_cleanup_attention_request_user_callouts.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true -class CleanupAttentionRequestUserCallouts < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - ATTENTION_REQUEST_CALLOUTS = [47, 48] - # 47 and 48 were removed with https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95446 - - def up - define_batchable_model('user_callouts') - .where(feature_name: ATTENTION_REQUEST_CALLOUTS) - .each_batch { |batch| batch.delete_all } # rubocop:disable Style/SymbolProc - end - - def down - # Attention request feature has been reverted. - end -end diff --git a/db/post_migrate/20220901073300_remove_partial_trigram_indexes_for_issues.rb b/db/post_migrate/20220901073300_remove_partial_trigram_indexes_for_issues.rb deleted file mode 100644 index 096b74bc1c6..00000000000 --- a/db/post_migrate/20220901073300_remove_partial_trigram_indexes_for_issues.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class RemovePartialTrigramIndexesForIssues < Gitlab::Database::Migration[2.0] - TITLE_INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :issues, TITLE_INDEX_NAME - remove_concurrent_index_by_name :issues, DESCRIPTION_INDEX_NAME - end - - def down - add_concurrent_index :issues, :title, - name: TITLE_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'" - - add_concurrent_index :issues, :description, - name: DESCRIPTION_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'" - end -end diff --git a/db/post_migrate/20220901184106_add_not_null_to_board_group_recent_visits.rb b/db/post_migrate/20220901184106_add_not_null_to_board_group_recent_visits.rb deleted file mode 100644 index 1dead32efb6..00000000000 --- a/db/post_migrate/20220901184106_add_not_null_to_board_group_recent_visits.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullToBoardGroupRecentVisits < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_not_null_constraint :board_group_recent_visits, :user_id, validate: false - add_not_null_constraint :board_group_recent_visits, :group_id, validate: false - add_not_null_constraint :board_group_recent_visits, :board_id, validate: false - end - - def down - remove_not_null_constraint :board_group_recent_visits, :user_id - remove_not_null_constraint :board_group_recent_visits, :board_id - remove_not_null_constraint :board_group_recent_visits, :group_id - end -end diff --git a/db/post_migrate/20220901184246_add_not_null_to_board_project_recent_visits.rb b/db/post_migrate/20220901184246_add_not_null_to_board_project_recent_visits.rb deleted file mode 100644 index 4f0cb4d3d68..00000000000 --- a/db/post_migrate/20220901184246_add_not_null_to_board_project_recent_visits.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullToBoardProjectRecentVisits < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_not_null_constraint :board_project_recent_visits, :user_id, validate: false - add_not_null_constraint :board_project_recent_visits, :project_id, validate: false - add_not_null_constraint :board_project_recent_visits, :board_id, validate: false - end - - def down - remove_not_null_constraint :board_project_recent_visits, :user_id - remove_not_null_constraint :board_project_recent_visits, :project_id - remove_not_null_constraint :board_project_recent_visits, :board_id - end -end diff --git a/db/post_migrate/20220902111016_delete_null_records_from_board_group_recent_visits.rb b/db/post_migrate/20220902111016_delete_null_records_from_board_group_recent_visits.rb deleted file mode 100644 index 4b55ecc013d..00000000000 --- a/db/post_migrate/20220902111016_delete_null_records_from_board_group_recent_visits.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DeleteNullRecordsFromBoardGroupRecentVisits < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - execute('DELETE FROM board_group_recent_visits WHERE user_id is null OR group_id is null OR board_id is null') - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220902111038_delete_null_records_from_board_project_recent_visits.rb b/db/post_migrate/20220902111038_delete_null_records_from_board_project_recent_visits.rb deleted file mode 100644 index bb261f80f73..00000000000 --- a/db/post_migrate/20220902111038_delete_null_records_from_board_project_recent_visits.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DeleteNullRecordsFromBoardProjectRecentVisits < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - execute('DELETE FROM board_project_recent_visits WHERE user_id is null OR project_id is null OR board_id is null') - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220902204048_move_security_findings_table_to_gitlab_partitions_dynamic_schema.rb b/db/post_migrate/20220902204048_move_security_findings_table_to_gitlab_partitions_dynamic_schema.rb deleted file mode 100644 index 62511e0e616..00000000000 --- a/db/post_migrate/20220902204048_move_security_findings_table_to_gitlab_partitions_dynamic_schema.rb +++ /dev/null @@ -1,230 +0,0 @@ -# frozen_string_literal: true - -# rubocop:disable Migration/WithLockRetriesDisallowedMethod -class MoveSecurityFindingsTableToGitlabPartitionsDynamicSchema < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_MAPPING_OF_PARTITION = { - index_security_findings_on_unique_columns: :security_findings_1_uuid_scan_id_partition_number_idx, - index_security_findings_on_confidence: :security_findings_1_confidence_idx, - index_security_findings_on_project_fingerprint: :security_findings_1_project_fingerprint_idx, - index_security_findings_on_scan_id_and_deduplicated: :security_findings_1_scan_id_deduplicated_idx, - index_security_findings_on_scan_id_and_id: :security_findings_1_scan_id_id_idx, - index_security_findings_on_scanner_id: :security_findings_1_scanner_id_idx, - index_security_findings_on_severity: :security_findings_1_severity_idx - }.freeze - - INDEX_MAPPING_AFTER_CREATING_FROM_PARTITION = { - partition_name_placeholder_pkey: :security_findings_pkey, - partition_name_placeholder_uuid_scan_id_partition_number_idx: :index_security_findings_on_unique_columns, - partition_name_placeholder_confidence_idx: :index_security_findings_on_confidence, - partition_name_placeholder_project_fingerprint_idx: :index_security_findings_on_project_fingerprint, - partition_name_placeholder_scan_id_deduplicated_idx: :index_security_findings_on_scan_id_and_deduplicated, - partition_name_placeholder_scan_id_id_idx: :index_security_findings_on_scan_id_and_id, - partition_name_placeholder_scanner_id_idx: :index_security_findings_on_scanner_id, - partition_name_placeholder_severity_idx: :index_security_findings_on_severity - }.freeze - - INDEX_MAPPING_AFTER_CREATING_FROM_ITSELF = { - security_findings_pkey1: :security_findings_pkey, - security_findings_uuid_scan_id_partition_number_idx1: :index_security_findings_on_unique_columns, - security_findings_confidence_idx1: :index_security_findings_on_confidence, - security_findings_project_fingerprint_idx1: :index_security_findings_on_project_fingerprint, - security_findings_scan_id_deduplicated_idx1: :index_security_findings_on_scan_id_and_deduplicated, - security_findings_scan_id_id_idx1: :index_security_findings_on_scan_id_and_id, - security_findings_scanner_id_idx1: :index_security_findings_on_scanner_id, - security_findings_severity_idx1: :index_security_findings_on_severity - }.freeze - - LATEST_PARTITION_SQL = <<~SQL - SELECT - partitions.relname AS partition_name - FROM pg_inherits - JOIN pg_class parent ON pg_inherits.inhparent = parent.oid - JOIN pg_class partitions ON pg_inherits.inhrelid = partitions.oid - WHERE - parent.relname = 'security_findings' - ORDER BY (regexp_matches(partitions.relname, 'security_findings_(\\d+)'))[1]::int DESC - LIMIT 1 - SQL - - CURRENT_CHECK_CONSTRAINT_SQL = <<~SQL - SELECT - pg_get_constraintdef(pg_catalog.pg_constraint.oid) - FROM - pg_catalog.pg_constraint - INNER JOIN pg_class ON pg_class.oid = pg_catalog.pg_constraint.conrelid - WHERE - conname = 'check_partition_number' AND - pg_class.relname = 'security_findings' - SQL - - def up - with_lock_retries do - lock_tables - - execute(<<~SQL) - ALTER TABLE security_findings RENAME TO security_findings_#{candidate_partition_number}; - SQL - - execute(<<~SQL) - ALTER INDEX security_findings_pkey RENAME TO security_findings_#{candidate_partition_number}_pkey; - SQL - - execute(<<~SQL) - CREATE TABLE security_findings ( - LIKE security_findings_#{candidate_partition_number} INCLUDING ALL - ) PARTITION BY LIST (partition_number); - SQL - - execute(<<~SQL) - ALTER SEQUENCE security_findings_id_seq OWNED BY #{connection.current_schema}.security_findings.id; - SQL - - execute(<<~SQL) - ALTER TABLE security_findings - ADD CONSTRAINT fk_rails_729b763a54 FOREIGN KEY (scanner_id) REFERENCES vulnerability_scanners(id) ON DELETE CASCADE; - SQL - - execute(<<~SQL) - ALTER TABLE security_findings - ADD CONSTRAINT fk_rails_bb63863cf1 FOREIGN KEY (scan_id) REFERENCES security_scans(id) ON DELETE CASCADE; - SQL - - execute(<<~SQL) - ALTER TABLE security_findings_#{candidate_partition_number} SET SCHEMA gitlab_partitions_dynamic; - SQL - - execute(<<~SQL) - ALTER TABLE security_findings ATTACH PARTITION gitlab_partitions_dynamic.security_findings_#{candidate_partition_number} FOR VALUES IN (#{candidate_partition_number}); - SQL - - execute(<<~SQL) - ALTER TABLE security_findings DROP CONSTRAINT check_partition_number; - SQL - - index_mapping = INDEX_MAPPING_OF_PARTITION.transform_values do |value| - value.to_s.sub('partition_name_placeholder', "security_findings_#{candidate_partition_number}") - end - - rename_indices('gitlab_partitions_dynamic', index_mapping) - end - end - - def down - # If there is already a partition for the `security_findings` table, - # we can promote that table to be the original one to save the data. - # Otherwise, we have to bring back the non-partitioned `security_findings` - # table from the partitioned one. - if latest_partition - create_non_partitioned_security_findings_with_data - else - create_non_partitioned_security_findings_without_data - end - end - - private - - def lock_tables - execute(<<~SQL) - LOCK TABLE vulnerability_scanners, security_scans, security_findings IN ACCESS EXCLUSIVE MODE - SQL - end - - def current_check_constraint - execute(CURRENT_CHECK_CONSTRAINT_SQL).first['pg_get_constraintdef'] - end - - def candidate_partition_number - @candidate_partition_number ||= current_check_constraint.match(/partition_number\s?=\s?(\d+)/).captures.first - end - - def latest_partition - @latest_partition ||= execute(LATEST_PARTITION_SQL).first&.fetch('partition_name', nil) - end - - def latest_partition_number - latest_partition.match(/security_findings_(\d+)/).captures.first - end - - def create_non_partitioned_security_findings_with_data - with_lock_retries do - lock_tables - - execute(<<~SQL) - ALTER TABLE security_findings DETACH PARTITION gitlab_partitions_dynamic.#{latest_partition}; - SQL - - execute(<<~SQL) - ALTER TABLE gitlab_partitions_dynamic.#{latest_partition} SET SCHEMA #{connection.current_schema}; - SQL - - execute(<<~SQL) - ALTER SEQUENCE security_findings_id_seq OWNED BY #{latest_partition}.id; - SQL - - execute(<<~SQL) - DROP TABLE security_findings; - SQL - - execute(<<~SQL) - ALTER TABLE #{latest_partition} RENAME TO security_findings; - SQL - - index_mapping = INDEX_MAPPING_AFTER_CREATING_FROM_PARTITION.transform_keys do |key| - key.to_s.sub('partition_name_placeholder', latest_partition) - end - - rename_indices(connection.current_schema, index_mapping) - end - - add_check_constraint(:security_findings, "(partition_number = #{latest_partition_number})", :check_partition_number) - end - - def create_non_partitioned_security_findings_without_data - with_lock_retries do - lock_tables - - execute(<<~SQL) - ALTER TABLE security_findings RENAME TO security_findings_1; - SQL - - execute(<<~SQL) - CREATE TABLE security_findings ( - LIKE security_findings_1 INCLUDING ALL - ); - SQL - - execute(<<~SQL) - ALTER SEQUENCE security_findings_id_seq OWNED BY #{connection.current_schema}.security_findings.id; - SQL - - execute(<<~SQL) - DROP TABLE security_findings_1; - SQL - - execute(<<~SQL) - ALTER TABLE ONLY security_findings - ADD CONSTRAINT fk_rails_729b763a54 FOREIGN KEY (scanner_id) REFERENCES vulnerability_scanners(id) ON DELETE CASCADE; - SQL - - execute(<<~SQL) - ALTER TABLE ONLY security_findings - ADD CONSTRAINT fk_rails_bb63863cf1 FOREIGN KEY (scan_id) REFERENCES security_scans(id) ON DELETE CASCADE; - SQL - - rename_indices(connection.current_schema, INDEX_MAPPING_AFTER_CREATING_FROM_ITSELF) - end - - add_check_constraint(:security_findings, "(partition_number = 1)", :check_partition_number) - end - - def rename_indices(schema, mapping) - mapping.each do |index_name, new_index_name| - execute(<<~SQL) - ALTER INDEX #{schema}.#{index_name} RENAME TO #{new_index_name}; - SQL - end - end -end -# rubocop:enable Migration/WithLockRetriesDisallowedMethod diff --git a/db/post_migrate/20220904173342_validate_not_null_constraint_board_group_recent_visits.rb b/db/post_migrate/20220904173342_validate_not_null_constraint_board_group_recent_visits.rb deleted file mode 100644 index 0e5a504d0eb..00000000000 --- a/db/post_migrate/20220904173342_validate_not_null_constraint_board_group_recent_visits.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ValidateNotNullConstraintBoardGroupRecentVisits < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - validate_not_null_constraint :board_group_recent_visits, :user_id - validate_not_null_constraint :board_group_recent_visits, :group_id - validate_not_null_constraint :board_group_recent_visits, :board_id - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220904173430_validate_not_null_constraint_board_project_recent_visits.rb b/db/post_migrate/20220904173430_validate_not_null_constraint_board_project_recent_visits.rb deleted file mode 100644 index ff73a179f69..00000000000 --- a/db/post_migrate/20220904173430_validate_not_null_constraint_board_project_recent_visits.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ValidateNotNullConstraintBoardProjectRecentVisits < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - validate_not_null_constraint :board_project_recent_visits, :user_id - validate_not_null_constraint :board_project_recent_visits, :project_id - validate_not_null_constraint :board_project_recent_visits, :board_id - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220905090300_add_tmp_index_merge_request_reviewers_attention_request_state.rb b/db/post_migrate/20220905090300_add_tmp_index_merge_request_reviewers_attention_request_state.rb deleted file mode 100644 index e192f76484c..00000000000 --- a/db/post_migrate/20220905090300_add_tmp_index_merge_request_reviewers_attention_request_state.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexMergeRequestReviewersAttentionRequestState < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_merge_request_reviewers_on_attention_requested_state" - ATTENTION_REQUESTED_STATE = 2 - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_request_reviewers, [:id], - where: "state = #{ATTENTION_REQUESTED_STATE}", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :merge_request_reviewers, INDEX_NAME - end -end diff --git a/db/post_migrate/20220905090339_reset_attention_requested_merge_requests_reviewers_state_to_unreviewed.rb b/db/post_migrate/20220905090339_reset_attention_requested_merge_requests_reviewers_state_to_unreviewed.rb deleted file mode 100644 index d335095e674..00000000000 --- a/db/post_migrate/20220905090339_reset_attention_requested_merge_requests_reviewers_state_to_unreviewed.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class ResetAttentionRequestedMergeRequestsReviewersStateToUnreviewed < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 500 - - class MergeRequestReviewer < MigrationRecord - self.table_name = 'merge_request_reviewers' - - enum state: { - unreviewed: 0, - reviewed: 1, - attention_requested: 2 - } - - include ::EachBatch - end - - def up - MergeRequestReviewer - .where(state: MergeRequestReviewer.states['attention_requested']) - .each_batch(of: BATCH_SIZE) { |batch| batch.update_all(state: MergeRequestReviewer.states['unreviewed']) } - end - - def down - # no op - end -end diff --git a/db/post_migrate/20220905112710_add_async_index_to_todos_to_cover_pending_query.rb b/db/post_migrate/20220905112710_add_async_index_to_todos_to_cover_pending_query.rb deleted file mode 100644 index e2bca2fae1a..00000000000 --- a/db/post_migrate/20220905112710_add_async_index_to_todos_to_cover_pending_query.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexToTodosToCoverPendingQuery < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_on_todos_user_project_target_and_state' - COLUMNS = %i[user_id project_id target_type target_id id].freeze - - def up - prepare_async_index :todos, COLUMNS, name: INDEX_NAME, where: "state = 'pending'" - end - - def down - unprepare_async_index :todos, COLUMNS, name: INDEX_NAME, where: "state='pending'" - end -end diff --git a/db/post_migrate/20220905120848_backfill_epic_cache_counts.rb b/db/post_migrate/20220905120848_backfill_epic_cache_counts.rb deleted file mode 100644 index 32fe04eb99c..00000000000 --- a/db/post_migrate/20220905120848_backfill_epic_cache_counts.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class BackfillEpicCacheCounts < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillEpicCacheCounts' - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 200 - MAX_BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 20 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :epics, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE, - gitlab_schema: :gitlab_main - ) - end - - def down - delete_batched_background_migration(MIGRATION, :epics, :id, []) - end -end diff --git a/db/post_migrate/20220906074449_schedule_disable_legacy_open_source_license_for_projects_less_than_one_mb.rb b/db/post_migrate/20220906074449_schedule_disable_legacy_open_source_license_for_projects_less_than_one_mb.rb deleted file mode 100644 index ee48ace13e0..00000000000 --- a/db/post_migrate/20220906074449_schedule_disable_legacy_open_source_license_for_projects_less_than_one_mb.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanOneMb < Gitlab::Database::Migration[2.0] - MIGRATION = 'DisableLegacyOpenSourceLicenseForProjectsLessThanOneMb' - INTERVAL = 2.minutes - BATCH_SIZE = 4_000 - MAX_BATCH_SIZE = 50_000 - SUB_BATCH_SIZE = 250 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - return unless Gitlab.com? - - queue_batched_background_migration( - MIGRATION, - :project_settings, - :project_id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.com? - - delete_batched_background_migration(MIGRATION, :project_settings, :project_id, []) - end -end diff --git a/db/post_migrate/20220906212931_add_partial_index_for_ci_pipeline_artifacts_unlocked_with_expire_at.rb b/db/post_migrate/20220906212931_add_partial_index_for_ci_pipeline_artifacts_unlocked_with_expire_at.rb deleted file mode 100644 index a24187dd56b..00000000000 --- a/db/post_migrate/20220906212931_add_partial_index_for_ci_pipeline_artifacts_unlocked_with_expire_at.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddPartialIndexForCiPipelineArtifactsUnlockedWithExpireAt < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = 'ci_pipeline_artifacts' - INDEX_NAME = 'ci_pipeline_artifacts_on_expire_at_for_removal' - CONDITIONS = 'locked = 0 AND expire_at IS NOT NULL' - - def up - add_concurrent_index TABLE_NAME, [:expire_at], where: CONDITIONS, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME - end -end diff --git a/db/post_migrate/20220907122648_populate_security_orchestration_policy_configuration_id.rb b/db/post_migrate/20220907122648_populate_security_orchestration_policy_configuration_id.rb deleted file mode 100644 index 441113c0ba3..00000000000 --- a/db/post_migrate/20220907122648_populate_security_orchestration_policy_configuration_id.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -class PopulateSecurityOrchestrationPolicyConfigurationId < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 500 - MERGE_REQUEST_MIGRATION = 'PopulateApprovalMergeRequestRulesWithSecurityOrchestration' - PROJECT_MIGRATION = 'PopulateApprovalProjectRulesWithSecurityOrchestration' - INTERVAL = 2.minutes - - def up - return unless Gitlab.ee? - - queue_batched_background_migration( - PROJECT_MIGRATION, - :approval_project_rules, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - - queue_batched_background_migration( - MERGE_REQUEST_MIGRATION, - :approval_merge_request_rules, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(PROJECT_MIGRATION, :approval_project_rules, :id, []) - delete_batched_background_migration(MERGE_REQUEST_MIGRATION, :approval_merge_request_rules, :id, []) - end -end diff --git a/db/post_migrate/20220908125146_remove_free_user_cap_remediation_worker.rb b/db/post_migrate/20220908125146_remove_free_user_cap_remediation_worker.rb deleted file mode 100644 index e95ea9c58b4..00000000000 --- a/db/post_migrate/20220908125146_remove_free_user_cap_remediation_worker.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveFreeUserCapRemediationWorker < Gitlab::Database::Migration[2.0] - def up - Sidekiq::Cron::Job.find('free_user_cap_data_remediation')&.destroy - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220909114220_drop_environments_project_name_lower_pattern_ops_index.rb b/db/post_migrate/20220909114220_drop_environments_project_name_lower_pattern_ops_index.rb deleted file mode 100644 index 3ab71809039..00000000000 --- a/db/post_migrate/20220909114220_drop_environments_project_name_lower_pattern_ops_index.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# reverts db/migrate/20220901131828_add_environments_project_name_lower_pattern_ops_index.rb -class DropEnvironmentsProjectNameLowerPatternOpsIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_environments_on_project_name_varchar_pattern_ops' - - def up - remove_concurrent_index_by_name :environments, INDEX_NAME - end - - def down - add_concurrent_index :environments, 'project_id, lower(name) varchar_pattern_ops', name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220912085047_add_index_to_todos_pending_query.rb b/db/post_migrate/20220912085047_add_index_to_todos_pending_query.rb deleted file mode 100644 index 7d721421463..00000000000 --- a/db/post_migrate/20220912085047_add_index_to_todos_pending_query.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToTodosPendingQuery < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_on_todos_user_project_target_and_state' - COLUMNS = %i[user_id project_id target_type target_id id].freeze - - def up - add_concurrent_index :todos, COLUMNS, name: INDEX_NAME, where: "state = 'pending'" - end - - def down - remove_concurrent_index_by_name :todos, INDEX_NAME - end -end diff --git a/db/post_migrate/20220912110433_prepare_create_internal_notes_index_on_id.rb b/db/post_migrate/20220912110433_prepare_create_internal_notes_index_on_id.rb deleted file mode 100644 index 241bdfa4715..00000000000 --- a/db/post_migrate/20220912110433_prepare_create_internal_notes_index_on_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class PrepareCreateInternalNotesIndexOnId < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_notes_on_id_where_internal' - - def up - prepare_async_index :notes, :id, where: 'internal = true', name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :notes, INDEX_NAME - end -end diff --git a/db/post_migrate/20220913030552_add_tmp_index_system_note_metadata_on_attention_request_actions.rb b/db/post_migrate/20220913030552_add_tmp_index_system_note_metadata_on_attention_request_actions.rb deleted file mode 100644 index 3418dabc0e9..00000000000 --- a/db/post_migrate/20220913030552_add_tmp_index_system_note_metadata_on_attention_request_actions.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexSystemNoteMetadataOnAttentionRequestActions < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_system_note_metadata_on_attention_request_actions" - - disable_ddl_transaction! - - def up - add_concurrent_index :system_note_metadata, [:id], - where: "action IN ('attention_requested', 'attention_request_removed')", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :system_note_metadata, INDEX_NAME - end -end diff --git a/db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb b/db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb deleted file mode 100644 index b7d6908696b..00000000000 --- a/db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class CleanupAttentionRequestRelatedSystemNotes < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 100 - - class SystemNoteMetadata < MigrationRecord - include EachBatch - - self.table_name = 'system_note_metadata' - end - - class Note < MigrationRecord - self.table_name = 'notes' - end - - def up - SystemNoteMetadata - .where(action: %w[attention_requested attention_request_removed]) - .each_batch(of: BATCH_SIZE) do |batch| - Note.where(id: batch.pluck(:note_id)).delete_all - end - end - - def down - # no op - end -end diff --git a/db/post_migrate/20220913083015_clean_up_rename_iterations_cadences_last_run_date_to_next_run_date.rb b/db/post_migrate/20220913083015_clean_up_rename_iterations_cadences_last_run_date_to_next_run_date.rb deleted file mode 100644 index 7618e1841bd..00000000000 --- a/db/post_migrate/20220913083015_clean_up_rename_iterations_cadences_last_run_date_to_next_run_date.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanUpRenameIterationsCadencesLastRunDateToNextRunDate < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :iterations_cadences, :last_run_date, :next_run_date - end - - def down - undo_cleanup_concurrent_column_rename :iterations_cadences, :last_run_date, :next_run_date - end -end diff --git a/db/post_migrate/20220914093408_add_unique_id_partition_id_index_to_ci_build_metadata.rb b/db/post_migrate/20220914093408_add_unique_id_partition_id_index_to_ci_build_metadata.rb deleted file mode 100644 index 1f40118c809..00000000000 --- a/db/post_migrate/20220914093408_add_unique_id_partition_id_index_to_ci_build_metadata.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIdPartitionIdIndexToCiBuildMetadata < Gitlab::Database::Migration[2.0] - TABLE_NAME = :ci_builds_metadata - INDEX_NAME = :index_ci_builds_metadata_on_id_partition_id_unique - - def up - prepare_async_index(TABLE_NAME, %i[id partition_id], unique: true, name: INDEX_NAME) - end - - def down - unprepare_async_index(:ci_builds_metadata, %i[id partition_id], name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20220915103831_add_unique_build_id_partition_id_index_to_ci_build_metadata.rb b/db/post_migrate/20220915103831_add_unique_build_id_partition_id_index_to_ci_build_metadata.rb deleted file mode 100644 index 74b60390057..00000000000 --- a/db/post_migrate/20220915103831_add_unique_build_id_partition_id_index_to_ci_build_metadata.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueBuildIdPartitionIdIndexToCiBuildMetadata < Gitlab::Database::Migration[2.0] - TABLE_NAME = :ci_builds_metadata - INDEX_NAME = :index_ci_builds_metadata_on_build_id_partition_id_unique - - def up - prepare_async_index(TABLE_NAME, %i[build_id partition_id], unique: true, name: INDEX_NAME) - end - - def down - unprepare_async_index(:ci_builds_metadata, %i[build_id partition_id], name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20220915192521_prepare_async_trigram_index_for_vulnerability_reads_container_images.rb b/db/post_migrate/20220915192521_prepare_async_trigram_index_for_vulnerability_reads_container_images.rb deleted file mode 100644 index 18ed1b2cd2b..00000000000 --- a/db/post_migrate/20220915192521_prepare_async_trigram_index_for_vulnerability_reads_container_images.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class PrepareAsyncTrigramIndexForVulnerabilityReadsContainerImages < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_vulnerability_reads_on_location_image_trigram' - REPORT_TYPES = { container_scanning: 2, cluster_image_scanning: 7 }.freeze - - def up - prepare_async_index :vulnerability_reads, :location_image, - name: INDEX_NAME, - using: :gin, opclass: { location_image: :gin_trgm_ops }, - where: "report_type = ANY (ARRAY[#{REPORT_TYPES.values.join(', ')}]) AND location_image IS NOT NULL" - end - - def down - unprepare_async_index :vulnerability_reads, :location_image, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220916054103_remove_experience_level_column.rb b/db/post_migrate/20220916054103_remove_experience_level_column.rb deleted file mode 100644 index dff5a9a6580..00000000000 --- a/db/post_migrate/20220916054103_remove_experience_level_column.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class RemoveExperienceLevelColumn < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def up - remove_column :user_preferences, :experience_level - end - - def down - add_column :user_preferences, :experience_level, :integer, limit: 2 - end -end diff --git a/db/post_migrate/20220916070101_add_index_build_id_partition_id_to_ci_build_metadata.rb b/db/post_migrate/20220916070101_add_index_build_id_partition_id_to_ci_build_metadata.rb deleted file mode 100644 index 18c24c47325..00000000000 --- a/db/post_migrate/20220916070101_add_index_build_id_partition_id_to_ci_build_metadata.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddIndexBuildIdPartitionIdToCiBuildMetadata < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = :ci_builds_metadata - INDEX_NAME = :index_ci_builds_metadata_on_build_id_partition_id_unique - - def up - add_concurrent_index(TABLE_NAME, %i[build_id partition_id], unique: true, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20220916112841_remove_unused_aggregation_columns.rb b/db/post_migrate/20220916112841_remove_unused_aggregation_columns.rb deleted file mode 100644 index f5333c84042..00000000000 --- a/db/post_migrate/20220916112841_remove_unused_aggregation_columns.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -class RemoveUnusedAggregationColumns < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_column :analytics_cycle_analytics_aggregations, :last_full_run_processed_records - remove_column :analytics_cycle_analytics_aggregations, :last_full_run_runtimes_in_seconds - remove_column :analytics_cycle_analytics_aggregations, :last_full_run_issues_updated_at - remove_column :analytics_cycle_analytics_aggregations, :last_full_run_mrs_updated_at - remove_column :analytics_cycle_analytics_aggregations, :last_full_run_issues_id - remove_column :analytics_cycle_analytics_aggregations, :last_full_run_merge_requests_id - end - end - - def down - with_lock_retries do - add_column(:analytics_cycle_analytics_aggregations, - :last_full_run_processed_records, - :integer, - array: true, - default: [], - null: false, - if_not_exists: true) - add_column(:analytics_cycle_analytics_aggregations, - :last_full_run_runtimes_in_seconds, - :integer, - array: true, - default: [], - null: false, - if_not_exists: true) - add_column(:analytics_cycle_analytics_aggregations, - :last_full_run_issues_updated_at, - :datetime_with_timezone, - if_not_exists: true) - add_column(:analytics_cycle_analytics_aggregations, - :last_full_run_mrs_updated_at, - :datetime_with_timezone, - if_not_exists: true) - add_column(:analytics_cycle_analytics_aggregations, - :last_full_run_issues_id, - :integer, - if_not_exists: true) - add_column(:analytics_cycle_analytics_aggregations, - :last_full_run_merge_requests_id, - :integer, - if_not_exists: true) - end - - add_check_constraint(:analytics_cycle_analytics_aggregations, - 'CARDINALITY(last_full_run_runtimes_in_seconds) <= 10', - 'chk_rails_7810292ec9') - - add_check_constraint(:analytics_cycle_analytics_aggregations, - 'CARDINALITY(last_full_run_processed_records) <= 10', - 'chk_rails_8b9e89687c') - end -end diff --git a/db/post_migrate/20220919023208_drop_unused_fields_from_merge_request_assignees.rb b/db/post_migrate/20220919023208_drop_unused_fields_from_merge_request_assignees.rb deleted file mode 100644 index f1afbb41893..00000000000 --- a/db/post_migrate/20220919023208_drop_unused_fields_from_merge_request_assignees.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class DropUnusedFieldsFromMergeRequestAssignees < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - if column_exists?(:merge_request_assignees, :state) # rubocop:disable Style/IfUnlessModifier - remove_column :merge_request_assignees, :state - end - - if column_exists?(:merge_request_assignees, :updated_state_by_user_id) - remove_column :merge_request_assignees, :updated_state_by_user_id - end - end - end - - def down - with_lock_retries do - unless column_exists?(:merge_request_assignees, :state) - add_column :merge_request_assignees, :state, :smallint, default: 0, null: false - end - - unless column_exists?(:merge_request_assignees, :updated_state_by_user_id) - add_column :merge_request_assignees, :updated_state_by_user_id, :bigint - end - end - - add_concurrent_index :merge_request_assignees, [:user_id, :state], - where: 'state = 2', - name: 'index_on_merge_request_assignees_user_id_and_state' - - add_concurrent_index :merge_request_assignees, :updated_state_by_user_id, - name: 'index_on_merge_request_assignees_updated_state_by_user_id' - - add_concurrent_foreign_key :merge_request_assignees, :users, - column: :updated_state_by_user_id, - on_delete: :nullify - end -end diff --git a/db/post_migrate/20220919041604_drop_unused_fields_from_merge_request_reviewers.rb b/db/post_migrate/20220919041604_drop_unused_fields_from_merge_request_reviewers.rb deleted file mode 100644 index d9f98557f75..00000000000 --- a/db/post_migrate/20220919041604_drop_unused_fields_from_merge_request_reviewers.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class DropUnusedFieldsFromMergeRequestReviewers < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - if column_exists?(:merge_request_reviewers, :updated_state_by_user_id) - remove_column :merge_request_reviewers, :updated_state_by_user_id - end - end - end - - def down - with_lock_retries do - unless column_exists?(:merge_request_reviewers, :updated_state_by_user_id) - add_column :merge_request_reviewers, :updated_state_by_user_id, :bigint - end - end - - add_concurrent_index :merge_request_reviewers, :updated_state_by_user_id, - name: 'index_on_merge_request_reviewers_updated_state_by_user_id' - - add_concurrent_foreign_key :merge_request_reviewers, :users, column: :updated_state_by_user_id, on_delete: :nullify - end -end diff --git a/db/post_migrate/20220919050555_drop_tmp_index_user_callouts_on_attention_request_feature_names.rb b/db/post_migrate/20220919050555_drop_tmp_index_user_callouts_on_attention_request_feature_names.rb deleted file mode 100644 index e456a91fe3f..00000000000 --- a/db/post_migrate/20220919050555_drop_tmp_index_user_callouts_on_attention_request_feature_names.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class DropTmpIndexUserCalloutsOnAttentionRequestFeatureNames < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_user_callouts_on_attention_request_feature_names" - ATTENTION_REQUEST_CALLOUTS = [47, 48] - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :user_callouts, INDEX_NAME - end - - def down - add_concurrent_index :user_callouts, [:id], - where: "feature_name IN (#{ATTENTION_REQUEST_CALLOUTS.join(',')})", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220919080303_delete_migrate_shared_vulnerability_scanners.rb b/db/post_migrate/20220919080303_delete_migrate_shared_vulnerability_scanners.rb deleted file mode 100644 index 4aedfcf1699..00000000000 --- a/db/post_migrate/20220919080303_delete_migrate_shared_vulnerability_scanners.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -class DeleteMigrateSharedVulnerabilityScanners < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = "MigrateSharedVulnerabilityScanners" - TABLE_NAME = :vulnerability_occurrences - BATCH_COLUMN = :id - BATCH_SIZE = 250 - - class BatchedBackgroundMigration < MigrationRecord - self.table_name = "batched_background_migrations" - end - - class BatchedBackgroundMigrationJob < MigrationRecord - include ::EachBatch - - self.table_name = "batched_background_migration_jobs" - - belongs_to :batched_background_migration - end - - def up - return unless migration_id = BatchedBackgroundMigration.find_by(job_class_name: MIGRATION)&.id - - # rubocop:disable Style/SymbolProc - BatchedBackgroundMigrationJob - .where(batched_background_migration_id: migration_id) - .each_batch(of: BATCH_SIZE) do |relation| - relation.delete_all - end - # rubocop:enable Style/SymbolProc - - delete_batched_background_migration(MIGRATION, - TABLE_NAME, - BATCH_COLUMN, - []) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220919080304_reschedule_migrate_shared_vulnerability_scanners.rb b/db/post_migrate/20220919080304_reschedule_migrate_shared_vulnerability_scanners.rb deleted file mode 100644 index 69757085587..00000000000 --- a/db/post_migrate/20220919080304_reschedule_migrate_shared_vulnerability_scanners.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RescheduleMigrateSharedVulnerabilityScanners < Gitlab::Database::Migration[2.0] - MIGRATION = "MigrateSharedVulnerabilityScanners" - TABLE_NAME = :vulnerability_occurrences - BATCH_COLUMN = :id - DELAY_INTERVAL = 5.minutes - BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 100 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - TABLE_NAME, - BATCH_COLUMN, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, TABLE_NAME, BATCH_COLUMN, []) - end -end diff --git a/db/post_migrate/20220920081631_prepare_ci_builds_metadata_for_partitioning_primary_key.rb b/db/post_migrate/20220920081631_prepare_ci_builds_metadata_for_partitioning_primary_key.rb deleted file mode 100644 index 90727178624..00000000000 --- a/db/post_migrate/20220920081631_prepare_ci_builds_metadata_for_partitioning_primary_key.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class PrepareCiBuildsMetadataForPartitioningPrimaryKey < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = 'ci_builds_metadata' - PRIMARY_KEY = 'ci_builds_metadata_pkey' - NEW_INDEX_NAME = 'index_ci_builds_metadata_on_id_partition_id_unique' - OLD_INDEX_NAME = 'index_ci_builds_metadata_on_id_unique' - - def up - with_lock_retries(raise_on_exhaustion: true) do - execute("ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT #{PRIMARY_KEY} CASCADE") - - rename_index(TABLE_NAME, NEW_INDEX_NAME, PRIMARY_KEY) - - execute("ALTER TABLE #{TABLE_NAME} ADD CONSTRAINT #{PRIMARY_KEY} " \ - "PRIMARY KEY USING INDEX #{PRIMARY_KEY}") - end - end - - # rolling back this migration is time consuming with the creation of these two indexes - def down - add_concurrent_index(TABLE_NAME, :id, unique: true, name: OLD_INDEX_NAME) - add_concurrent_index(TABLE_NAME, [:id, :partition_id], unique: true, name: NEW_INDEX_NAME) - - with_lock_retries(raise_on_exhaustion: true) do - execute("ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT #{PRIMARY_KEY} CASCADE") - - rename_index(TABLE_NAME, OLD_INDEX_NAME, PRIMARY_KEY) - - execute("ALTER TABLE #{TABLE_NAME} ADD CONSTRAINT #{PRIMARY_KEY} " \ - "PRIMARY KEY USING INDEX #{PRIMARY_KEY}") - end - end -end diff --git a/db/post_migrate/20220920122121_schedule_index_removal_for_ci_builds_metadata.rb b/db/post_migrate/20220920122121_schedule_index_removal_for_ci_builds_metadata.rb deleted file mode 100644 index 57475a08c93..00000000000 --- a/db/post_migrate/20220920122121_schedule_index_removal_for_ci_builds_metadata.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class ScheduleIndexRemovalForCiBuildsMetadata < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = :ci_builds_metadata - INDEX_NAME = :index_ci_builds_metadata_on_build_id - - def up - prepare_async_index_removal(TABLE_NAME, :build_id, name: INDEX_NAME) - end - - def down - unprepare_async_index(TABLE_NAME, :build_id, name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20220920124709_backfill_internal_on_notes_renamed.rb b/db/post_migrate/20220920124709_backfill_internal_on_notes_renamed.rb deleted file mode 100644 index a9de69243f6..00000000000 --- a/db/post_migrate/20220920124709_backfill_internal_on_notes_renamed.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Renamed from BackfillInternalOnNotes to BackfillInternalOnNotesRenamed to avoid collision with an Elasticsearch -# migration from the same name. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129012 -class BackfillInternalOnNotesRenamed < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillInternalOnNotes' - DELAY_INTERVAL = 2.minutes - TABLE = :notes - BATCH_SIZE = 2000 - SUB_BATCH_SIZE = 10 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - TABLE, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, TABLE, :id, []) - end -end diff --git a/db/post_migrate/20220920135356_tiebreak_user_type_index.rb b/db/post_migrate/20220920135356_tiebreak_user_type_index.rb deleted file mode 100644 index 489196c8eab..00000000000 --- a/db/post_migrate/20220920135356_tiebreak_user_type_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class TiebreakUserTypeIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - NEW_INDEX_NAME = 'index_users_on_user_type_and_id' - OLD_INDEX_NAME = 'index_users_on_user_type' - - def up - # rubocop:disable Migration/PreventIndexCreation - add_concurrent_index :users, [:user_type, :id], name: NEW_INDEX_NAME - # rubocop:enable Migration/PreventIndexCreation - remove_concurrent_index_by_name :users, OLD_INDEX_NAME - end - - def down - add_concurrent_index :users, :user_type, name: OLD_INDEX_NAME - remove_concurrent_index_by_name :users, NEW_INDEX_NAME - end -end diff --git a/db/post_migrate/20220920141001_add_index_on_internal_notes.rb b/db/post_migrate/20220920141001_add_index_on_internal_notes.rb deleted file mode 100644 index 466ad7b5a8d..00000000000 --- a/db/post_migrate/20220920141001_add_index_on_internal_notes.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnInternalNotes < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_notes_on_id_where_internal' - - disable_ddl_transaction! - - def up - add_concurrent_index :notes, :id, where: 'internal = true', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :notes, INDEX_NAME - end -end diff --git a/db/post_migrate/20220920213504_finalize_task_system_note_renaming.rb b/db/post_migrate/20220920213504_finalize_task_system_note_renaming.rb deleted file mode 100644 index d9307c14ccb..00000000000 --- a/db/post_migrate/20220920213504_finalize_task_system_note_renaming.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FinalizeTaskSystemNoteRenaming < Gitlab::Database::Migration[2.0] - def up - # no-op - end - - def down - # noop - end -end diff --git a/db/post_migrate/20220920214524_remove_task_system_note_rename_temp_index.rb b/db/post_migrate/20220920214524_remove_task_system_note_rename_temp_index.rb deleted file mode 100644 index d3671d24578..00000000000 --- a/db/post_migrate/20220920214524_remove_task_system_note_rename_temp_index.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RemoveTaskSystemNoteRenameTempIndex < Gitlab::Database::Migration[2.0] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220921093355_schedule_backfill_namespace_details.rb b/db/post_migrate/20220921093355_schedule_backfill_namespace_details.rb deleted file mode 100644 index 16ce9bd5c85..00000000000 --- a/db/post_migrate/20220921093355_schedule_backfill_namespace_details.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillNamespaceDetails < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillNamespaceDetails' - INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :namespaces, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :namespaces, :id, []) - end -end diff --git a/db/post_migrate/20220921111823_remove_and_add_ci_pipeline_variables_raw_with_new_default.rb b/db/post_migrate/20220921111823_remove_and_add_ci_pipeline_variables_raw_with_new_default.rb deleted file mode 100644 index fd56a8f320a..00000000000 --- a/db/post_migrate/20220921111823_remove_and_add_ci_pipeline_variables_raw_with_new_default.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class RemoveAndAddCiPipelineVariablesRawWithNewDefault < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_pipeline_variables, :raw, :boolean, null: false, default: true - add_column :ci_pipeline_variables, :raw, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20220921111831_remove_and_add_ci_group_variables_raw_with_new_default.rb b/db/post_migrate/20220921111831_remove_and_add_ci_group_variables_raw_with_new_default.rb deleted file mode 100644 index f4b7de3faf4..00000000000 --- a/db/post_migrate/20220921111831_remove_and_add_ci_group_variables_raw_with_new_default.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class RemoveAndAddCiGroupVariablesRawWithNewDefault < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_group_variables, :raw, :boolean, null: false, default: true - add_column :ci_group_variables, :raw, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20220921111840_remove_and_add_ci_instance_variables_raw_with_new_default.rb b/db/post_migrate/20220921111840_remove_and_add_ci_instance_variables_raw_with_new_default.rb deleted file mode 100644 index 019db1bbaa3..00000000000 --- a/db/post_migrate/20220921111840_remove_and_add_ci_instance_variables_raw_with_new_default.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class RemoveAndAddCiInstanceVariablesRawWithNewDefault < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_instance_variables, :raw, :boolean, null: false, default: true - add_column :ci_instance_variables, :raw, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20220921111849_remove_and_add_ci_job_variables_raw_with_new_default.rb b/db/post_migrate/20220921111849_remove_and_add_ci_job_variables_raw_with_new_default.rb deleted file mode 100644 index 736cd46382d..00000000000 --- a/db/post_migrate/20220921111849_remove_and_add_ci_job_variables_raw_with_new_default.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class RemoveAndAddCiJobVariablesRawWithNewDefault < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_job_variables, :raw, :boolean, null: false, default: true - add_column :ci_job_variables, :raw, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20220921111857_remove_and_add_ci_pipeline_schedule_variables_raw_with_new_default.rb b/db/post_migrate/20220921111857_remove_and_add_ci_pipeline_schedule_variables_raw_with_new_default.rb deleted file mode 100644 index 159b0303d71..00000000000 --- a/db/post_migrate/20220921111857_remove_and_add_ci_pipeline_schedule_variables_raw_with_new_default.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class RemoveAndAddCiPipelineScheduleVariablesRawWithNewDefault < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_pipeline_schedule_variables, :raw, :boolean, null: false, default: true - add_column :ci_pipeline_schedule_variables, :raw, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20220921111907_remove_and_add_ci_variables_raw_with_new_default.rb b/db/post_migrate/20220921111907_remove_and_add_ci_variables_raw_with_new_default.rb deleted file mode 100644 index 129e5b1f020..00000000000 --- a/db/post_migrate/20220921111907_remove_and_add_ci_variables_raw_with_new_default.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class RemoveAndAddCiVariablesRawWithNewDefault < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_variables, :raw, :boolean, null: false, default: true - add_column :ci_variables, :raw, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20220921144258_remove_orphan_group_token_users.rb b/db/post_migrate/20220921144258_remove_orphan_group_token_users.rb deleted file mode 100644 index a2483f611a3..00000000000 --- a/db/post_migrate/20220921144258_remove_orphan_group_token_users.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class RemoveOrphanGroupTokenUsers < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - disable_ddl_transaction! - - class MigrationUser < MigrationRecord - include EachBatch - - self.table_name = 'users' - - scope :project_bots, -> { where(user_type: 6) } - scope :without_memberships, -> { where("NOT EXISTS (SELECT 1 FROM members where members.user_id = users.id)") } - end - - class MigrationPersonalAccessToken < MigrationRecord - self.table_name = 'personal_access_tokens' - end - - def up - delete_worker = 'DeleteUserWorker'.safe_constantize - - MigrationUser.project_bots.each_batch(of: 1000) do |batch| - bot_ids = batch.without_memberships.pluck(:id) - - MigrationPersonalAccessToken.where(user_id: bot_ids).delete_all - - next unless delete_worker && delete_worker.respond_to?(:perform_async) - - bot_ids.each do |bot_id| - delete_worker.perform_async(bot_id, bot_id, skip_authorization: true) - end - end - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220922090236_remove_trace_column_from_ci_builds.rb b/db/post_migrate/20220922090236_remove_trace_column_from_ci_builds.rb deleted file mode 100644 index e1871a9799f..00000000000 --- a/db/post_migrate/20220922090236_remove_trace_column_from_ci_builds.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class RemoveTraceColumnFromCiBuilds < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :ci_builds, :trace, :text - end -end diff --git a/db/post_migrate/20220922143143_schedule_reset_duplicate_ci_runners_token_values.rb b/db/post_migrate/20220922143143_schedule_reset_duplicate_ci_runners_token_values.rb deleted file mode 100644 index fd02bda8004..00000000000 --- a/db/post_migrate/20220922143143_schedule_reset_duplicate_ci_runners_token_values.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class ScheduleResetDuplicateCiRunnersTokenValues < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_ci - disable_ddl_transaction! - - MIGRATION = 'ResetDuplicateCiRunnersTokenValues' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 2_000 - MAX_BATCH_SIZE = 100_000 - SUB_BATCH_SIZE = 500 - - def up - queue_batched_background_migration( - MIGRATION, - :ci_runners, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :ci_runners, :id, []) - end -end diff --git a/db/post_migrate/20220922143634_schedule_reset_duplicate_ci_runners_token_encrypted_values.rb b/db/post_migrate/20220922143634_schedule_reset_duplicate_ci_runners_token_encrypted_values.rb deleted file mode 100644 index bbbf9a1db44..00000000000 --- a/db/post_migrate/20220922143634_schedule_reset_duplicate_ci_runners_token_encrypted_values.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class ScheduleResetDuplicateCiRunnersTokenEncryptedValues < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_ci - disable_ddl_transaction! - - MIGRATION = 'ResetDuplicateCiRunnersTokenEncryptedValues' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 2_000 - MAX_BATCH_SIZE = 100_000 - SUB_BATCH_SIZE = 500 - - def up - queue_batched_background_migration( - MIGRATION, - :ci_runners, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :ci_runners, :id, []) - end -end diff --git a/db/post_migrate/20220922204106_remove_index_for_requested_non_invited_awaiting_members.rb b/db/post_migrate/20220922204106_remove_index_for_requested_non_invited_awaiting_members.rb deleted file mode 100644 index 033b04a75f8..00000000000 --- a/db/post_migrate/20220922204106_remove_index_for_requested_non_invited_awaiting_members.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexForRequestedNonInvitedAwaitingMembers < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_members_on_non_requested_non_invited_and_state_awaiting' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :members, INDEX_NAME - end - - def down - clause = '((requested_at IS NULL) AND (invite_token IS NULL) AND (access_level > 5) AND (state = 1))' - - add_concurrent_index :members, :source_id, where: clause, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220923052531_remove_tmp_index_merge_request_reviewers_on_attention_requested_state.rb b/db/post_migrate/20220923052531_remove_tmp_index_merge_request_reviewers_on_attention_requested_state.rb deleted file mode 100644 index 27d9c1641bc..00000000000 --- a/db/post_migrate/20220923052531_remove_tmp_index_merge_request_reviewers_on_attention_requested_state.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIndexMergeRequestReviewersOnAttentionRequestedState < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_merge_request_reviewers_on_attention_requested_state" - ATTENTION_REQUESTED_STATE = 2 - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :merge_request_reviewers, INDEX_NAME - end - - def down - add_concurrent_index :merge_request_reviewers, [:id], - where: "state = #{ATTENTION_REQUESTED_STATE}", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220923060226_remove_tmp_index_system_note_metadata_on_attention_request_actions.rb b/db/post_migrate/20220923060226_remove_tmp_index_system_note_metadata_on_attention_request_actions.rb deleted file mode 100644 index 40e8c1cfdb5..00000000000 --- a/db/post_migrate/20220923060226_remove_tmp_index_system_note_metadata_on_attention_request_actions.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIndexSystemNoteMetadataOnAttentionRequestActions < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_index_system_note_metadata_on_attention_request_actions" - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :system_note_metadata, INDEX_NAME - end - - def down - add_concurrent_index :system_note_metadata, [:id], - where: "action IN ('attention_requested', 'attention_request_removed')", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220927171740_prepare_for_vulnerability_occurrences_uuid_type_transition.rb b/db/post_migrate/20220927171740_prepare_for_vulnerability_occurrences_uuid_type_transition.rb deleted file mode 100644 index e6f3384514d..00000000000 --- a/db/post_migrate/20220927171740_prepare_for_vulnerability_occurrences_uuid_type_transition.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class PrepareForVulnerabilityOccurrencesUuidTypeTransition < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - TABLE = :vulnerability_occurrences - MAPPINGS = { - uuid: { - from_type: :string, - to_type: :uuid, - default_value: '00000000-0000-0000-0000-000000000000' - } - } - - def up - create_temporary_columns_and_triggers(TABLE, MAPPINGS) - end - - def down - columns = MAPPINGS.keys - temporary_columns = columns.map { |column| convert_to_type_column(column, :string, :uuid) } - trigger_name = rename_trigger_name(TABLE, columns, temporary_columns) - remove_rename_triggers(TABLE, trigger_name) - temporary_columns.each { |column| remove_column(TABLE, column) } - end -end diff --git a/db/post_migrate/20220928225711_schedule_update_ci_pipeline_artifacts_locked_status.rb b/db/post_migrate/20220928225711_schedule_update_ci_pipeline_artifacts_locked_status.rb deleted file mode 100644 index 0d7a5dc4bec..00000000000 --- a/db/post_migrate/20220928225711_schedule_update_ci_pipeline_artifacts_locked_status.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class ScheduleUpdateCiPipelineArtifactsLockedStatus < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - MIGRATION = 'UpdateCiPipelineArtifactsUnknownLockedStatus' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - SUB_BATCH_SIZE = 500 - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - def up - queue_batched_background_migration( - MIGRATION, - :ci_pipeline_artifacts, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :ci_pipeline_artifacts, :id, []) - end -end diff --git a/db/post_migrate/20220929081645_tmp_idx_null_member_namespace_id.rb b/db/post_migrate/20220929081645_tmp_idx_null_member_namespace_id.rb deleted file mode 100644 index 58d6c653e6f..00000000000 --- a/db/post_migrate/20220929081645_tmp_idx_null_member_namespace_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class TmpIdxNullMemberNamespaceId < Gitlab::Database::Migration[2.0] - TMP_INDEX_FOR_NULL_MEMBER_NAMESPACE_ID = 'tmp_index_for_null_member_namespace_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :members, :member_namespace_id, - name: TMP_INDEX_FOR_NULL_MEMBER_NAMESPACE_ID, - where: 'member_namespace_id IS NULL' - end - - def down - remove_concurrent_index_by_name :members, name: TMP_INDEX_FOR_NULL_MEMBER_NAMESPACE_ID - end -end diff --git a/db/post_migrate/20220929091500_add_tmp_index_vulns_on_report_type.rb b/db/post_migrate/20220929091500_add_tmp_index_vulns_on_report_type.rb deleted file mode 100644 index 19100e1d0cc..00000000000 --- a/db/post_migrate/20220929091500_add_tmp_index_vulns_on_report_type.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true -class AddTmpIndexVulnsOnReportType < Gitlab::Database::Migration[2.0] - # Temporary index to perform migration removing invalid vulnerabilities - INDEX_NAME = 'tmp_idx_vulnerabilities_on_id_where_report_type_7_99' - - REPORT_TYPES = { - cluster_image_scanning: 7, - custom: 99 - } - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerabilities, :id, - where: "report_type IN (#{REPORT_TYPES.values.join(', ')})", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME - end -end diff --git a/db/post_migrate/20220929101947_delete_remove_invalid_member_migration.rb b/db/post_migrate/20220929101947_delete_remove_invalid_member_migration.rb deleted file mode 100644 index 6fb358e57ab..00000000000 --- a/db/post_migrate/20220929101947_delete_remove_invalid_member_migration.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class DeleteRemoveInvalidMemberMigration < Gitlab::Database::Migration[2.0] - PROJECT_MEMBER_MIGRATION = 'ScheduleDestroyInvalidProjectMembers' - GROUP_MEMBER_MIGRATION = 'ScheduleDestroyInvalidGroupMembers' - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - delete_batched_background_migration(PROJECT_MEMBER_MIGRATION, :members, :id, []) - delete_batched_background_migration(GROUP_MEMBER_MIGRATION, :members, :id, []) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20220929194453_add_index_releases_project_id_id.rb b/db/post_migrate/20220929194453_add_index_releases_project_id_id.rb deleted file mode 100644 index 179b5a636f0..00000000000 --- a/db/post_migrate/20220929194453_add_index_releases_project_id_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexReleasesProjectIdId < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_releases_on_project_id_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :releases, %i[project_id id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :releases, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20220929213730_schedule_delete_orphaned_operational_vulnerabilities.rb b/db/post_migrate/20220929213730_schedule_delete_orphaned_operational_vulnerabilities.rb deleted file mode 100644 index c03358b1fda..00000000000 --- a/db/post_migrate/20220929213730_schedule_delete_orphaned_operational_vulnerabilities.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDeleteOrphanedOperationalVulnerabilities < Gitlab::Database::Migration[2.0] - MIGRATION = 'DeleteOrphanedOperationalVulnerabilities' - INTERVAL = 2.minutes - BATCH_SIZE = 10_000 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :vulnerabilities, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :vulnerabilities, :id, []) - end -end diff --git a/db/post_migrate/20220930110127_remove_unique_index_build_id_to_ci_builds_metadata.rb b/db/post_migrate/20220930110127_remove_unique_index_build_id_to_ci_builds_metadata.rb deleted file mode 100644 index 4c23cdc5284..00000000000 --- a/db/post_migrate/20220930110127_remove_unique_index_build_id_to_ci_builds_metadata.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class RemoveUniqueIndexBuildIdToCiBuildsMetadata < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = :ci_builds_metadata - INDEX_NAME = :index_ci_builds_metadata_on_build_id - - def up - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end - - def down - add_concurrent_index(TABLE_NAME, :build_id, unique: true, name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20221003192827_add_index_resolved_on_default_branch_to_vulnerabilities_read.rb b/db/post_migrate/20221003192827_add_index_resolved_on_default_branch_to_vulnerabilities_read.rb deleted file mode 100644 index e352e324187..00000000000 --- a/db/post_migrate/20221003192827_add_index_resolved_on_default_branch_to_vulnerabilities_read.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexResolvedOnDefaultBranchToVulnerabilitiesRead < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_vuln_reads_on_resolved_on_default_branch' - COLUMNS = %i[project_id state id] - - def up - add_concurrent_index :vulnerability_reads, COLUMNS, - where: 'resolved_on_default_branch IS TRUE', - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/post_migrate/20221004074910_routing_table_prepare_constraint_for_builds_metadata.rb b/db/post_migrate/20221004074910_routing_table_prepare_constraint_for_builds_metadata.rb deleted file mode 100644 index 013984154ae..00000000000 --- a/db/post_migrate/20221004074910_routing_table_prepare_constraint_for_builds_metadata.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class RoutingTablePrepareConstraintForBuildsMetadata < Gitlab::Database::Migration[2.0] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - - disable_ddl_transaction! - - TABLE_NAME = :ci_builds_metadata - PARENT_TABLE_NAME = :p_ci_builds_metadata - FIRST_PARTITION = 100 - PARTITION_COLUMN = :partition_id - - def up - prepare_constraint_for_list_partitioning( - table_name: TABLE_NAME, - partitioning_column: PARTITION_COLUMN, - parent_table_name: PARENT_TABLE_NAME, - initial_partitioning_value: FIRST_PARTITION - ) - end - - def down - revert_preparing_constraint_for_list_partitioning( - table_name: TABLE_NAME, - partitioning_column: PARTITION_COLUMN, - parent_table_name: PARENT_TABLE_NAME, - initial_partitioning_value: FIRST_PARTITION - ) - end -end diff --git a/db/post_migrate/20221004074914_create_routing_table_for_builds_metadata.rb b/db/post_migrate/20221004074914_create_routing_table_for_builds_metadata.rb deleted file mode 100644 index a792fc91d3d..00000000000 --- a/db/post_migrate/20221004074914_create_routing_table_for_builds_metadata.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class CreateRoutingTableForBuildsMetadata < Gitlab::Database::Migration[2.0] - def up; end - - def down; end -end diff --git a/db/post_migrate/20221004092038_tmp_index_members_on_id_where_namespace_id_null.rb b/db/post_migrate/20221004092038_tmp_index_members_on_id_where_namespace_id_null.rb deleted file mode 100644 index 68a707e99c2..00000000000 --- a/db/post_migrate/20221004092038_tmp_index_members_on_id_where_namespace_id_null.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class TmpIndexMembersOnIdWhereNamespaceIdNull < Gitlab::Database::Migration[2.0] - TMP_INDEX = 'tmp_index_members_on_id_where_namespace_id_null' - - disable_ddl_transaction! - - def up - add_concurrent_index :members, :id, - name: TMP_INDEX, - where: 'member_namespace_id IS NULL' - end - - def down - remove_concurrent_index_by_name :members, name: TMP_INDEX - end -end diff --git a/db/post_migrate/20221004094814_schedule_destroy_invalid_members.rb b/db/post_migrate/20221004094814_schedule_destroy_invalid_members.rb deleted file mode 100644 index fa6a1fd5f72..00000000000 --- a/db/post_migrate/20221004094814_schedule_destroy_invalid_members.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true -class ScheduleDestroyInvalidMembers < Gitlab::Database::Migration[2.0] - MIGRATION = 'DestroyInvalidMembers' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 200 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :members, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE, - gitlab_schema: :gitlab_main - ) - end - - def down - delete_batched_background_migration(MIGRATION, :members, :id, []) - end -end diff --git a/db/post_migrate/20221005103000_add_index_merge_request_id_on_scan_finding_approval_merge_request_rules.rb b/db/post_migrate/20221005103000_add_index_merge_request_id_on_scan_finding_approval_merge_request_rules.rb deleted file mode 100644 index 06bf21b894a..00000000000 --- a/db/post_migrate/20221005103000_add_index_merge_request_id_on_scan_finding_approval_merge_request_rules.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexMergeRequestIdOnScanFindingApprovalMergeRequestRules < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'scan_finding_approval_mr_rule_index_merge_request_id' - SCAN_FINDING_REPORT_TYPE = 4 - - disable_ddl_transaction! - - def up - add_concurrent_index :approval_merge_request_rules, :merge_request_id, - where: "report_type = #{SCAN_FINDING_REPORT_TYPE}", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :approval_merge_request_rules, INDEX_NAME - end -end diff --git a/db/post_migrate/20221006070927_finalize_invalid_member_cleanup.rb b/db/post_migrate/20221006070927_finalize_invalid_member_cleanup.rb deleted file mode 100644 index 78786e46f5c..00000000000 --- a/db/post_migrate/20221006070927_finalize_invalid_member_cleanup.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class FinalizeInvalidMemberCleanup < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'DestroyInvalidMembers' - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :members, - column_name: :id, - job_arguments: [] - ) - end - - def down - # noop - end -end diff --git a/db/post_migrate/20221006083240_prepare_partial_trigram_indexes_for_issues_attempt_2.rb b/db/post_migrate/20221006083240_prepare_partial_trigram_indexes_for_issues_attempt_2.rb deleted file mode 100644 index 6ca2ba222ae..00000000000 --- a/db/post_migrate/20221006083240_prepare_partial_trigram_indexes_for_issues_attempt_2.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class PreparePartialTrigramIndexesForIssuesAttempt2 < Gitlab::Database::Migration[2.0] - TITLE_INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - def up - prepare_async_index :issues, :title, - name: TITLE_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*' " \ - "OR description NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*'" - - prepare_async_index :issues, :description, - name: DESCRIPTION_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*' " \ - "OR description NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*'" - end - - def down - unprepare_async_index_by_name :issues, DESCRIPTION_INDEX_NAME - unprepare_async_index_by_name :issues, TITLE_INDEX_NAME - end -end diff --git a/db/post_migrate/20221006172302_adjust_task_note_rename_background_migration_values.rb b/db/post_migrate/20221006172302_adjust_task_note_rename_background_migration_values.rb deleted file mode 100644 index b582b163e2d..00000000000 --- a/db/post_migrate/20221006172302_adjust_task_note_rename_background_migration_values.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -class AdjustTaskNoteRenameBackgroundMigrationValues < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - JOB_CLASS_NAME = 'RenameTaskSystemNoteToChecklistItem' - MIGRATION_FAILED_STATUS = 4 - MIGRATION_FINISHED_STATUS = 3 - MIGRATION_ACTIVE_STATUS = 1 - JOB_FAILED_STATUS = 2 - - OLD_BATCH_SIZE = 10_000 - NEW_BATCH_SIZE = 5_000 - - OLD_SUB_BATCH_SIZE = 100 - NEW_SUB_BATCH_SIZE = 10 - - class InlineBatchedMigration < MigrationRecord - self.table_name = :batched_background_migrations - - scope :for_configuration, ->(job_class_name, table_name, column_name, job_arguments) do - where(job_class_name: job_class_name, table_name: table_name, column_name: column_name) - .where("job_arguments = ?", Gitlab::Json.dump(job_arguments)) # rubocop:disable Rails/WhereEquals - end - end - - class InlineBatchedJob < MigrationRecord - include EachBatch - self.table_name = :batched_background_migration_jobs - end - - def up - migration = InlineBatchedMigration.for_configuration( - JOB_CLASS_NAME, - :system_note_metadata, - :id, - [] - ).first - return if migration.blank? || migration.status == MIGRATION_FINISHED_STATUS - - InlineBatchedJob.where( - batched_background_migration_id: migration.id, - status: JOB_FAILED_STATUS - ).each_batch(of: 100) do |batch| - batch.update_all(attempts: 0, sub_batch_size: NEW_SUB_BATCH_SIZE) - end - - update_params = { batch_size: NEW_BATCH_SIZE, sub_batch_size: NEW_SUB_BATCH_SIZE } - - if migration.status == MIGRATION_FAILED_STATUS - update_params[:status] = MIGRATION_ACTIVE_STATUS - update_params[:started_at] = Time.zone.now if migration.respond_to?(:started_at) - end - - migration.update!(**update_params) - end - - def down - migration = InlineBatchedMigration.for_configuration( - JOB_CLASS_NAME, - :system_note_metadata, - :id, - [] - ).first - return if migration.blank? - - migration.update!( - batch_size: OLD_BATCH_SIZE, - sub_batch_size: OLD_SUB_BATCH_SIZE - ) - end -end diff --git a/db/post_migrate/20221010074914_migrate_security_findings_delete_queues.rb b/db/post_migrate/20221010074914_migrate_security_findings_delete_queues.rb deleted file mode 100644 index ce593e19859..00000000000 --- a/db/post_migrate/20221010074914_migrate_security_findings_delete_queues.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class MigrateSecurityFindingsDeleteQueues < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - def up - sidekiq_queue_migrate 'security_findings_delete_by_job_id', to: 'security_scans_purge_by_job_id' - sidekiq_queue_migrate 'cronjob:security_findings_cleanup', to: 'cronjob:security_scans_purge' - end - - def down - sidekiq_queue_migrate 'security_scans_purge_by_job_id', to: 'security_findings_delete_by_job_id' - sidekiq_queue_migrate 'cronjob:security_scans_purge', to: 'cronjob:security_findings_cleanup' - end -end diff --git a/db/post_migrate/20221010121510_prepare_async_index_author_id_target_project_id_on_merge_requests.rb b/db/post_migrate/20221010121510_prepare_async_index_author_id_target_project_id_on_merge_requests.rb deleted file mode 100644 index cd9035dd9f9..00000000000 --- a/db/post_migrate/20221010121510_prepare_async_index_author_id_target_project_id_on_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class PrepareAsyncIndexAuthorIdTargetProjectIdOnMergeRequests < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_merge_requests_on_author_id_and_target_project_id' - - disable_ddl_transaction! - - def up - prepare_async_index :merge_requests, %i[author_id target_project_id], name: INDEX_NAME - end - - def down - unprepare_async_index :merge_requests, %i[author_id target_project_id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221010122138_add_async_index_author_id_target_project_id_on_merge_requests.rb b/db/post_migrate/20221010122138_add_async_index_author_id_target_project_id_on_merge_requests.rb deleted file mode 100644 index 0689c090d09..00000000000 --- a/db/post_migrate/20221010122138_add_async_index_author_id_target_project_id_on_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexAuthorIdTargetProjectIdOnMergeRequests < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_merge_requests_on_author_id_and_id' - - disable_ddl_transaction! - - def up - prepare_async_index :merge_requests, %i[author_id id], name: INDEX_NAME - end - - def down - unprepare_async_index :merge_requests, %i[author_id id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221010122352_add_index_to_namespace_settings_on_default_compliance_framework_id.rb b/db/post_migrate/20221010122352_add_index_to_namespace_settings_on_default_compliance_framework_id.rb deleted file mode 100644 index 63de7942208..00000000000 --- a/db/post_migrate/20221010122352_add_index_to_namespace_settings_on_default_compliance_framework_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToNamespaceSettingsOnDefaultComplianceFrameworkId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'idx_namespace_settings_on_default_compliance_framework_id' - - def up - add_concurrent_index :namespace_settings, :default_compliance_framework_id, unique: true, name: INDEX_NAME - end - - def down - remove_concurrent_index :namespace_settings, :default_compliance_framework_id, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221010123040_add_compliance_framework_fk_to_namespace_settings.rb b/db/post_migrate/20221010123040_add_compliance_framework_fk_to_namespace_settings.rb deleted file mode 100644 index 5d4966fd580..00000000000 --- a/db/post_migrate/20221010123040_add_compliance_framework_fk_to_namespace_settings.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddComplianceFrameworkFkToNamespaceSettings < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :namespace_settings, :compliance_management_frameworks, - column: :default_compliance_framework_id, on_delete: :nullify, reverse_lock_order: true - end - - def down - with_lock_retries do - remove_foreign_key :namespace_settings, column: :default_compliance_framework_id - end - end -end diff --git a/db/post_migrate/20221010141500_add_index_author_id_target_project_id_on_merge_requests.rb b/db/post_migrate/20221010141500_add_index_author_id_target_project_id_on_merge_requests.rb deleted file mode 100644 index 5b9d5be2b3f..00000000000 --- a/db/post_migrate/20221010141500_add_index_author_id_target_project_id_on_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexAuthorIdTargetProjectIdOnMergeRequests < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_merge_requests_on_author_id_and_target_project_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_requests, %i[author_id target_project_id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :merge_requests, INDEX_NAME - end -end diff --git a/db/post_migrate/20221010162137_add_index_author_id_and_id_on_merge_requests.rb b/db/post_migrate/20221010162137_add_index_author_id_and_id_on_merge_requests.rb deleted file mode 100644 index 36184b5f573..00000000000 --- a/db/post_migrate/20221010162137_add_index_author_id_and_id_on_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexAuthorIdAndIdOnMergeRequests < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_merge_requests_on_author_id_and_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_requests, %i[author_id id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :merge_requests, INDEX_NAME - end -end diff --git a/db/post_migrate/20221011062254_sync_new_amount_used_for_ci_project_monthly_usages.rb b/db/post_migrate/20221011062254_sync_new_amount_used_for_ci_project_monthly_usages.rb deleted file mode 100644 index 32943f10fcf..00000000000 --- a/db/post_migrate/20221011062254_sync_new_amount_used_for_ci_project_monthly_usages.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class SyncNewAmountUsedForCiProjectMonthlyUsages < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - def up - project_usages = define_batchable_model('ci_project_monthly_usages') - - project_usages.each_batch(of: 500) do |batch| - batch.where('amount_used > 0').update_all('new_amount_used = amount_used') - end - end - - def down - # Non reversible migration. - # This data migration keeps `new_amount_used` in sync with the old `amount_used`. - # In case of failure or interruption the migration can be retried. - end -end diff --git a/db/post_migrate/20221011113928_redo_remove_and_add_ci_job_variables_raw_with_new_default.rb b/db/post_migrate/20221011113928_redo_remove_and_add_ci_job_variables_raw_with_new_default.rb deleted file mode 100644 index a377b78803e..00000000000 --- a/db/post_migrate/20221011113928_redo_remove_and_add_ci_job_variables_raw_with_new_default.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class RedoRemoveAndAddCiJobVariablesRawWithNewDefault < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - # We are removing and adding the same column with the same parameters to refresh the table - # because we have some wrong `ci_job_variables.raw` data (`TRUE`) in the database. - def change - remove_column :ci_job_variables, :raw, :boolean, null: false, default: false - add_column :ci_job_variables, :raw, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20221012182701_remove_namespace_settings_cohort_free_user_cap_columns.rb b/db/post_migrate/20221012182701_remove_namespace_settings_cohort_free_user_cap_columns.rb deleted file mode 100644 index 36408ad19ed..00000000000 --- a/db/post_migrate/20221012182701_remove_namespace_settings_cohort_free_user_cap_columns.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveNamespaceSettingsCohortFreeUserCapColumns < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def up - remove_column :namespace_settings, :exclude_from_free_user_cap - remove_column :namespace_settings, :include_for_free_user_cap_preview - end - - def down - add_column :namespace_settings, :exclude_from_free_user_cap, :boolean, null: false, default: false - add_column :namespace_settings, :include_for_free_user_cap_preview, :boolean, null: false, default: false - end -end diff --git a/db/post_migrate/20221013154159_update_invalid_dormant_user_setting.rb b/db/post_migrate/20221013154159_update_invalid_dormant_user_setting.rb deleted file mode 100644 index 1f1e47fdac1..00000000000 --- a/db/post_migrate/20221013154159_update_invalid_dormant_user_setting.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class UpdateInvalidDormantUserSetting < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - # rubocop:disable Layout/LineLength - def up - execute("update application_settings set deactivate_dormant_users_period=90 where deactivate_dormant_users_period < 90") - end - # rubocop:enable Layout/LineLength - - def down - # no-op - end -end diff --git a/db/post_migrate/20221013215832_cleanup_vulnerability_state_transitions_with_same_from_state_to_state.rb b/db/post_migrate/20221013215832_cleanup_vulnerability_state_transitions_with_same_from_state_to_state.rb deleted file mode 100644 index a81a80deb25..00000000000 --- a/db/post_migrate/20221013215832_cleanup_vulnerability_state_transitions_with_same_from_state_to_state.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class CleanupVulnerabilityStateTransitionsWithSameFromStateToState < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class VulnerabilityStateTransition < MigrationRecord - self.table_name = 'vulnerability_state_transitions' - end - - def up - VulnerabilityStateTransition.where('from_state = to_state').delete_all - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221017084227_cleanup_rename_ci_pipeline_metadata_title.rb b/db/post_migrate/20221017084227_cleanup_rename_ci_pipeline_metadata_title.rb deleted file mode 100644 index 0829f3d8734..00000000000 --- a/db/post_migrate/20221017084227_cleanup_rename_ci_pipeline_metadata_title.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupRenameCiPipelineMetadataTitle < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :ci_pipeline_metadata, :title, :name - end - - def down - undo_cleanup_concurrent_column_rename :ci_pipeline_metadata, :title, :name, batch_column_name: :pipeline_id - end -end diff --git a/db/post_migrate/20221018062308_schedule_backfill_project_namespace_details.rb b/db/post_migrate/20221018062308_schedule_backfill_project_namespace_details.rb deleted file mode 100644 index 74c8ef37ac2..00000000000 --- a/db/post_migrate/20221018062308_schedule_backfill_project_namespace_details.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillProjectNamespaceDetails < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillProjectNamespaceDetails' - INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 200 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20221018193635_ensure_task_note_renaming_background_migration_finished.rb b/db/post_migrate/20221018193635_ensure_task_note_renaming_background_migration_finished.rb deleted file mode 100644 index c6ae0f185d8..00000000000 --- a/db/post_migrate/20221018193635_ensure_task_note_renaming_background_migration_finished.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class EnsureTaskNoteRenamingBackgroundMigrationFinished < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'RenameTaskSystemNoteToChecklistItem' - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :system_note_metadata, - column_name: :id, - job_arguments: [] - ) - end - - def down - # noop - end -end diff --git a/db/post_migrate/20221018193827_drop_tmp_index_system_note_metadata_on_id_where_task.rb b/db/post_migrate/20221018193827_drop_tmp_index_system_note_metadata_on_id_where_task.rb deleted file mode 100644 index 5cc70c530c6..00000000000 --- a/db/post_migrate/20221018193827_drop_tmp_index_system_note_metadata_on_id_where_task.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropTmpIndexSystemNoteMetadataOnIdWhereTask < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_system_note_metadata_on_id_where_task' - - def up - remove_concurrent_index_by_name :system_note_metadata, INDEX_NAME - end - - def down - add_concurrent_index :system_note_metadata, [:id, :action], where: "action = 'task'", name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb b/db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb deleted file mode 100644 index 1cb93886ca3..00000000000 --- a/db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddTempIndexForUserDetailsFields < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_idx_where_user_details_fields_filled' - - disable_ddl_transaction! - - def up - # rubocop:disable Migration/PreventIndexCreation - add_concurrent_index :users, :id, name: INDEX_NAME, where: <<~QUERY - (COALESCE(linkedin, '') IS DISTINCT FROM '') - OR (COALESCE(twitter, '') IS DISTINCT FROM '') - OR (COALESCE(skype, '') IS DISTINCT FROM '') - OR (COALESCE(website_url, '') IS DISTINCT FROM '') - OR (COALESCE(location, '') IS DISTINCT FROM '') - OR (COALESCE(organization, '') IS DISTINCT FROM '') - QUERY - # rubocop:enable Migration/PreventIndexCreation - end - - def down - remove_concurrent_index_by_name :users, INDEX_NAME - end -end diff --git a/db/post_migrate/20221019002459_queue_backfill_user_details_fields.rb b/db/post_migrate/20221019002459_queue_backfill_user_details_fields.rb deleted file mode 100644 index 8ed4416a98d..00000000000 --- a/db/post_migrate/20221019002459_queue_backfill_user_details_fields.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class QueueBackfillUserDetailsFields < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillUserDetailsFields' - INTERVAL = 2.minutes - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration(MIGRATION, :users, :id, job_interval: INTERVAL) - end - - def down - delete_batched_background_migration(MIGRATION, :users, :id, []) - end -end diff --git a/db/post_migrate/20221019102426_remove_tmp_index_approval_merge_request_rules_on_report_type.rb b/db/post_migrate/20221019102426_remove_tmp_index_approval_merge_request_rules_on_report_type.rb deleted file mode 100644 index 7203d35de92..00000000000 --- a/db/post_migrate/20221019102426_remove_tmp_index_approval_merge_request_rules_on_report_type.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIndexApprovalMergeRequestRulesOnReportType < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_approval_merge_request_rules_on_report_type_equal_one' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :approval_merge_request_rules, INDEX_NAME - end - - def down - add_concurrent_index :approval_merge_request_rules, - [:id, :report_type], - name: INDEX_NAME, - where: "report_type = 1" - end -end diff --git a/db/post_migrate/20221019105041_queue_populate_projects_star_count.rb b/db/post_migrate/20221019105041_queue_populate_projects_star_count.rb deleted file mode 100644 index 768e0c7826f..00000000000 --- a/db/post_migrate/20221019105041_queue_populate_projects_star_count.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class QueuePopulateProjectsStarCount < Gitlab::Database::Migration[2.0] - MIGRATION = 'PopulateProjectsStarCount' - DELAY_INTERVAL = 2.minutes - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :projects, - :id, - job_interval: DELAY_INTERVAL, - sub_batch_size: 50 - ) - end - - def down - delete_batched_background_migration(MIGRATION, :projects, :id, []) - end -end diff --git a/db/post_migrate/20221019141508_add_index_to_test_reports_issue_id_created_at_and_id.rb b/db/post_migrate/20221019141508_add_index_to_test_reports_issue_id_created_at_and_id.rb deleted file mode 100644 index 054512adf2e..00000000000 --- a/db/post_migrate/20221019141508_add_index_to_test_reports_issue_id_created_at_and_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToTestReportsIssueIdCreatedAtAndId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = 'requirements_management_test_reports' - INDEX_NAME = 'idx_test_reports_on_issue_id_created_at_and_id' - - def up - add_concurrent_index TABLE_NAME, [:issue_id, :created_at, :id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME - end -end diff --git a/db/post_migrate/20221019194751_disable_fastupdate_on_issues_title_gin_index.rb b/db/post_migrate/20221019194751_disable_fastupdate_on_issues_title_gin_index.rb deleted file mode 100644 index 64d935489c2..00000000000 --- a/db/post_migrate/20221019194751_disable_fastupdate_on_issues_title_gin_index.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class DisableFastupdateOnIssuesTitleGinIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_title_trigram' - - def up - return unless index_exists_by_name?(:issues, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; - SQL - end - end - - def down - return unless index_exists_by_name?(:issues, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; - SQL - end - end -end diff --git a/db/post_migrate/20221019195754_disable_fastupdate_on_issues_description_gin_index.rb b/db/post_migrate/20221019195754_disable_fastupdate_on_issues_description_gin_index.rb deleted file mode 100644 index 8822cb3b414..00000000000 --- a/db/post_migrate/20221019195754_disable_fastupdate_on_issues_description_gin_index.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class DisableFastupdateOnIssuesDescriptionGinIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_description_trigram' - - def up - return unless index_exists_by_name?(:issues, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; - SQL - end - end - - def down - return unless index_exists_by_name?(:issues, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; - SQL - end - end -end diff --git a/db/post_migrate/20221019200033_disable_fastupdate_on_merge_requests_title_gin_index.rb b/db/post_migrate/20221019200033_disable_fastupdate_on_merge_requests_title_gin_index.rb deleted file mode 100644 index 3e1124dc2bb..00000000000 --- a/db/post_migrate/20221019200033_disable_fastupdate_on_merge_requests_title_gin_index.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class DisableFastupdateOnMergeRequestsTitleGinIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_merge_requests_on_title_trigram' - - def up - return unless index_exists_by_name?(:merge_requests, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; - SQL - end - end - - def down - return unless index_exists_by_name?(:merge_requests, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; - SQL - end - end -end diff --git a/db/post_migrate/20221019200206_disable_fastupdate_on_merge_requests_description_gin_index.rb b/db/post_migrate/20221019200206_disable_fastupdate_on_merge_requests_description_gin_index.rb deleted file mode 100644 index 7ab6f40e206..00000000000 --- a/db/post_migrate/20221019200206_disable_fastupdate_on_merge_requests_description_gin_index.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class DisableFastupdateOnMergeRequestsDescriptionGinIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_merge_requests_on_description_trigram' - - def up - return unless index_exists_by_name?(:merge_requests, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; - SQL - end - end - - def down - return unless index_exists_by_name?(:merge_requests, INDEX_NAME) - - with_lock_retries do - execute <<~SQL - ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; - SQL - end - end -end diff --git a/db/post_migrate/20221021082720_drop_index_on_ci_runners_token.rb b/db/post_migrate/20221021082720_drop_index_on_ci_runners_token.rb deleted file mode 100644 index 9125831fbf3..00000000000 --- a/db/post_migrate/20221021082720_drop_index_on_ci_runners_token.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnCiRunnersToken < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_runners_on_token' - - def up - remove_concurrent_index_by_name :ci_runners, INDEX_NAME - end - - def down - add_concurrent_index :ci_runners, - :token, - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221021082734_drop_index_on_ci_runners_token_encrypted.rb b/db/post_migrate/20221021082734_drop_index_on_ci_runners_token_encrypted.rb deleted file mode 100644 index 39771fb5f85..00000000000 --- a/db/post_migrate/20221021082734_drop_index_on_ci_runners_token_encrypted.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnCiRunnersTokenEncrypted < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_runners_on_token_encrypted' - - def up - remove_concurrent_index_by_name :ci_runners, INDEX_NAME - end - - def down - add_concurrent_index :ci_runners, - :token_encrypted, - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221021145820_create_routing_table_for_builds_metadata_v2.rb b/db/post_migrate/20221021145820_create_routing_table_for_builds_metadata_v2.rb deleted file mode 100644 index e5f1ba5cb87..00000000000 --- a/db/post_migrate/20221021145820_create_routing_table_for_builds_metadata_v2.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -class CreateRoutingTableForBuildsMetadataV2 < Gitlab::Database::Migration[2.0] - include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers - - disable_ddl_transaction! - - TABLE_NAME = :ci_builds_metadata - PARENT_TABLE_NAME = :p_ci_builds_metadata - FIRST_PARTITION = 100 - PARTITION_COLUMN = :partition_id - - def up - return if connection.table_exists?(PARENT_TABLE_NAME) && partition_attached? - - convert_table_to_first_list_partition( - table_name: TABLE_NAME, - partitioning_column: PARTITION_COLUMN, - parent_table_name: PARENT_TABLE_NAME, - initial_partitioning_value: FIRST_PARTITION, - lock_tables: [:ci_builds, :ci_builds_metadata] - ) - end - - def down - revert_converting_table_to_first_list_partition( - table_name: TABLE_NAME, - partitioning_column: PARTITION_COLUMN, - parent_table_name: PARENT_TABLE_NAME, - initial_partitioning_value: FIRST_PARTITION - ) - end - - private - - def partition_attached? - connection.select_value(<<~SQL) - SELECT true FROM postgres_partitions WHERE name = '#{TABLE_NAME}'; - SQL - end -end diff --git a/db/post_migrate/20221021160735_add_index_for_common_finder_query_desc_with_namespace_id.rb b/db/post_migrate/20221021160735_add_index_for_common_finder_query_desc_with_namespace_id.rb deleted file mode 100644 index d7c50010b72..00000000000 --- a/db/post_migrate/20221021160735_add_index_for_common_finder_query_desc_with_namespace_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForCommonFinderQueryDescWithNamespaceId < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_group_vulnerability_reads_common_finder_query_desc' - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerability_reads, - [:namespace_id, :state, :report_type, :severity, :vulnerability_id], - name: INDEX_NAME, - order: { severity: :desc, vulnerability_id: :desc } - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/post_migrate/20221024034228_remove_sprints_project_id_column.rb b/db/post_migrate/20221024034228_remove_sprints_project_id_column.rb deleted file mode 100644 index e30d6dce497..00000000000 --- a/db/post_migrate/20221024034228_remove_sprints_project_id_column.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -class RemoveSprintsProjectIdColumn < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - DATERANGE_CONSTRAINT_NAME = 'iteration_start_and_due_daterange_project_id_constraint' - - def up - with_lock_retries do - remove_column :sprints, :project_id, :bigint if column_exists?(:sprints, :project_id) - end - end - - def down - with_lock_retries do - add_column :sprints, :project_id, :bigint unless column_exists?(:sprints, :project_id) - end - - with_lock_retries do - next if check_constraint_exists?(:sprints, DATERANGE_CONSTRAINT_NAME) - - execute(<<~SQL) - ALTER TABLE sprints - ADD CONSTRAINT #{DATERANGE_CONSTRAINT_NAME} - EXCLUDE USING gist (project_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) - WHERE (project_id IS NOT NULL) - SQL - end - - add_check_constraint(:sprints, - 'project_id <> NULL::bigint AND group_id IS NULL OR group_id <> NULL::bigint AND project_id IS NULL', - 'sprints_must_belong_to_project_or_group') - - add_concurrent_index :sprints, [:project_id, :iid], unique: true, name: 'index_sprints_on_project_id_and_iid' - - add_concurrent_foreign_key :sprints, :projects, column: :project_id, on_delete: :cascade - end -end diff --git a/db/post_migrate/20221024121500_drop_fingerprint_from_sbom_sources.rb b/db/post_migrate/20221024121500_drop_fingerprint_from_sbom_sources.rb deleted file mode 100644 index 83856cbe5dd..00000000000 --- a/db/post_migrate/20221024121500_drop_fingerprint_from_sbom_sources.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class DropFingerprintFromSbomSources < Gitlab::Database::Migration[2.0] - enable_lock_retries! - - def change - remove_column :sbom_sources, :fingerprint, :bytea - end -end diff --git a/db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb b/db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb deleted file mode 100644 index 2ab7f8a9c04..00000000000 --- a/db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class CheckVulnerabilitiesStateTransitionFromStateNotEqualToState < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_check_constraint(:vulnerability_state_transitions, '(from_state != to_state)', constraint_name) - end - - def down - remove_check_constraint(:vulnerability_state_transitions, constraint_name) - end - - private - - def constraint_name - check_constraint_name('vulnerability_state_transitions', 'fully_qualified_table_name', 'state_not_equal') - end -end diff --git a/db/post_migrate/20221025220607_add_index_id_on_scan_finding_approval_merge_request_rules.rb b/db/post_migrate/20221025220607_add_index_id_on_scan_finding_approval_merge_request_rules.rb deleted file mode 100644 index 4e72e7f95ec..00000000000 --- a/db/post_migrate/20221025220607_add_index_id_on_scan_finding_approval_merge_request_rules.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexIdOnScanFindingApprovalMergeRequestRules < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'scan_finding_approval_mr_rule_index_id' - SCAN_FINDING_REPORT_TYPE = 4 - - disable_ddl_transaction! - - def up - add_concurrent_index :approval_merge_request_rules, :id, - where: "report_type = #{SCAN_FINDING_REPORT_TYPE}", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :approval_merge_request_rules, INDEX_NAME - end -end diff --git a/db/post_migrate/20221027203556_delete_experiment_user_foreign_keys.rb b/db/post_migrate/20221027203556_delete_experiment_user_foreign_keys.rb deleted file mode 100644 index 564dc3d4899..00000000000 --- a/db/post_migrate/20221027203556_delete_experiment_user_foreign_keys.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class DeleteExperimentUserForeignKeys < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists :experiment_users, :experiments, name: 'fk_rails_56d4708b4a' - end - - with_lock_retries do - remove_foreign_key_if_exists :experiment_users, :users, name: 'fk_rails_fd805f771a' - end - end - - def down - add_concurrent_foreign_key :experiment_users, :experiments, column: :experiment_id, name: 'fk_rails_56d4708b4a' - add_concurrent_foreign_key :experiment_users, :users, column: :user_id, name: 'fk_rails_fd805f771a' - end -end diff --git a/db/post_migrate/20221027203951_drop_experiment_users_table.rb b/db/post_migrate/20221027203951_drop_experiment_users_table.rb deleted file mode 100644 index 838a9605740..00000000000 --- a/db/post_migrate/20221027203951_drop_experiment_users_table.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class DropExperimentUsersTable < Gitlab::Database::Migration[2.0] - def up - drop_table :experiment_users - end - - def down - create_table :experiment_users do |t| - t.bigint :experiment_id, null: false - t.bigint :user_id, null: false - t.integer :group_type, limit: 2, null: false, default: 0 - t.timestamps_with_timezone null: false - t.datetime_with_timezone :converted_at - t.jsonb :context, null: false, default: {} - end - - add_index :experiment_users, :experiment_id - add_index :experiment_users, :user_id - end -end diff --git a/db/post_migrate/20221028000041_remove_invalid_partial_trigram_indexes_for_issues.rb b/db/post_migrate/20221028000041_remove_invalid_partial_trigram_indexes_for_issues.rb deleted file mode 100644 index 9b46647047a..00000000000 --- a/db/post_migrate/20221028000041_remove_invalid_partial_trigram_indexes_for_issues.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveInvalidPartialTrigramIndexesForIssues < Gitlab::Database::Migration[2.0] - TITLE_INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :issues, TITLE_INDEX_NAME - remove_concurrent_index_by_name :issues, DESCRIPTION_INDEX_NAME - end - - def down; end -end diff --git a/db/post_migrate/20221028000603_prepare_partial_trigram_indexes_for_issues_attempt_3.rb b/db/post_migrate/20221028000603_prepare_partial_trigram_indexes_for_issues_attempt_3.rb deleted file mode 100644 index 199a7a22d5b..00000000000 --- a/db/post_migrate/20221028000603_prepare_partial_trigram_indexes_for_issues_attempt_3.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class PreparePartialTrigramIndexesForIssuesAttempt3 < Gitlab::Database::Migration[2.0] - TITLE_INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - def up - prepare_async_index :issues, :title, - name: TITLE_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*' " \ - "OR description NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*'" - - prepare_async_index :issues, :description, - name: DESCRIPTION_INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*' " \ - "OR description NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*'" - end - - def down - unprepare_async_index_by_name :issues, DESCRIPTION_INDEX_NAME - unprepare_async_index_by_name :issues, TITLE_INDEX_NAME - end -end diff --git a/db/post_migrate/20221028022627_add_index_on_password_last_changed_at_to_user_details.rb b/db/post_migrate/20221028022627_add_index_on_password_last_changed_at_to_user_details.rb deleted file mode 100644 index 8314767ade1..00000000000 --- a/db/post_migrate/20221028022627_add_index_on_password_last_changed_at_to_user_details.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnPasswordLastChangedAtToUserDetails < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_user_details_on_password_last_changed_at' - - disable_ddl_transaction! - - def up - add_concurrent_index :user_details, :password_last_changed_at, name: INDEX_NAME, comment: 'JiHu-specific index' - end - - def down - remove_concurrent_index_by_name :user_details, INDEX_NAME - end -end diff --git a/db/post_migrate/20221102090940_create_next_ci_partitions_record.rb b/db/post_migrate/20221102090940_create_next_ci_partitions_record.rb deleted file mode 100644 index 4bd89a70daa..00000000000 --- a/db/post_migrate/20221102090940_create_next_ci_partitions_record.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class CreateNextCiPartitionsRecord < Gitlab::Database::Migration[2.0] - NEXT_PARTITION_ID = 101 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - def up - return unless Gitlab.com? - - execute(<<~SQL) - INSERT INTO "ci_partitions" ("id", "created_at", "updated_at") - VALUES (#{NEXT_PARTITION_ID}, now(), now()) - ON CONFLICT DO NOTHING; - SQL - - reset_pk_sequence!('ci_partitions') - end - - def down - return unless Gitlab.com? - - execute(<<~SQL) - DELETE FROM "ci_partitions" - WHERE "ci_partitions"."id" = #{NEXT_PARTITION_ID}; - SQL - end -end diff --git a/db/post_migrate/20221102090943_create_second_partition_for_builds_metadata.rb b/db/post_migrate/20221102090943_create_second_partition_for_builds_metadata.rb deleted file mode 100644 index 6923e6f6cba..00000000000 --- a/db/post_migrate/20221102090943_create_second_partition_for_builds_metadata.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -class CreateSecondPartitionForBuildsMetadata < Gitlab::Database::Migration[2.0] - TABLE_NAME = 'p_ci_builds_metadata' - BUILDS_TABLE = 'ci_builds' - NEXT_PARTITION_ID = 101 - PARTITION_NAME = 'gitlab_partitions_dynamic.ci_builds_metadata_101' - - disable_ddl_transaction! - - def up - return unless Gitlab.com? - - with_lock_retries(**lock_args) do - connection.execute(<<~SQL) - LOCK TABLE #{BUILDS_TABLE} IN SHARE UPDATE EXCLUSIVE MODE; - LOCK TABLE ONLY #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE; - SQL - - connection.execute(<<~SQL) - CREATE TABLE IF NOT EXISTS #{PARTITION_NAME} - PARTITION OF #{TABLE_NAME} - FOR VALUES IN (#{NEXT_PARTITION_ID}); - SQL - end - end - - def down - return unless Gitlab.com? - return unless table_exists?(PARTITION_NAME) - - with_lock_retries(**lock_args) do - connection.execute(<<~SQL) - LOCK TABLE #{BUILDS_TABLE}, #{TABLE_NAME}, #{PARTITION_NAME} IN ACCESS EXCLUSIVE MODE; - SQL - - connection.execute(<<~SQL) - ALTER TABLE #{TABLE_NAME} DETACH PARTITION #{PARTITION_NAME}; - SQL - - connection.execute(<<~SQL) - DROP TABLE IF EXISTS #{PARTITION_NAME} CASCADE; - SQL - end - end - - private - - def lock_args - { - raise_on_exhaustion: true, - timing_configuration: lock_timing_configuration - } - end - - def lock_timing_configuration - iterations = Gitlab::Database::WithLockRetries::DEFAULT_TIMING_CONFIGURATION - aggressive_iterations = Array.new(5) { [10.seconds, 1.minute] } - - iterations + aggressive_iterations - end -end diff --git a/db/post_migrate/20221103073328_change_member_namespace_id_not_null.rb b/db/post_migrate/20221103073328_change_member_namespace_id_not_null.rb deleted file mode 100644 index 19f6732d297..00000000000 --- a/db/post_migrate/20221103073328_change_member_namespace_id_not_null.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class ChangeMemberNamespaceIdNotNull < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_not_null_constraint :members, :member_namespace_id, validate: false - end - - def down - remove_not_null_constraint :members, :member_namespace_id - end -end diff --git a/db/post_migrate/20221103084213_remove_tmp_index_members_on_id_where_namespace_id_null.rb b/db/post_migrate/20221103084213_remove_tmp_index_members_on_id_where_namespace_id_null.rb deleted file mode 100644 index 07908e697f5..00000000000 --- a/db/post_migrate/20221103084213_remove_tmp_index_members_on_id_where_namespace_id_null.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveTmpIndexMembersOnIdWhereNamespaceIdNull < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_members_on_id_where_namespace_id_null' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :members, INDEX_NAME - end - - def down - add_concurrent_index :members, :id, name: INDEX_NAME, where: 'member_namespace_id IS NULL' - end -end diff --git a/db/post_migrate/20221103150250_migrate_sidekiq_queued_jobs.rb b/db/post_migrate/20221103150250_migrate_sidekiq_queued_jobs.rb deleted file mode 100644 index 1934711f9ef..00000000000 --- a/db/post_migrate/20221103150250_migrate_sidekiq_queued_jobs.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class MigrateSidekiqQueuedJobs < Gitlab::Database::Migration[2.0] - def up - # no-op because of https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1991 - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221104042137_add_partial_trigram_index_for_issue_title_attempt_2.rb b/db/post_migrate/20221104042137_add_partial_trigram_index_for_issue_title_attempt_2.rb deleted file mode 100644 index 24204577959..00000000000 --- a/db/post_migrate/20221104042137_add_partial_trigram_index_for_issue_title_attempt_2.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddPartialTrigramIndexForIssueTitleAttempt2 < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_title_trigram_non_latin' - - def up - add_concurrent_index :issues, :title, - name: INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*' " \ - "OR description NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*'" - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20221104042159_add_partial_trigram_index_for_issue_description_attempt_2.rb b/db/post_migrate/20221104042159_add_partial_trigram_index_for_issue_description_attempt_2.rb deleted file mode 100644 index 36b595d1067..00000000000 --- a/db/post_migrate/20221104042159_add_partial_trigram_index_for_issue_description_attempt_2.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddPartialTrigramIndexForIssueDescriptionAttempt2 < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_description_trigram_non_latin' - - def up - add_concurrent_index :issues, :description, - name: INDEX_NAME, - using: :gin, opclass: { description: :gin_trgm_ops }, - where: "title NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*' " \ - "OR description NOT SIMILAR TO '[\\u0000-\\u02FF\\u1E00-\\u1EFF\\u2070-\\u218F]*'" - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20221104074652_add_temp_index_for_project_statistics_upload_size_migration.rb b/db/post_migrate/20221104074652_add_temp_index_for_project_statistics_upload_size_migration.rb deleted file mode 100644 index b6ee636fa9b..00000000000 --- a/db/post_migrate/20221104074652_add_temp_index_for_project_statistics_upload_size_migration.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddTempIndexForProjectStatisticsUploadSizeMigration < Gitlab::Database::Migration[2.0] - INDEX_PROJECT_STATSISTICS_UPLOADS_SIZE = 'tmp_index_project_statistics_uploads_size' - - disable_ddl_transaction! - - def up - # Temporary index is to be used to trigger refresh for all project_statistics with - # upload_size <> 0 - add_concurrent_index :project_statistics, [:project_id], - name: INDEX_PROJECT_STATSISTICS_UPLOADS_SIZE, - where: "uploads_size <> 0" - end - - def down - remove_concurrent_index_by_name :project_statistics, INDEX_PROJECT_STATSISTICS_UPLOADS_SIZE - end -end diff --git a/db/post_migrate/20221104100203_recreate_async_trigram_index_for_vulnerability_reads_container_images.rb b/db/post_migrate/20221104100203_recreate_async_trigram_index_for_vulnerability_reads_container_images.rb deleted file mode 100644 index ea2914f4dc4..00000000000 --- a/db/post_migrate/20221104100203_recreate_async_trigram_index_for_vulnerability_reads_container_images.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RecreateAsyncTrigramIndexForVulnerabilityReadsContainerImages < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_vulnerability_reads_on_location_image_trigram' - REPORT_TYPES = { container_scanning: 2, cluster_image_scanning: 7 }.freeze - - def up - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - - prepare_async_index :vulnerability_reads, :location_image, - name: INDEX_NAME, - using: :gin, opclass: { location_image: :gin_trgm_ops }, - where: "report_type = ANY (ARRAY[#{REPORT_TYPES.values.join(', ')}]) AND location_image IS NOT NULL" - end - - def down - unprepare_async_index :vulnerability_reads, :location_image, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221104170500_add_vulnerability_reads_all_status_index.rb b/db/post_migrate/20221104170500_add_vulnerability_reads_all_status_index.rb deleted file mode 100644 index 1dc1921ebaa..00000000000 --- a/db/post_migrate/20221104170500_add_vulnerability_reads_all_status_index.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true -class AddVulnerabilityReadsAllStatusIndex < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_vulnerability_reads_on_namespace_type_severity_id' - - disable_ddl_transaction! - - def up - add_concurrent_index :vulnerability_reads, %i[namespace_id report_type severity vulnerability_id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME - end -end diff --git a/db/post_migrate/20221104190203_validate_environment_id_on_deployments.rb b/db/post_migrate/20221104190203_validate_environment_id_on_deployments.rb deleted file mode 100644 index 9546daa3975..00000000000 --- a/db/post_migrate/20221104190203_validate_environment_id_on_deployments.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class ValidateEnvironmentIdOnDeployments < Gitlab::Database::Migration[2.0] - def up - validate_foreign_key :deployments, :environment_id - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221107094359_recount_epic_cache_counts.rb b/db/post_migrate/20221107094359_recount_epic_cache_counts.rb deleted file mode 100644 index 37ab952edba..00000000000 --- a/db/post_migrate/20221107094359_recount_epic_cache_counts.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RecountEpicCacheCounts < Gitlab::Database::Migration[2.0] - MIGRATION = 'RecountEpicCacheCounts' - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 200 - MAX_BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 20 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :epics, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE, - gitlab_schema: :gitlab_main - ) - end - - def down - delete_batched_background_migration(MIGRATION, :epics, :id, []) - end -end diff --git a/db/post_migrate/20221107184758_sync_new_amount_used_for_ci_namespace_monthly_usages.rb b/db/post_migrate/20221107184758_sync_new_amount_used_for_ci_namespace_monthly_usages.rb deleted file mode 100644 index 9a6014b5c94..00000000000 --- a/db/post_migrate/20221107184758_sync_new_amount_used_for_ci_namespace_monthly_usages.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class SyncNewAmountUsedForCiNamespaceMonthlyUsages < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - def up - namespace_usages = define_batchable_model('ci_namespace_monthly_usages') - - namespace_usages.each_batch(of: 500) do |batch| - batch.where('amount_used > 0').update_all('new_amount_used = amount_used') - end - end - - def down - # Non reversible migration. - # This data migration keeps `new_amount_used` in sync with the old `amount_used`. - # In case of failure or interruption the migration can be retried. - end -end diff --git a/db/post_migrate/20221107220420_validate_not_null_constraint_on_member_namespace_id.rb b/db/post_migrate/20221107220420_validate_not_null_constraint_on_member_namespace_id.rb deleted file mode 100644 index 48da0c1fd09..00000000000 --- a/db/post_migrate/20221107220420_validate_not_null_constraint_on_member_namespace_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ValidateNotNullConstraintOnMemberNamespaceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - CONSTRAINT_NAME = 'check_508774aac0' - - def up - validate_not_null_constraint :members, :member_namespace_id, constraint_name: CONSTRAINT_NAME - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221107220526_validate_fk_member_namespace_id.rb b/db/post_migrate/20221107220526_validate_fk_member_namespace_id.rb deleted file mode 100644 index f78dc5a36fd..00000000000 --- a/db/post_migrate/20221107220526_validate_fk_member_namespace_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class ValidateFkMemberNamespaceId < Gitlab::Database::Migration[2.0] - CONSTRAINT_NAME = 'fk_2f85abf8f1' - - def up - validate_foreign_key :members, :member_namespace_id, name: CONSTRAINT_NAME - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221107222213_remove_old_member_namespace_id_fk.rb b/db/post_migrate/20221107222213_remove_old_member_namespace_id_fk.rb deleted file mode 100644 index d46fa80336e..00000000000 --- a/db/post_migrate/20221107222213_remove_old_member_namespace_id_fk.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class RemoveOldMemberNamespaceIdFk < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TARGET_COLUMN = :member_namespace_id - - def up - with_lock_retries do - remove_foreign_key_if_exists(:members, column: TARGET_COLUMN, name: fk_name(TARGET_COLUMN)) - end - end - - def down - add_concurrent_foreign_key( - :members, - :namespaces, - column: TARGET_COLUMN, - name: fk_name(TARGET_COLUMN), - on_delete: :nullify - ) - end - - def fk_name(column_name) - # generate a FK name - concurrent_foreign_key_name(:members, column_name) - end -end diff --git a/db/post_migrate/20221108045019_truncate_timeline_event_tags_table.rb b/db/post_migrate/20221108045019_truncate_timeline_event_tags_table.rb deleted file mode 100644 index a576f9e860f..00000000000 --- a/db/post_migrate/20221108045019_truncate_timeline_event_tags_table.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class TruncateTimelineEventTagsTable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - return unless Gitlab::Database.gitlab_schemas_for_connection(connection).include?(:gitlab_main) - - execute('TRUNCATE TABLE incident_management_timeline_event_tags, incident_management_timeline_event_tag_links') - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221108121322_add_supporting_index_for_vulnerabilities_feedback_migration.rb b/db/post_migrate/20221108121322_add_supporting_index_for_vulnerabilities_feedback_migration.rb deleted file mode 100644 index c77930512d2..00000000000 --- a/db/post_migrate/20221108121322_add_supporting_index_for_vulnerabilities_feedback_migration.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddSupportingIndexForVulnerabilitiesFeedbackMigration < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_idx_for_vulnerability_feedback_migration" - WHERE_CLAUSE = "migrated_to_state_transition = false AND feedback_type = 0" - - disable_ddl_transaction! - - def up - add_concurrent_index( - :vulnerability_feedback, - %i[migrated_to_state_transition feedback_type], - where: WHERE_CLAUSE, - name: INDEX_NAME - ) - end - - def down - remove_concurrent_index_by_name( - :vulnerability_feedback, - INDEX_NAME - ) - end -end diff --git a/db/post_migrate/20221108222015_remove_temp_index_on_project_features_where_releases_access_level_gt_repository.rb b/db/post_migrate/20221108222015_remove_temp_index_on_project_features_where_releases_access_level_gt_repository.rb deleted file mode 100644 index e7cc6786b4b..00000000000 --- a/db/post_migrate/20221108222015_remove_temp_index_on_project_features_where_releases_access_level_gt_repository.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveTempIndexOnProjectFeaturesWhereReleasesAccessLevelGtRepository < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_idx_project_features_on_releases_al_and_repo_al_partial' - - def up - remove_concurrent_index_by_name :project_features, INDEX_NAME - end - - def down - add_concurrent_index :project_features, - [:releases_access_level, :repository_access_level], - name: INDEX_NAME, - where: 'releases_access_level > repository_access_level' - end -end diff --git a/db/post_migrate/20221110045406_sanitize_confidential_note_todos.rb b/db/post_migrate/20221110045406_sanitize_confidential_note_todos.rb deleted file mode 100644 index d409a4dfdd1..00000000000 --- a/db/post_migrate/20221110045406_sanitize_confidential_note_todos.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class SanitizeConfidentialNoteTodos < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # no-op: this empty migration is left here only for compatibility reasons. - # It was a temporary migration which used not-isolated code. - # https://gitlab.com/gitlab-org/gitlab/-/issues/382557 - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221111070314_prepare_removal_of_issue_trigram_indexes.rb b/db/post_migrate/20221111070314_prepare_removal_of_issue_trigram_indexes.rb deleted file mode 100644 index c4cae19497e..00000000000 --- a/db/post_migrate/20221111070314_prepare_removal_of_issue_trigram_indexes.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class PrepareRemovalOfIssueTrigramIndexes < Gitlab::Database::Migration[2.0] - TITLE_INDEX_NAME = 'index_issues_on_title_trigram' - DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram' - - def up - prepare_async_index_removal :issues, :title, name: TITLE_INDEX_NAME - prepare_async_index_removal :issues, :description, name: DESCRIPTION_INDEX_NAME - end - - def down - unprepare_async_index_by_name :issues, DESCRIPTION_INDEX_NAME - unprepare_async_index_by_name :issues, TITLE_INDEX_NAME - end -end diff --git a/db/post_migrate/20230113003255_remove_atlassian_refresh_token_constraint.rb b/db/post_migrate/20230113003255_remove_atlassian_refresh_token_constraint.rb index 81c3f10c0f6..7929d4495c0 100644 --- a/db/post_migrate/20230113003255_remove_atlassian_refresh_token_constraint.rb +++ b/db/post_migrate/20230113003255_remove_atlassian_refresh_token_constraint.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class RemoveAtlassianRefreshTokenConstraint < Gitlab::Database::Migration[2.1] CONSTRAINT_NAME = 'atlassian_identities_refresh_token_length_constraint' diff --git a/db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb b/db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb index 19020fecad5..28a600c459f 100644 --- a/db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb +++ b/db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class BackfillNamespaceLdapSettings < Gitlab::Database::Migration[2.1] restrict_gitlab_migration gitlab_schema: :gitlab_main disable_ddl_transaction! diff --git a/db/post_migrate/20230124104310_prepare_web_hook_logs_id_created_at_async_index.rb b/db/post_migrate/20230124104310_prepare_web_hook_logs_id_created_at_async_index.rb index ea087265c90..d22fda092d3 100644 --- a/db/post_migrate/20230124104310_prepare_web_hook_logs_id_created_at_async_index.rb +++ b/db/post_migrate/20230124104310_prepare_web_hook_logs_id_created_at_async_index.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class PrepareWebHookLogsIdCreatedAtAsyncIndex < Gitlab::Database::Migration[2.1] include Gitlab::Database::PartitioningMigrationHelpers diff --git a/db/post_migrate/20230313150531_reschedule_migration_for_remediation.rb b/db/post_migrate/20230313150531_reschedule_migration_for_remediation.rb index 01d5c3a79b0..cef9c2338e9 100644 --- a/db/post_migrate/20230313150531_reschedule_migration_for_remediation.rb +++ b/db/post_migrate/20230313150531_reschedule_migration_for_remediation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop: disable BackgroundMigration/DictionaryFile +# rubocop:disable BackgroundMigration/DictionaryFile -- MigrateRemediationsForVulnerabilityFindings is rescheduled class RescheduleMigrationForRemediation < Gitlab::Database::Migration[2.1] MIGRATION = 'MigrateRemediationsForVulnerabilityFindings' @@ -29,4 +29,4 @@ class RescheduleMigrationForRemediation < Gitlab::Database::Migration[2.1] delete_batched_background_migration(MIGRATION, :vulnerability_occurrences, :id, []) end end -# rubocop: enable BackgroundMigration/DictionaryFile +# rubocop:enable BackgroundMigration/DictionaryFile diff --git a/db/post_migrate/20230315161408_finalize_set_notifications_bigint_conversion_backfill.rb b/db/post_migrate/20230315161408_finalize_set_notifications_bigint_conversion_backfill.rb index d4a6d86d9cb..2f83fc15672 100644 --- a/db/post_migrate/20230315161408_finalize_set_notifications_bigint_conversion_backfill.rb +++ b/db/post_migrate/20230315161408_finalize_set_notifications_bigint_conversion_backfill.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class FinalizeSetNotificationsBigintConversionBackfill < Gitlab::Database::Migration[2.1] include Gitlab::Database::MigrationHelpers::ConvertToBigint restrict_gitlab_migration gitlab_schema: :gitlab_main diff --git a/db/post_migrate/20230328184031_swap_sent_notifications_id_columns.rb b/db/post_migrate/20230328184031_swap_sent_notifications_id_columns.rb index a2a0751c38a..b6215565b50 100644 --- a/db/post_migrate/20230328184031_swap_sent_notifications_id_columns.rb +++ b/db/post_migrate/20230328184031_swap_sent_notifications_id_columns.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class SwapSentNotificationsIdColumns < Gitlab::Database::Migration[2.1] include Gitlab::Database::MigrationHelpers::ConvertToBigint diff --git a/db/post_migrate/20230404061832_drop_sync_index_ci_job_artifacts_on_expire_at_for_removal.rb b/db/post_migrate/20230404061832_drop_sync_index_ci_job_artifacts_on_expire_at_for_removal.rb index efa0792c457..491ec0c02d5 100644 --- a/db/post_migrate/20230404061832_drop_sync_index_ci_job_artifacts_on_expire_at_for_removal.rb +++ b/db/post_migrate/20230404061832_drop_sync_index_ci_job_artifacts_on_expire_at_for_removal.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropSyncIndexCiJobArtifactsOnExpireAtForRemoval < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_ci_job_artifacts_on_expire_at_for_removal' CONDITIONS = 'locked = 0 AND expire_at IS NOT NULL' diff --git a/db/post_migrate/20230405200858_requeue_backfill_project_wiki_repositories.rb b/db/post_migrate/20230405200858_requeue_backfill_project_wiki_repositories.rb index 6c4792d0d6c..6a67110ce68 100644 --- a/db/post_migrate/20230405200858_requeue_backfill_project_wiki_repositories.rb +++ b/db/post_migrate/20230405200858_requeue_backfill_project_wiki_repositories.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable BackgroundMigration/DictionaryFile +# rubocop:disable BackgroundMigration/DictionaryFile -- BackfillProjectWikiRepositories is rescheduled class RequeueBackfillProjectWikiRepositories < Gitlab::Database::Migration[2.1] MIGRATION = "BackfillProjectWikiRepositories" DELAY_INTERVAL = 2.minutes diff --git a/db/post_migrate/20230420065656_finalize_fix_incoherent_packages_size_on_project_statistics.rb b/db/post_migrate/20230420065656_finalize_fix_incoherent_packages_size_on_project_statistics.rb index aa03310eb0a..8932c52d445 100644 --- a/db/post_migrate/20230420065656_finalize_fix_incoherent_packages_size_on_project_statistics.rb +++ b/db/post_migrate/20230420065656_finalize_fix_incoherent_packages_size_on_project_statistics.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class FinalizeFixIncoherentPackagesSizeOnProjectStatistics < Gitlab::Database::Migration[2.1] MIGRATION = 'FixIncoherentPackagesSizeOnProjectStatistics' disable_ddl_transaction! diff --git a/db/post_migrate/20230427194552_drop_cycle_analytics_unused_tables.rb b/db/post_migrate/20230427194552_drop_cycle_analytics_unused_tables.rb index 7c10238a1bc..be3f80389b0 100644 --- a/db/post_migrate/20230427194552_drop_cycle_analytics_unused_tables.rb +++ b/db/post_migrate/20230427194552_drop_cycle_analytics_unused_tables.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropCycleAnalyticsUnusedTables < Gitlab::Database::Migration[2.1] disable_ddl_transaction! diff --git a/db/post_migrate/20230501094322_prepare_removal_partial_index_deployments_for_project_id_and_tag.rb b/db/post_migrate/20230501094322_prepare_removal_partial_index_deployments_for_project_id_and_tag.rb index bbdfb89bb80..1c0edcd5c44 100644 --- a/db/post_migrate/20230501094322_prepare_removal_partial_index_deployments_for_project_id_and_tag.rb +++ b/db/post_migrate/20230501094322_prepare_removal_partial_index_deployments_for_project_id_and_tag.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class PrepareRemovalPartialIndexDeploymentsForProjectIdAndTag < Gitlab::Database::Migration[2.1] INDEX_NAME = 'partial_index_deployments_for_project_id_and_tag' diff --git a/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb b/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb index 3eb5fc13a2a..0d60a816c02 100644 --- a/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb +++ b/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsCertManagers < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_cert_managers diff --git a/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb b/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb index 2c7b7d89bf5..e7755c940a5 100644 --- a/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb +++ b/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsCilium < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_cilium diff --git a/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb b/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb index 1eeb7770c82..9262f7d9955 100644 --- a/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb +++ b/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsCrossplane < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_crossplane diff --git a/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb b/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb index c435b356e01..2efa53e5b31 100644 --- a/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb +++ b/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsHelm < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_helm diff --git a/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb b/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb index 3ccc536cb7e..409c9c49b1c 100644 --- a/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb +++ b/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsIngress < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_ingress diff --git a/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb b/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb index bd98aa6d19c..35bddba301a 100644 --- a/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb +++ b/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsJupyter < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_jupyter diff --git a/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb b/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb index e8473b74408..38f28eca109 100644 --- a/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb +++ b/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsKnative < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_knative diff --git a/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb b/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb index b62452f2052..35db7cbed47 100644 --- a/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb +++ b/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsPrometheus < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_prometheus diff --git a/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb b/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb index a4ab75dbce5..fb177b5a1de 100644 --- a/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb +++ b/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropClustersApplicationsRunners < Gitlab::Database::Migration[2.1] def up drop_table :clusters_applications_runners diff --git a/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb b/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb index 003f2d91b54..b68b7e85285 100644 --- a/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb +++ b/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropServerlessDomainCluster < Gitlab::Database::Migration[2.1] def up drop_table :serverless_domain_cluster diff --git a/db/post_migrate/20230508150219_reschedule_evidences_handling_unicode.rb b/db/post_migrate/20230508150219_reschedule_evidences_handling_unicode.rb index ed23df4405e..3ea17f81bee 100644 --- a/db/post_migrate/20230508150219_reschedule_evidences_handling_unicode.rb +++ b/db/post_migrate/20230508150219_reschedule_evidences_handling_unicode.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable BackgroundMigration/DictionaryFile +# rubocop:disable BackgroundMigration/DictionaryFile -- MigrateEvidencesForVulnerabilityFindings is rescheduled class RescheduleEvidencesHandlingUnicode < Gitlab::Database::Migration[2.1] restrict_gitlab_migration gitlab_schema: :gitlab_main diff --git a/db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb b/db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb index 6c0e4e722d2..2b5d7424450 100644 --- a/db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb +++ b/db/post_migrate/20230515153600_finalize_back_fill_prepared_at_merge_requests.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class FinalizeBackFillPreparedAtMergeRequests < Gitlab::Database::Migration[2.1] disable_ddl_transaction! diff --git a/db/post_migrate/20230522111534_reschedule_migration_for_links_from_metadata.rb b/db/post_migrate/20230522111534_reschedule_migration_for_links_from_metadata.rb index f49b158593f..5178a2c574c 100644 --- a/db/post_migrate/20230522111534_reschedule_migration_for_links_from_metadata.rb +++ b/db/post_migrate/20230522111534_reschedule_migration_for_links_from_metadata.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop: disable BackgroundMigration/DictionaryFile +# rubocop:disable BackgroundMigration/DictionaryFile -- MigrateLinksForVulnerabilityFindings is rescheduled class RescheduleMigrationForLinksFromMetadata < Gitlab::Database::Migration[2.1] MIGRATION = 'MigrateLinksForVulnerabilityFindings' @@ -29,4 +29,4 @@ class RescheduleMigrationForLinksFromMetadata < Gitlab::Database::Migration[2.1] delete_batched_background_migration(MIGRATION, :vulnerability_occurrences, :id, []) end end -# rubocop: enable BackgroundMigration/DictionaryFile +# rubocop:enable BackgroundMigration/DictionaryFile diff --git a/db/post_migrate/20230605192000_drop_tmp_index_oauth_access_tokens_on_id_where_expires_in_null.rb b/db/post_migrate/20230605192000_drop_tmp_index_oauth_access_tokens_on_id_where_expires_in_null.rb index c74df0a5cdd..b82c2dfb8ed 100644 --- a/db/post_migrate/20230605192000_drop_tmp_index_oauth_access_tokens_on_id_where_expires_in_null.rb +++ b/db/post_migrate/20230605192000_drop_tmp_index_oauth_access_tokens_on_id_where_expires_in_null.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropTmpIndexOauthAccessTokensOnIdWhereExpiresInNull < Gitlab::Database::Migration[2.1] TMP_INDEX = 'tmp_index_oauth_access_tokens_on_id_where_expires_in_null' diff --git a/db/post_migrate/20230615030402_remove_audit_events_group_index.rb b/db/post_migrate/20230615030402_remove_audit_events_group_index.rb index 9a77d7a4d0d..ff75a04b0f4 100644 --- a/db/post_migrate/20230615030402_remove_audit_events_group_index.rb +++ b/db/post_migrate/20230615030402_remove_audit_events_group_index.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class RemoveAuditEventsGroupIndex < Gitlab::Database::Migration[2.1] include Gitlab::Database::PartitioningMigrationHelpers diff --git a/db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb b/db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb index 77ddd909215..3ab42c70d8a 100644 --- a/db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb +++ b/db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class PrepareRemovalIndexDeploymentsOnProjectIdSha < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_deployments_on_project_id_sha' diff --git a/db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb b/db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb index 0c9a292eb8c..0098eaabf76 100644 --- a/db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb +++ b/db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class PrepareRemovalIndexDeploymentsOnProjectIdAndStatus < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_deployments_on_project_id_and_status' diff --git a/db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb b/db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb index 6171b58ac53..204579d6e18 100644 --- a/db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb +++ b/db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class PrepareRemovalIndexDeploymentsOnEnvironmentIdAndIidAndProjectId < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_deployments_on_environment_id_and_iid_and_project_id' diff --git a/db/post_migrate/20230712052619_drop_index_deployments_on_project_id_and_status.rb b/db/post_migrate/20230712052619_drop_index_deployments_on_project_id_and_status.rb index 0c76b73dcdc..5dea67a5d16 100644 --- a/db/post_migrate/20230712052619_drop_index_deployments_on_project_id_and_status.rb +++ b/db/post_migrate/20230712052619_drop_index_deployments_on_project_id_and_status.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropIndexDeploymentsOnProjectIdAndStatus < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_deployments_on_project_id_and_status' diff --git a/db/post_migrate/20230712054057_drop_index_deployments_on_project_id_sha.rb b/db/post_migrate/20230712054057_drop_index_deployments_on_project_id_sha.rb index 9916ee7f9ba..edb0ee98d43 100644 --- a/db/post_migrate/20230712054057_drop_index_deployments_on_project_id_sha.rb +++ b/db/post_migrate/20230712054057_drop_index_deployments_on_project_id_sha.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropIndexDeploymentsOnProjectIdSha < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_deployments_on_project_id_sha' diff --git a/db/post_migrate/20230712055956_drop_index_deployments_on_environment_id_and_iid_and_project_id.rb b/db/post_migrate/20230712055956_drop_index_deployments_on_environment_id_and_iid_and_project_id.rb index 52a02e68d14..4791baf9d9e 100644 --- a/db/post_migrate/20230712055956_drop_index_deployments_on_environment_id_and_iid_and_project_id.rb +++ b/db/post_migrate/20230712055956_drop_index_deployments_on_environment_id_and_iid_and_project_id.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropIndexDeploymentsOnEnvironmentIdAndIidAndProjectId < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_deployments_on_environment_id_and_iid_and_project_id' diff --git a/db/post_migrate/20230717062445_backfill_ci_stages_pipeline_id_conversion.rb b/db/post_migrate/20230717062445_backfill_ci_stages_pipeline_id_conversion.rb index d93517fb49b..c0a5c577403 100644 --- a/db/post_migrate/20230717062445_backfill_ci_stages_pipeline_id_conversion.rb +++ b/db/post_migrate/20230717062445_backfill_ci_stages_pipeline_id_conversion.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class BackfillCiStagesPipelineIdConversion < Gitlab::Database::Migration[2.1] restrict_gitlab_migration gitlab_schema: :gitlab_ci diff --git a/db/post_migrate/20230724150939_index_projects_on_namespace_id_and_repository_size_limit.rb b/db/post_migrate/20230724150939_index_projects_on_namespace_id_and_repository_size_limit.rb index fd2387e2bc4..2a60e948007 100644 --- a/db/post_migrate/20230724150939_index_projects_on_namespace_id_and_repository_size_limit.rb +++ b/db/post_migrate/20230724150939_index_projects_on_namespace_id_and_repository_size_limit.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class IndexProjectsOnNamespaceIdAndRepositorySizeLimit < Gitlab::Database::Migration[2.1] INDEX_NAME = "index_projects_on_namespace_id_and_repository_size_limit" diff --git a/db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb b/db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb index 43b4db7d9b5..b5986967214 100644 --- a/db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb +++ b/db/post_migrate/20230726080827_add_issue_search_data_namespace_id_foreign_key.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddIssueSearchDataNamespaceIdForeignKey < Gitlab::Database::Migration[2.1] include Gitlab::Database::PartitioningMigrationHelpers diff --git a/db/post_migrate/20230818034041_prepare_removal_index_success_deployments_on_cluster_id_and_environment_id.rb b/db/post_migrate/20230818034041_prepare_removal_index_success_deployments_on_cluster_id_and_environment_id.rb index 39a45774676..db40584bb3a 100644 --- a/db/post_migrate/20230818034041_prepare_removal_index_success_deployments_on_cluster_id_and_environment_id.rb +++ b/db/post_migrate/20230818034041_prepare_removal_index_success_deployments_on_cluster_id_and_environment_id.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class PrepareRemovalIndexSuccessDeploymentsOnClusterIdAndEnvironmentId < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_successful_deployments_on_cluster_id_and_environment_id' diff --git a/db/post_migrate/20230906181457_add_index_to_violations_on_target_proj_id.rb b/db/post_migrate/20230906181457_add_index_to_violations_on_target_proj_id.rb index 13c76a3c2de..a51fbd0a00a 100644 --- a/db/post_migrate/20230906181457_add_index_to_violations_on_target_proj_id.rb +++ b/db/post_migrate/20230906181457_add_index_to_violations_on_target_proj_id.rb @@ -2,7 +2,7 @@ class AddIndexToViolationsOnTargetProjId < Gitlab::Database::Migration[2.1] TABLE_NAME = 'merge_requests_compliance_violations' - # Use funciton based naming as suggested in docs: + # Use function based naming as suggested in docs: # https://docs.gitlab.com/ee/development/migration_style_guide.html#truncate-long-index-names INDEX_NAME = 'i_compliance_violations_for_export' diff --git a/db/post_migrate/20230912105945_queue_backfill_finding_id_in_vulnerabilities.rb b/db/post_migrate/20230912105945_queue_backfill_finding_id_in_vulnerabilities.rb index 3275f6e729d..5b51c8c3d67 100644 --- a/db/post_migrate/20230912105945_queue_backfill_finding_id_in_vulnerabilities.rb +++ b/db/post_migrate/20230912105945_queue_backfill_finding_id_in_vulnerabilities.rb @@ -8,18 +8,9 @@ class QueueBackfillFindingIdInVulnerabilities < Gitlab::Database::Migration[2.1] restrict_gitlab_migration gitlab_schema: :gitlab_main - def up - queue_batched_background_migration( - MIGRATION, - :vulnerabilities, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end + # marking no-op + # per https://docs.gitlab.com/ee/development/database/batched_background_migrations.html#requeuing-batched-background-migrations + def up; end - def down - delete_batched_background_migration(MIGRATION, :vulnerabilities, :id, []) - end + def down; end end diff --git a/db/post_migrate/20230929095008_drop_application_settings_product_analytics_cluster_settings.rb b/db/post_migrate/20230929095008_drop_application_settings_product_analytics_cluster_settings.rb index b759ee21912..d8a7f0017fa 100644 --- a/db/post_migrate/20230929095008_drop_application_settings_product_analytics_cluster_settings.rb +++ b/db/post_migrate/20230929095008_drop_application_settings_product_analytics_cluster_settings.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropApplicationSettingsProductAnalyticsClusterSettings < Gitlab::Database::Migration[2.1] disable_ddl_transaction! diff --git a/db/post_migrate/20230929095728_drop_project_settings_product_analytics_cluster_settings.rb b/db/post_migrate/20230929095728_drop_project_settings_product_analytics_cluster_settings.rb index e6f0c29fb7a..d8054a34a4b 100644 --- a/db/post_migrate/20230929095728_drop_project_settings_product_analytics_cluster_settings.rb +++ b/db/post_migrate/20230929095728_drop_project_settings_product_analytics_cluster_settings.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropProjectSettingsProductAnalyticsClusterSettings < Gitlab::Database::Migration[2.1] disable_ddl_transaction! diff --git a/db/post_migrate/20231001105945_requeue_backfill_finding_id_in_vulnerabilities.rb b/db/post_migrate/20231001105945_requeue_backfill_finding_id_in_vulnerabilities.rb index 8115ad199ce..9004176595e 100644 --- a/db/post_migrate/20231001105945_requeue_backfill_finding_id_in_vulnerabilities.rb +++ b/db/post_migrate/20231001105945_requeue_backfill_finding_id_in_vulnerabilities.rb @@ -8,18 +8,9 @@ class RequeueBackfillFindingIdInVulnerabilities < Gitlab::Database::Migration[2. restrict_gitlab_migration gitlab_schema: :gitlab_main - def up - queue_batched_background_migration( - MIGRATION, - :vulnerabilities, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end + # marking no-op + # per https://docs.gitlab.com/ee/development/database/batched_background_migrations.html#requeuing-batched-background-migrations + def up; end - def down - delete_batched_background_migration(MIGRATION, :vulnerabilities, :id, []) - end + def down; end end diff --git a/db/post_migrate/20231011142714_queue_backfill_has_remediations_of_vulnerability_reads.rb b/db/post_migrate/20231011142714_queue_backfill_has_remediations_of_vulnerability_reads.rb index 2c1eebbfaa5..12de83a384e 100644 --- a/db/post_migrate/20231011142714_queue_backfill_has_remediations_of_vulnerability_reads.rb +++ b/db/post_migrate/20231011142714_queue_backfill_has_remediations_of_vulnerability_reads.rb @@ -9,19 +9,15 @@ class QueueBackfillHasRemediationsOfVulnerabilityReads < Gitlab::Database::Migra restrict_gitlab_migration gitlab_schema: :gitlab_main disable_ddl_transaction! - def up - queue_batched_background_migration( - MIGRATION, - :vulnerability_reads, - :vulnerability_id, - job_interval: DELAY_INTERVAL, - queued_migration_version: '20231011142714', - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end + # per: https://docs.gitlab.com/ee/development/database/batched_background_migrations.html#requeuing-batched-background-migrations + # > When you requeue the batched background migration, turn the original queuing + # > into a no-op by clearing up the #up and #down methods of the migration + # > performing the requeuing. Otherwise, the batched background migration is + # > queued multiple times on systems that are upgrading multiple patch releases + # > at once. + # + # being re-run via https://gitlab.com/gitlab-org/gitlab/-/merge_requests/135747 + def up; end - def down - delete_batched_background_migration(MIGRATION, :vulnerability_reads, :vulnerability_id, []) - end + def down; end end diff --git a/db/post_migrate/20231012180342_index_stopping_environments_on_updated_at.rb b/db/post_migrate/20231012180342_index_stopping_environments_on_updated_at.rb index 3b9332ab0f8..cca6ed23fef 100644 --- a/db/post_migrate/20231012180342_index_stopping_environments_on_updated_at.rb +++ b/db/post_migrate/20231012180342_index_stopping_environments_on_updated_at.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class IndexStoppingEnvironmentsOnUpdatedAt < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_environments_on_updated_at_for_stopping_state' diff --git a/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb b/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb index 3f4009d783c..8d6173fc7ca 100644 --- a/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb +++ b/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb @@ -16,7 +16,6 @@ class QueueDeleteInvalidProtectedBranchMergeAccessLevels < Gitlab::Database::Mig :protected_branch_merge_access_levels, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231016173129', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb b/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb index 6accaa3296b..32022ff8be0 100644 --- a/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb +++ b/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb @@ -16,7 +16,6 @@ class QueueDeleteInvalidProtectedBranchPushAccessLevels < Gitlab::Database::Migr :protected_branch_push_access_levels, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231016194927', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb b/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb index 5880124d0a6..f96f1c3b380 100644 --- a/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb +++ b/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb @@ -15,7 +15,6 @@ class QueueDeleteInvalidProtectedTagCreateAccessLevels < Gitlab::Database::Migra :protected_tag_create_access_levels, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231016194943', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231023113908_add_index_stopping_environments_on_updated_at.rb b/db/post_migrate/20231023113908_add_index_stopping_environments_on_updated_at.rb index 01fe32d6bd7..5df8625c24c 100644 --- a/db/post_migrate/20231023113908_add_index_stopping_environments_on_updated_at.rb +++ b/db/post_migrate/20231023113908_add_index_stopping_environments_on_updated_at.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddIndexStoppingEnvironmentsOnUpdatedAt < Gitlab::Database::Migration[2.1] INDEX_NAME = 'index_environments_on_updated_at_for_stopping_state' diff --git a/db/post_migrate/20231024073401_cleanup_ci_pipeline_variables_pipeline_id_bigint.rb b/db/post_migrate/20231024073401_cleanup_ci_pipeline_variables_pipeline_id_bigint.rb new file mode 100644 index 00000000000..bbc2abadcec --- /dev/null +++ b/db/post_migrate/20231024073401_cleanup_ci_pipeline_variables_pipeline_id_bigint.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class CleanupCiPipelineVariablesPipelineIdBigint < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE = :ci_pipeline_variables + REFERENCING_TABLE = :ci_pipelines + COLUMNS = [:pipeline_id] + INDEX_NAME = :index_ci_pipeline_variables_on_pipeline_id_bigint_and_key + FK_NAME = :temp_fk_rails_8d3b04e3e1 + + def up + with_lock_retries(raise_on_exhaustion: true) do + lock_tables(:ci_pipelines, TABLE) + cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + end + + def down + restore_conversion_of_integer_to_bigint(TABLE, COLUMNS) + + add_concurrent_index( + TABLE, [:pipeline_id_convert_to_bigint, :key], + name: INDEX_NAME, unique: true + ) + add_concurrent_foreign_key( + TABLE, REFERENCING_TABLE, + column: :pipeline_id_convert_to_bigint, name: FK_NAME, + on_delete: :cascade, validate: true, reverse_lock_order: true + ) + end +end diff --git a/db/post_migrate/20231027093009_drop_index_project_topics_on_project_id.rb b/db/post_migrate/20231027093009_drop_index_project_topics_on_project_id.rb new file mode 100644 index 00000000000..87d0e923565 --- /dev/null +++ b/db/post_migrate/20231027093009_drop_index_project_topics_on_project_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexProjectTopicsOnProjectId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_project_topics_on_project_id + TABLE_NAME = :project_topics + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :project_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231029134824_remove_deployments_cluster_id.rb b/db/post_migrate/20231029134824_remove_deployments_cluster_id.rb new file mode 100644 index 00000000000..11ab9370ad2 --- /dev/null +++ b/db/post_migrate/20231029134824_remove_deployments_cluster_id.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class RemoveDeploymentsClusterId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + def up + with_lock_retries do + remove_column :deployments, :cluster_id, if_exists: true + end + end + + def down + with_lock_retries do + add_column :deployments, :cluster_id, :integer, if_not_exists: true + end + + add_concurrent_index(:deployments, [:cluster_id, :status]) + end +end diff --git a/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb b/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb index 4984eb83263..1197e31dea8 100644 --- a/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb +++ b/db/post_migrate/20231030071209_queue_backfill_packages_tags_project_id.rb @@ -16,7 +16,6 @@ class QueueBackfillPackagesTagsProjectId < Gitlab::Database::Migration[2.2] :packages_tags, :id, job_interval: DELAY_INTERVAL, - queued_migration_version: '20231030071209', batch_size: BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) diff --git a/db/post_migrate/20231031204841_requeue_backfill_has_remediations_of_vulnerability_reads.rb b/db/post_migrate/20231031204841_requeue_backfill_has_remediations_of_vulnerability_reads.rb new file mode 100644 index 00000000000..0cff65db72f --- /dev/null +++ b/db/post_migrate/20231031204841_requeue_backfill_has_remediations_of_vulnerability_reads.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +# rubocop: disable BackgroundMigration/DictionaryFile -- queued/introduced before the rule is introduced + +class RequeueBackfillHasRemediationsOfVulnerabilityReads < Gitlab::Database::Migration[2.2] + milestone '16.7' + + MIGRATION = "BackfillHasRemediationsOfVulnerabilityReads" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 10_000 + SUB_BATCH_SIZE = 50 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + # per: https://docs.gitlab.com/ee/development/database/batched_background_migrations.html#requeuing-batched-background-migrations + # > When you requeue the batched background migration, turn the original queuing + # > into a no-op by clearing up the #up and #down methods of the migration + # > performing the requeuing. Otherwise, the batched background migration is + # > queued multiple times on systems that are upgrading multiple patch releases + # > at once. + def up; end + + def down; end +end +# rubocop: enable BackgroundMigration/DictionaryFile diff --git a/db/post_migrate/20220809223215_change_task_system_note_wording_to_checklist_item.rb b/db/post_migrate/20231107092912_queue_backfill_branch_protection_namespace_setting.rb index df7c2d325d2..28af287c75b 100644 --- a/db/post_migrate/20220809223215_change_task_system_note_wording_to_checklist_item.rb +++ b/db/post_migrate/20231107092912_queue_backfill_branch_protection_namespace_setting.rb @@ -1,28 +1,27 @@ # frozen_string_literal: true -class ChangeTaskSystemNoteWordingToChecklistItem < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - MIGRATION = 'RenameTaskSystemNoteToChecklistItem' +class QueueBackfillBranchProtectionNamespaceSetting < Gitlab::Database::Migration[2.2] + milestone "16.7" + MIGRATION = "BackfillBranchProtectionNamespaceSetting" DELAY_INTERVAL = 2.minutes BATCH_SIZE = 10_000 - MAX_BATCH_SIZE = 20_000 SUB_BATCH_SIZE = 100 + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + def up queue_batched_background_migration( MIGRATION, - :system_note_metadata, - :id, + :namespace_settings, + :namespace_id, job_interval: DELAY_INTERVAL, batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, sub_batch_size: SUB_BATCH_SIZE ) end def down - delete_batched_background_migration(MIGRATION, :system_note_metadata, :id, []) + delete_batched_background_migration(MIGRATION, :namespace_settings, :namespace_id, []) end end diff --git a/db/post_migrate/20231109120223_ensure_id_uniqueness_for_p_ci_builds_v4.rb b/db/post_migrate/20231109120223_ensure_id_uniqueness_for_p_ci_builds_v4.rb new file mode 100644 index 00000000000..994755dbd28 --- /dev/null +++ b/db/post_migrate/20231109120223_ensure_id_uniqueness_for_p_ci_builds_v4.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +class EnsureIdUniquenessForPCiBuildsV4 < Gitlab::Database::Migration[2.2] + include Gitlab::Database::SchemaHelpers + include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum + + enable_lock_retries! + milestone '16.7' + + TABLE_NAME = :p_ci_builds + FUNCTION_NAME = :assign_p_ci_builds_id_value + TRIGGER_NAME = :assign_p_ci_builds_id_trigger + + def up + return unless should_run? + + lock_tables(TABLE_NAME, :ci_builds) + + Gitlab::Database::PostgresPartitionedTable.each_partition(TABLE_NAME) do |partition| + drop_trigger(partition.identifier, TRIGGER_NAME, if_exists: true) + end + + create_trigger(TABLE_NAME, TRIGGER_NAME, FUNCTION_NAME, fires: 'BEFORE INSERT') + end + + def down + return unless should_run? + + drop_trigger(TABLE_NAME, TRIGGER_NAME, if_exists: true) + return if trigger_exists?(:ci_builds, TRIGGER_NAME) + + Gitlab::Database::PostgresPartitionedTable.each_partition(TABLE_NAME) do |partition| + create_trigger(partition.identifier, TRIGGER_NAME, FUNCTION_NAME, fires: 'BEFORE INSERT') + end + end + + private + + def should_run? + can_execute_on?(:ci_builds) + end +end diff --git a/db/post_migrate/20231109124031_ensure_id_uniqueness_for_p_ci_builds_v5.rb b/db/post_migrate/20231109124031_ensure_id_uniqueness_for_p_ci_builds_v5.rb new file mode 100644 index 00000000000..e3b082b41ad --- /dev/null +++ b/db/post_migrate/20231109124031_ensure_id_uniqueness_for_p_ci_builds_v5.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class EnsureIdUniquenessForPCiBuildsV5 < Gitlab::Database::Migration[2.2] + include Gitlab::Database::SchemaHelpers + + enable_lock_retries! + milestone '16.7' + + TABLE_NAME = :p_ci_builds + FUNCTION_NAME = :assign_p_ci_builds_id_value + TRIGGER_NAME = :assign_p_ci_builds_id_trigger + + def up + return if trigger_exists?(TABLE_NAME, TRIGGER_NAME) + + lock_tables(TABLE_NAME, :ci_builds) + + Gitlab::Database::PostgresPartitionedTable.each_partition(TABLE_NAME) do |partition| + drop_trigger(partition.identifier, TRIGGER_NAME, if_exists: true) + end + + create_trigger(TABLE_NAME, TRIGGER_NAME, FUNCTION_NAME, fires: 'BEFORE INSERT') + end + + def down + drop_trigger(TABLE_NAME, TRIGGER_NAME, if_exists: true) + return if trigger_exists?(:ci_builds, TRIGGER_NAME) + + Gitlab::Database::PostgresPartitionedTable.each_partition(TABLE_NAME) do |partition| + create_trigger(partition.identifier, TRIGGER_NAME, FUNCTION_NAME, fires: 'BEFORE INSERT') + end + end +end diff --git a/db/post_migrate/20231110173626_drop_merge_requests_on_author_id_index.rb b/db/post_migrate/20231110173626_drop_merge_requests_on_author_id_index.rb new file mode 100644 index 00000000000..fac5f0ad679 --- /dev/null +++ b/db/post_migrate/20231110173626_drop_merge_requests_on_author_id_index.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class DropMergeRequestsOnAuthorIdIndex < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = 'index_merge_requests_on_author_id' + TABLE_NAME = :merge_requests + + def up + # Duplicated index. This index is covered by +index_merge_requests_on_author_id_and_created_at+ + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :author_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231113025718_drop_index_users_require_two_factor_authentication_from_group_false.rb b/db/post_migrate/20231113025718_drop_index_users_require_two_factor_authentication_from_group_false.rb new file mode 100644 index 00000000000..28fc0bab5a0 --- /dev/null +++ b/db/post_migrate/20231113025718_drop_index_users_require_two_factor_authentication_from_group_false.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class DropIndexUsersRequireTwoFactorAuthenticationFromGroupFalse < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :users + INDEX_NAME = :index_users_require_two_factor_authentication_from_group_false + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :require_two_factor_authentication_from_group, + where: 'require_two_factor_authentication_from_group = FALSE', + name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231113025733_drop_index_users_require_two_factor_authentication_from_group.rb b/db/post_migrate/20231113025733_drop_index_users_require_two_factor_authentication_from_group.rb new file mode 100644 index 00000000000..769f4c38179 --- /dev/null +++ b/db/post_migrate/20231113025733_drop_index_users_require_two_factor_authentication_from_group.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class DropIndexUsersRequireTwoFactorAuthenticationFromGroup < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :users + INDEX_NAME = :index_users_on_require_two_factor_authentication_from_group + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :require_two_factor_authentication_from_group, + where: 'require_two_factor_authentication_from_group = TRUE', + name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231113142618_remove_users_state_duplicated_index.rb b/db/post_migrate/20231113142618_remove_users_state_duplicated_index.rb new file mode 100644 index 00000000000..dbc018dc027 --- /dev/null +++ b/db/post_migrate/20231113142618_remove_users_state_duplicated_index.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class RemoveUsersStateDuplicatedIndex < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_users_on_state + TABLE_NAME = :users + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :state, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231113164909_drop_index_users_on_accepted_term_id.rb b/db/post_migrate/20231113164909_drop_index_users_on_accepted_term_id.rb new file mode 100644 index 00000000000..2cbf68efd25 --- /dev/null +++ b/db/post_migrate/20231113164909_drop_index_users_on_accepted_term_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexUsersOnAcceptedTermId < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + TABLE_NAME = 'users' + INDEX_NAME = 'index_users_on_accepted_term_id' + COLUMN = 'accepted_term_id' + + def up + remove_concurrent_index_by_name TABLE_NAME, name: INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, COLUMN, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231114000727_drop_index_namespaces_on_require_two_factor_authentication.rb b/db/post_migrate/20231114000727_drop_index_namespaces_on_require_two_factor_authentication.rb new file mode 100644 index 00000000000..fa61cdead56 --- /dev/null +++ b/db/post_migrate/20231114000727_drop_index_namespaces_on_require_two_factor_authentication.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class DropIndexNamespacesOnRequireTwoFactorAuthentication < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :namespaces + INDEX_NAME = :index_namespaces_on_require_two_factor_authentication + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :require_two_factor_authentication, + name: INDEX_NAME + end +end diff --git a/db/post_migrate/20220601040233_finalize_backfill_issue_search_data.rb b/db/post_migrate/20231114015857_finalize_packages_tags_project_id_backfill.rb index 7b5cd405fa8..3f98aff31ad 100644 --- a/db/post_migrate/20220601040233_finalize_backfill_issue_search_data.rb +++ b/db/post_migrate/20231114015857_finalize_packages_tags_project_id_backfill.rb @@ -1,15 +1,16 @@ # frozen_string_literal: true -class FinalizeBackfillIssueSearchData < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillIssueSearchData' +class FinalizePackagesTagsProjectIdBackfill < Gitlab::Database::Migration[2.2] disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main + milestone '16.7' + + MIGRATION = 'BackfillPackagesTagsProjectId' def up ensure_batched_background_migration_is_finished( job_class_name: MIGRATION, - table_name: :issues, + table_name: :packages_tags, column_name: :id, job_arguments: [], finalize: true diff --git a/db/post_migrate/20231114015923_validate_packages_tags_project_id_null_constraint.rb b/db/post_migrate/20231114015923_validate_packages_tags_project_id_null_constraint.rb new file mode 100644 index 00000000000..36a37f8ce4e --- /dev/null +++ b/db/post_migrate/20231114015923_validate_packages_tags_project_id_null_constraint.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ValidatePackagesTagsProjectIdNullConstraint < Gitlab::Database::Migration[2.2] + milestone '16.7' + + def up + validate_not_null_constraint :packages_tags, :project_id + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20231114034309_add_merge_request_diffs_project_id_not_null_constraint.rb b/db/post_migrate/20231114034309_add_merge_request_diffs_project_id_not_null_constraint.rb new file mode 100644 index 00000000000..7f947001d39 --- /dev/null +++ b/db/post_migrate/20231114034309_add_merge_request_diffs_project_id_not_null_constraint.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class AddMergeRequestDiffsProjectIdNotNullConstraint < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + def up + add_not_null_constraint :merge_request_diffs, :project_id, validate: false + end + + def down + remove_not_null_constraint :merge_request_diffs, :project_id + end +end 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 new file mode 100644 index 00000000000..1c783b922ae --- /dev/null +++ b/db/post_migrate/20231114034507_add_merge_request_diffs_project_id_index_async.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddMergeRequestDiffsProjectIdIndexAsync < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + INDEX_NAME = 'index_merge_request_diffs_on_project_id' + + def up + prepare_async_index :merge_request_diffs, :project_id, name: INDEX_NAME + end + + def down + unprepare_async_index :merge_request_diffs, :project_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231114043522_queue_backfill_merge_request_diffs_project_id.rb b/db/post_migrate/20231114043522_queue_backfill_merge_request_diffs_project_id.rb new file mode 100644 index 00000000000..19448243fdc --- /dev/null +++ b/db/post_migrate/20231114043522_queue_backfill_merge_request_diffs_project_id.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class QueueBackfillMergeRequestDiffsProjectId < Gitlab::Database::Migration[2.2] + milestone '16.7' + restrict_gitlab_migration gitlab_schema: :gitlab_main + + MIGRATION = "BackfillMergeRequestDiffsProjectId" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 10000 + SUB_BATCH_SIZE = 100 + + def up + queue_batched_background_migration( + MIGRATION, + :merge_request_diffs, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :merge_request_diffs, :id, []) + end +end diff --git a/db/post_migrate/20231114053330_cleanup_ci_pipelines_auto_canceled_by_id_bigint.rb b/db/post_migrate/20231114053330_cleanup_ci_pipelines_auto_canceled_by_id_bigint.rb new file mode 100644 index 00000000000..489403f42bf --- /dev/null +++ b/db/post_migrate/20231114053330_cleanup_ci_pipelines_auto_canceled_by_id_bigint.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class CleanupCiPipelinesAutoCanceledByIdBigint < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone "16.7" + + TABLE = :ci_pipelines + REFERENCING_TABLE = :ci_pipelines + COLUMN = :auto_canceled_by_id + OLD_COLUMN = :auto_canceled_by_id_convert_to_bigint + INDEX_NAME = :index_ci_pipelines_on_auto_canceled_by_id_bigint + OLD_FK_NAME = :fk_67e4288f3a + + def up + with_lock_retries(raise_on_exhaustion: true) do + cleanup_conversion_of_integer_to_bigint(TABLE, [COLUMN]) + end + end + + def down + restore_conversion_of_integer_to_bigint(TABLE, [COLUMN]) + + add_concurrent_index(TABLE, OLD_COLUMN, name: INDEX_NAME) + + add_concurrent_foreign_key( + TABLE, TABLE, + column: OLD_COLUMN, name: OLD_FK_NAME, + on_delete: :nullify, validate: true, reverse_lock_order: true + ) + end +end diff --git a/db/post_migrate/20231114091935_remove_member_namespace_id_index_from_members.rb b/db/post_migrate/20231114091935_remove_member_namespace_id_index_from_members.rb new file mode 100644 index 00000000000..26379f47778 --- /dev/null +++ b/db/post_migrate/20231114091935_remove_member_namespace_id_index_from_members.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveMemberNamespaceIdIndexFromMembers < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = 'index_members_on_member_namespace_id' + + def up + remove_concurrent_index_by_name :members, INDEX_NAME + end + + def down + add_concurrent_index :members, :member_namespace_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231115104943_remove_service_access_tokens_category_column.rb b/db/post_migrate/20231115104943_remove_service_access_tokens_category_column.rb new file mode 100644 index 00000000000..42879d1e70d --- /dev/null +++ b/db/post_migrate/20231115104943_remove_service_access_tokens_category_column.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveServiceAccessTokensCategoryColumn < Gitlab::Database::Migration[2.2] + milestone '16.7' + + def change + remove_column :service_access_tokens, :category, :integer, limit: 2, default: 0, null: false + end +end diff --git a/db/post_migrate/20231115172623_remove_name_description_trigram_indexes_from_catalog_resources.rb b/db/post_migrate/20231115172623_remove_name_description_trigram_indexes_from_catalog_resources.rb new file mode 100644 index 00000000000..4dc02efa0be --- /dev/null +++ b/db/post_migrate/20231115172623_remove_name_description_trigram_indexes_from_catalog_resources.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class RemoveNameDescriptionTrigramIndexesFromCatalogResources < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + NAME_TRIGRAM_INDEX = 'index_catalog_resources_on_name_trigram' + DESCRIPTION_TRIGRAM_INDEX = 'index_catalog_resources_on_description_trigram' + + def up + remove_concurrent_index_by_name :catalog_resources, NAME_TRIGRAM_INDEX + remove_concurrent_index_by_name :catalog_resources, DESCRIPTION_TRIGRAM_INDEX + end + + def down + add_concurrent_index :catalog_resources, :name, name: NAME_TRIGRAM_INDEX, + using: :gin, opclass: { name: :gin_trgm_ops } + + add_concurrent_index :catalog_resources, :description, name: DESCRIPTION_TRIGRAM_INDEX, + using: :gin, opclass: { description: :gin_trgm_ops } + end +end diff --git a/db/post_migrate/20231116105945_requeue_backfill_finding_id_in_vulnerabilities2.rb b/db/post_migrate/20231116105945_requeue_backfill_finding_id_in_vulnerabilities2.rb new file mode 100644 index 00000000000..5713df95be3 --- /dev/null +++ b/db/post_migrate/20231116105945_requeue_backfill_finding_id_in_vulnerabilities2.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class RequeueBackfillFindingIdInVulnerabilities2 < Gitlab::Database::Migration[2.2] + milestone '16.7' + + # marking as no-op as per our database guidelines + def up; end + + def down; end +end diff --git a/db/post_migrate/20231120070345_cleanup_ci_stages_pipeline_id_bigint.rb b/db/post_migrate/20231120070345_cleanup_ci_stages_pipeline_id_bigint.rb new file mode 100644 index 00000000000..c9238eb7272 --- /dev/null +++ b/db/post_migrate/20231120070345_cleanup_ci_stages_pipeline_id_bigint.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +class CleanupCiStagesPipelineIdBigint < Gitlab::Database::Migration[2.2] + include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum + + disable_ddl_transaction! + milestone "16.7" + + TABLE = :ci_stages + REFERENCING_TABLE = :ci_pipelines + COLUMN = :pipeline_id + OLD_COLUMN = :pipeline_id_convert_to_bigint + INDEXES = { + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_name' => [ + [:pipeline_id_convert_to_bigint, :name], { unique: true } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint' => [ + [:pipeline_id_convert_to_bigint], {} + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_id' => [ + [:pipeline_id_convert_to_bigint, :id], { where: 'status = ANY (ARRAY[0, 1, 2, 8, 9, 10])' } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_position' => [ + [:pipeline_id_convert_to_bigint, :position], {} + ] + } + OLD_FK_NAME = :fk_c5ddde695f + + def up + return unless can_execute_on?(:ci_pipelines, :ci_stages) + + with_lock_retries(raise_on_exhaustion: true) do + lock_tables(REFERENCING_TABLE, TABLE) + cleanup_conversion_of_integer_to_bigint(TABLE, [COLUMN]) + end + end + + def down + return unless can_execute_on?(:ci_pipelines, :ci_stages) + + restore_conversion_of_integer_to_bigint(TABLE, [COLUMN]) + + INDEXES.each do |index_name, (columns, options)| + add_concurrent_index(TABLE, columns, name: index_name, **options) + end + + add_concurrent_foreign_key( + TABLE, REFERENCING_TABLE, + column: OLD_COLUMN, name: OLD_FK_NAME, + on_delete: :cascade, validate: true, reverse_lock_order: true + ) + end +end diff --git a/db/post_migrate/20231120161159_prepare_index_for_org_id_and_id_on_projects.rb b/db/post_migrate/20231120161159_prepare_index_for_org_id_and_id_on_projects.rb new file mode 100644 index 00000000000..1a49f8ee43f --- /dev/null +++ b/db/post_migrate/20231120161159_prepare_index_for_org_id_and_id_on_projects.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class PrepareIndexForOrgIdAndIdOnProjects < Gitlab::Database::Migration[2.2] + milestone '16.7' + + INDEX_NAME = 'index_projects_on_organization_id_and_id' + + def up + prepare_async_index :projects, [:organization_id, :id], name: INDEX_NAME + end + + def down + unprepare_async_index :projects, [:organization_id, :id], name: INDEX_NAME + end +end 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 new file mode 100644 index 00000000000..5576e9d534e --- /dev/null +++ b/db/post_migrate/20231121040153_add_merge_request_diffs_project_id_index.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddMergeRequestDiffsProjectIdIndex < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + INDEX_NAME = 'index_merge_request_diffs_on_project_id' + + def up + add_concurrent_index :merge_request_diffs, :project_id, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :merge_request_diffs, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231121040212_add_merge_request_diffs_project_id_foreign_key.rb b/db/post_migrate/20231121040212_add_merge_request_diffs_project_id_foreign_key.rb new file mode 100644 index 00000000000..91d4c532629 --- /dev/null +++ b/db/post_migrate/20231121040212_add_merge_request_diffs_project_id_foreign_key.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddMergeRequestDiffsProjectIdForeignKey < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + def up + add_concurrent_foreign_key :merge_request_diffs, :projects, + column: :project_id, on_delete: :cascade, validate: false + end + + def down + with_lock_retries do + remove_foreign_key :merge_request_diffs, column: :project_id + end + end +end diff --git a/db/post_migrate/20231122011731_drop_index_users_on_email_trigram.rb b/db/post_migrate/20231122011731_drop_index_users_on_email_trigram.rb new file mode 100644 index 00000000000..79e30651237 --- /dev/null +++ b/db/post_migrate/20231122011731_drop_index_users_on_email_trigram.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class DropIndexUsersOnEmailTrigram < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :users + INDEX_NAME = :index_users_on_email_trigram + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :email, name: INDEX_NAME, + using: :gin, opclass: { email: :gin_trgm_ops } + end +end diff --git a/db/post_migrate/20231122084642_remove_partition_id_default_value_for_job_artifact_state.rb b/db/post_migrate/20231122084642_remove_partition_id_default_value_for_job_artifact_state.rb new file mode 100644 index 00000000000..3a1e9c2e6a9 --- /dev/null +++ b/db/post_migrate/20231122084642_remove_partition_id_default_value_for_job_artifact_state.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class RemovePartitionIdDefaultValueForJobArtifactState < Gitlab::Database::Migration[2.2] + milestone '16.7' + enable_lock_retries! + + def up + change_column_default :ci_job_artifact_states, :partition_id, from: 100, to: nil + end + + def down + change_column_default :ci_job_artifact_states, :partition_id, from: nil, to: 100 + end +end diff --git a/db/post_migrate/20231122100006_remove_custom_email_smtp_columns_from_service_desk_settings.rb b/db/post_migrate/20231122100006_remove_custom_email_smtp_columns_from_service_desk_settings.rb new file mode 100644 index 00000000000..98bb15dd76e --- /dev/null +++ b/db/post_migrate/20231122100006_remove_custom_email_smtp_columns_from_service_desk_settings.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class RemoveCustomEmailSmtpColumnsFromServiceDeskSettings < Gitlab::Database::Migration[2.2] + MAXIMUM_LIMIT = 255 + + milestone '16.7' + + disable_ddl_transaction! + + def up + with_lock_retries do + remove_column :service_desk_settings, :custom_email_smtp_address + remove_column :service_desk_settings, :custom_email_smtp_port + remove_column :service_desk_settings, :custom_email_smtp_username + remove_column :service_desk_settings, :encrypted_custom_email_smtp_password + remove_column :service_desk_settings, :encrypted_custom_email_smtp_password_iv + end + end + + def down + with_lock_retries do + add_column :service_desk_settings, :custom_email_smtp_address, :text + add_column :service_desk_settings, :custom_email_smtp_port, :integer + add_column :service_desk_settings, :custom_email_smtp_username, :text + add_column :service_desk_settings, :encrypted_custom_email_smtp_password, :binary + add_column :service_desk_settings, :encrypted_custom_email_smtp_password_iv, :binary + end + + add_text_limit :service_desk_settings, :custom_email_smtp_address, MAXIMUM_LIMIT + add_text_limit :service_desk_settings, :custom_email_smtp_username, MAXIMUM_LIMIT + end +end diff --git a/db/post_migrate/20231122110442_drop_index_web_hooks_on_project_id.rb b/db/post_migrate/20231122110442_drop_index_web_hooks_on_project_id.rb new file mode 100644 index 00000000000..f3b2e59f189 --- /dev/null +++ b/db/post_migrate/20231122110442_drop_index_web_hooks_on_project_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexWebHooksOnProjectId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_web_hooks_on_project_id + TABLE_NAME = :web_hooks + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :project_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231122111935_drop_index_web_hook_logs_part_on_web_hook_id.rb b/db/post_migrate/20231122111935_drop_index_web_hook_logs_part_on_web_hook_id.rb new file mode 100644 index 00000000000..70f3cfee78d --- /dev/null +++ b/db/post_migrate/20231122111935_drop_index_web_hook_logs_part_on_web_hook_id.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class DropIndexWebHookLogsPartOnWebHookId < Gitlab::Database::Migration[2.2] + include Gitlab::Database::PartitioningMigrationHelpers + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_web_hook_logs_part_on_web_hook_id + TABLE_NAME = :web_hook_logs + + def up + remove_concurrent_partitioned_index_by_name(TABLE_NAME, INDEX_NAME) + end + + def down + add_concurrent_partitioned_index(TABLE_NAME, :web_hook_id, name: INDEX_NAME) + end +end diff --git a/db/post_migrate/20231122114135_add_index_on_sbom_occurrences_highest_severity.rb b/db/post_migrate/20231122114135_add_index_on_sbom_occurrences_highest_severity.rb new file mode 100644 index 00000000000..c7c5aef7160 --- /dev/null +++ b/db/post_migrate/20231122114135_add_index_on_sbom_occurrences_highest_severity.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddIndexOnSbomOccurrencesHighestSeverity < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + INDEX_NAME = 'index_sbom_occurrences_on_highest_severity' + INDEX_TO_BE_REMOVED = 'index_sbom_occurrences_on_project_id' + + def up + add_concurrent_index :sbom_occurrences, + [:project_id, :highest_severity], + order: { highest_severity: 'DESC NULLS LAST' }, + name: INDEX_NAME + + remove_concurrent_index_by_name :sbom_occurrences, INDEX_TO_BE_REMOVED + end + + def down + add_concurrent_index :sbom_occurrences, :project_id, name: INDEX_TO_BE_REMOVED + remove_concurrent_index_by_name :sbom_occurrences, INDEX_NAME + end +end diff --git a/db/post_migrate/20231122123408_drop_idx_jira_connect_subscriptions_on_installation_id.rb b/db/post_migrate/20231122123408_drop_idx_jira_connect_subscriptions_on_installation_id.rb new file mode 100644 index 00000000000..301fbe97bdf --- /dev/null +++ b/db/post_migrate/20231122123408_drop_idx_jira_connect_subscriptions_on_installation_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIdxJiraConnectSubscriptionsOnInstallationId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :idx_jira_connect_subscriptions_on_installation_id + TABLE_NAME = :jira_connect_subscriptions + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :jira_connect_installation_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231122124815_drop_index_bulk_import_batch_trackers_on_tracker_id.rb b/db/post_migrate/20231122124815_drop_index_bulk_import_batch_trackers_on_tracker_id.rb new file mode 100644 index 00000000000..46e0df5cde9 --- /dev/null +++ b/db/post_migrate/20231122124815_drop_index_bulk_import_batch_trackers_on_tracker_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexBulkImportBatchTrackersOnTrackerId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_bulk_import_batch_trackers_on_tracker_id + TABLE_NAME = :bulk_import_batch_trackers + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :tracker_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231122125550_drop_index_bulk_import_export_batches_on_export_id.rb b/db/post_migrate/20231122125550_drop_index_bulk_import_export_batches_on_export_id.rb new file mode 100644 index 00000000000..295eae13c06 --- /dev/null +++ b/db/post_migrate/20231122125550_drop_index_bulk_import_export_batches_on_export_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexBulkImportExportBatchesOnExportId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_bulk_import_export_batches_on_export_id + TABLE_NAME = :bulk_import_export_batches + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :export_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231122130721_drop_index_project_relation_exports_on_project_export_job_id.rb b/db/post_migrate/20231122130721_drop_index_project_relation_exports_on_project_export_job_id.rb new file mode 100644 index 00000000000..b84852ba596 --- /dev/null +++ b/db/post_migrate/20231122130721_drop_index_project_relation_exports_on_project_export_job_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexProjectRelationExportsOnProjectExportJobId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_project_relation_exports_on_project_export_job_id + TABLE_NAME = :project_relation_exports + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :project_export_job_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231124084532_remove_security_orchestration_policy_configurations_bot_user_id_column.rb b/db/post_migrate/20231124084532_remove_security_orchestration_policy_configurations_bot_user_id_column.rb new file mode 100644 index 00000000000..0437864c7d9 --- /dev/null +++ b/db/post_migrate/20231124084532_remove_security_orchestration_policy_configurations_bot_user_id_column.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class RemoveSecurityOrchestrationPolicyConfigurationsBotUserIdColumn < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + TABLE = :security_orchestration_policy_configurations + COLUMN = :bot_user_id + INDEX = "index_security_policy_configurations_on_bot_user_id" + + def up + remove_column(TABLE, COLUMN) + end + + def down + add_column(TABLE, COLUMN, :integer) unless column_exists?(TABLE, COLUMN) + + add_concurrent_foreign_key(TABLE, :users, column: COLUMN, on_delete: :nullify) + + add_concurrent_index(TABLE, COLUMN, + where: "security_orchestration_policy_configurations.bot_user_id IS NOT NULL", + name: INDEX) + end +end diff --git a/db/post_migrate/20231124105726_drop_idx_service_desk_enabled_projects_on_id_creator_id_created_at_for_gitlab_com.rb b/db/post_migrate/20231124105726_drop_idx_service_desk_enabled_projects_on_id_creator_id_created_at_for_gitlab_com.rb new file mode 100644 index 00000000000..96adba81123 --- /dev/null +++ b/db/post_migrate/20231124105726_drop_idx_service_desk_enabled_projects_on_id_creator_id_created_at_for_gitlab_com.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class DropIdxServiceDeskEnabledProjectsOnIdCreatorIdCreatedAtForGitlabCom < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :index_service_desk_enabled_projects_on_id_creator_id_created_at + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index( + TABLE_NAME, + [:id, :creator_id, :created_at], + where: 'service_desk_enabled = TRUE', + name: INDEX_NAME + ) + end + + private + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231124124600_drop_idx_projects_mirror_id_where_mirror_and_trigger_builds_for_gitlab_com.rb b/db/post_migrate/20231124124600_drop_idx_projects_mirror_id_where_mirror_and_trigger_builds_for_gitlab_com.rb new file mode 100644 index 00000000000..8e35a610361 --- /dev/null +++ b/db/post_migrate/20231124124600_drop_idx_projects_mirror_id_where_mirror_and_trigger_builds_for_gitlab_com.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class DropIdxProjectsMirrorIdWhereMirrorAndTriggerBuildsForGitlabCom < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :index_projects_on_mirror_id_where_mirror_and_trigger_builds + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index TABLE_NAME, :id, where: 'mirror = TRUE AND mirror_trigger_builds = TRUE', name: INDEX_NAME + end + + private + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231124124750_drop_idx_projects_on_mirror_creator_id_created_at_for_gitlab_com.rb b/db/post_migrate/20231124124750_drop_idx_projects_on_mirror_creator_id_created_at_for_gitlab_com.rb new file mode 100644 index 00000000000..2ea4967a154 --- /dev/null +++ b/db/post_migrate/20231124124750_drop_idx_projects_on_mirror_creator_id_created_at_for_gitlab_com.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class DropIdxProjectsOnMirrorCreatorIdCreatedAtForGitlabCom < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :index_projects_on_mirror_creator_id_created_at + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index( + TABLE_NAME, + [:creator_id, :created_at], + where: 'mirror = true and mirror_trigger_builds = true', + name: INDEX_NAME + ) + end + + private + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231124125007_drop_idx_projects_on_id_service_desk_enabled_for_gitlab_com.rb b/db/post_migrate/20231124125007_drop_idx_projects_on_id_service_desk_enabled_for_gitlab_com.rb new file mode 100644 index 00000000000..1bcdf18ae78 --- /dev/null +++ b/db/post_migrate/20231124125007_drop_idx_projects_on_id_service_desk_enabled_for_gitlab_com.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class DropIdxProjectsOnIdServiceDeskEnabledForGitlabCom < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :index_projects_on_id_service_desk_enabled + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index TABLE_NAME, :id, where: 'service_desk_enabled = true', name: INDEX_NAME + end + + private + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231124132953_drop_idx_projects_id_created_at_disable_overriding_approvers_true_for_gitlab_com.rb b/db/post_migrate/20231124132953_drop_idx_projects_id_created_at_disable_overriding_approvers_true_for_gitlab_com.rb new file mode 100644 index 00000000000..1d63c3ddb64 --- /dev/null +++ b/db/post_migrate/20231124132953_drop_idx_projects_id_created_at_disable_overriding_approvers_true_for_gitlab_com.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class DropIdxProjectsIdCreatedAtDisableOverridingApproversTrueForGitlabCom < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :idx_projects_id_created_at_disable_overriding_approvers_true + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index( + TABLE_NAME, + [:id, :created_at], + where: "disable_overriding_approvers_per_merge_request = TRUE", + name: INDEX_NAME + ) + end + + private + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231124133015_drop_idx_projects_id_created_at_disable_overriding_approvers_false_for_gitlab_com.rb b/db/post_migrate/20231124133015_drop_idx_projects_id_created_at_disable_overriding_approvers_false_for_gitlab_com.rb new file mode 100644 index 00000000000..8da8d726ab8 --- /dev/null +++ b/db/post_migrate/20231124133015_drop_idx_projects_id_created_at_disable_overriding_approvers_false_for_gitlab_com.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class DropIdxProjectsIdCreatedAtDisableOverridingApproversFalseForGitlabCom < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :idx_projects_id_created_at_disable_overriding_approvers_false + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index( + TABLE_NAME, + [:id, :created_at], + where: "(disable_overriding_approvers_per_merge_request = FALSE) OR " \ + "(disable_overriding_approvers_per_merge_request IS NULL)", + name: INDEX_NAME + ) + end + + private + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231124180449_add_index_updated_at_to_bulk_import_batch_trackers.rb b/db/post_migrate/20231124180449_add_index_updated_at_to_bulk_import_batch_trackers.rb new file mode 100644 index 00000000000..1503a4e9ea7 --- /dev/null +++ b/db/post_migrate/20231124180449_add_index_updated_at_to_bulk_import_batch_trackers.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexUpdatedAtToBulkImportBatchTrackers < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + INDEX = 'index_bulk_import_batch_trackers_on_tracker_id_and_updated_at' + + def up + add_concurrent_index :bulk_import_batch_trackers, + [:tracker_id, :updated_at], + name: INDEX + end + + def down + remove_concurrent_index_by_name :bulk_import_batch_trackers, name: INDEX + end +end diff --git a/db/post_migrate/20231124213241_add_index_to_bulk_imports_on_updated_at_and_status.rb b/db/post_migrate/20231124213241_add_index_to_bulk_imports_on_updated_at_and_status.rb new file mode 100644 index 00000000000..c3e657a4873 --- /dev/null +++ b/db/post_migrate/20231124213241_add_index_to_bulk_imports_on_updated_at_and_status.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexToBulkImportsOnUpdatedAtAndStatus < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + INDEX_NAME = 'index_bulk_imports_on_updated_at_and_id_for_stale_status' + + def up + add_concurrent_index :bulk_imports, [:updated_at, :id], + where: 'STATUS in (0, 1)', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :bulk_imports, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231126220000_cleanup_container_registry_protection_rules_container_path_pattern_at_rename.rb b/db/post_migrate/20231126220000_cleanup_container_registry_protection_rules_container_path_pattern_at_rename.rb new file mode 100644 index 00000000000..e3f8c53199a --- /dev/null +++ b/db/post_migrate/20231126220000_cleanup_container_registry_protection_rules_container_path_pattern_at_rename.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class CleanupContainerRegistryProtectionRulesContainerPathPatternAtRename < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + def up + cleanup_concurrent_column_rename :container_registry_protection_rules, :container_path_pattern, + :repository_path_pattern + end + + def down + undo_cleanup_concurrent_column_rename :container_registry_protection_rules, :container_path_pattern, + :repository_path_pattern + + # Restoring the old index name `:i_container_protection_unique_project_id_container_path_pattern` + # that was changed in the following migrations: + # - `db/migrate/20231126200903_rename_container_registry_protection_rules_container_path_pattern.rb` + # - `db/migrate/20231126200904_rename_index_i_container_protection_unique_project_id_container_path_pattern.rb` + if index_exists?(:container_registry_protection_rules, [:project_id, :container_path_pattern], + name: :i_container_protection_unique_project_container_path_pattern) + rename_index :container_registry_protection_rules, :i_container_protection_unique_project_container_path_pattern, + :i_container_protection_unique_project_id_container_path_pattern + end + end +end diff --git a/db/post_migrate/20231127171903_remove_application_settings_columns.rb b/db/post_migrate/20231127171903_remove_application_settings_columns.rb new file mode 100644 index 00000000000..9400c036678 --- /dev/null +++ b/db/post_migrate/20231127171903_remove_application_settings_columns.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class RemoveApplicationSettingsColumns < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + def up + remove_column :application_settings, :elasticsearch_shards, if_exists: true + remove_column :application_settings, :elasticsearch_replicas, if_exists: true + remove_column :application_settings, :static_objects_external_storage_auth_token, if_exists: true + remove_column :application_settings, :web_ide_clientside_preview_enabled, if_exists: true + end + + def down + add_column :application_settings, :elasticsearch_shards, :integer, default: 5, null: false, if_not_exists: true + add_column :application_settings, :elasticsearch_replicas, :integer, default: 1, null: false, if_not_exists: true + add_column :application_settings, :static_objects_external_storage_auth_token, :string, limit: 255, + if_not_exists: true + add_column :application_settings, :web_ide_clientside_preview_enabled, :boolean, default: false, null: false, + if_not_exists: true + end +end diff --git a/db/post_migrate/20231127174335_remove_ignored_application_settings_columns.rb b/db/post_migrate/20231127174335_remove_ignored_application_settings_columns.rb new file mode 100644 index 00000000000..07cabb93d96 --- /dev/null +++ b/db/post_migrate/20231127174335_remove_ignored_application_settings_columns.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class RemoveIgnoredApplicationSettingsColumns < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + PROJECT_INDEX_NAME = 'index_applicationsettings_on_instance_administration_project_id' + GROUP_INDEX_NAME = 'index_application_settings_on_instance_administrators_group_id' + + def up + remove_column(:application_settings, :instance_administration_project_id) + remove_column(:application_settings, :instance_administrators_group_id) + end + + def down + unless column_exists?(:users, :instance_administration_project_id) + add_column(:application_settings, :instance_administration_project_id, :bigint) + end + + unless column_exists?(:users, :instance_administrators_group_id) + add_column(:application_settings, :instance_administrators_group_id, :integer) + end + + add_concurrent_index(:application_settings, :instance_administration_project_id, name: PROJECT_INDEX_NAME) + add_concurrent_index(:application_settings, :instance_administrators_group_id, name: GROUP_INDEX_NAME) + end +end diff --git a/db/post_migrate/20231127185327_fix_broken_user_achievements_awarded.rb b/db/post_migrate/20231127185327_fix_broken_user_achievements_awarded.rb new file mode 100644 index 00000000000..f23cace49a7 --- /dev/null +++ b/db/post_migrate/20231127185327_fix_broken_user_achievements_awarded.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class FixBrokenUserAchievementsAwarded < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + milestone '16.7' + + class User < MigrationRecord + self.table_name = 'users' + end + + def up + User.reset_column_information + + ghost_id = User.where(user_type: 5).first&.id + + return unless ghost_id + + update_column_in_batches(:user_achievements, :awarded_by_user_id, ghost_id) do |table, query| + query.where(table[:awarded_by_user_id].eq(nil)) + end + end + + def down + # noop -- this is a data migration and can't be reversed + end +end diff --git a/db/post_migrate/20231127185328_fix_broken_user_achievements_revoked.rb b/db/post_migrate/20231127185328_fix_broken_user_achievements_revoked.rb new file mode 100644 index 00000000000..548a85b8814 --- /dev/null +++ b/db/post_migrate/20231127185328_fix_broken_user_achievements_revoked.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class FixBrokenUserAchievementsRevoked < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + milestone '16.7' + + class User < MigrationRecord + self.table_name = 'users' + end + + def up + User.reset_column_information + + ghost_id = User.where(user_type: 5).first&.id + + return unless ghost_id + + update_column_in_batches(:user_achievements, :revoked_by_user_id, ghost_id) do |table, query| + query.where(table[:revoked_at].not_eq(nil)).where(table[:revoked_by_user_id].eq(nil)) + end + end + + def down + # noop -- this is a data migration and can't be reversed + end +end diff --git a/db/post_migrate/20231128103624_add_unique_id_partition_id_index_to_ci_job_artifact.rb b/db/post_migrate/20231128103624_add_unique_id_partition_id_index_to_ci_job_artifact.rb new file mode 100644 index 00000000000..504864f75c9 --- /dev/null +++ b/db/post_migrate/20231128103624_add_unique_id_partition_id_index_to_ci_job_artifact.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddUniqueIdPartitionIdIndexToCiJobArtifact < Gitlab::Database::Migration[2.2] + milestone '16.7' + TABLE_NAME = :ci_job_artifacts + INDEX_NAME = :index_ci_job_artifacts_on_id_partition_id_unique + COLUMNS = %i[id partition_id] + + def up + prepare_async_index(TABLE_NAME, COLUMNS, unique: true, name: INDEX_NAME) + end + + def down + unprepare_async_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) + end +end diff --git a/db/post_migrate/20231128104044_add_unique_job_id_filte_type_partition_id_index_to_ci_job_artifact.rb b/db/post_migrate/20231128104044_add_unique_job_id_filte_type_partition_id_index_to_ci_job_artifact.rb new file mode 100644 index 00000000000..c667dce511f --- /dev/null +++ b/db/post_migrate/20231128104044_add_unique_job_id_filte_type_partition_id_index_to_ci_job_artifact.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddUniqueJobIdFilteTypePartitionIdIndexToCiJobArtifact < Gitlab::Database::Migration[2.2] + milestone '16.7' + + TABLE_NAME = :ci_job_artifacts + INDEX_NAME = :idx_ci_job_artifacts_on_job_id_file_type_and_partition_id_uniq + COLUMNS = %i[job_id file_type partition_id] + + def up + prepare_async_index(TABLE_NAME, COLUMNS, unique: true, name: INDEX_NAME) + end + + def down + unprepare_async_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) + end +end diff --git a/db/post_migrate/20231128111550_add_async_indexes_with_partition_id_for_ci_pipeline_variables.rb b/db/post_migrate/20231128111550_add_async_indexes_with_partition_id_for_ci_pipeline_variables.rb new file mode 100644 index 00000000000..9539bbcca31 --- /dev/null +++ b/db/post_migrate/20231128111550_add_async_indexes_with_partition_id_for_ci_pipeline_variables.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddAsyncIndexesWithPartitionIdForCiPipelineVariables < Gitlab::Database::Migration[2.2] + milestone '16.7' + + TABLE_NAME = :ci_pipeline_variables + PK_INDEX_NAME = :index_ci_pipeline_variables_on_id_partition_id_unique + UNIQUE_INDEX_NAME = :index_pipeline_variables_on_pipeline_id_key_partition_id_unique + + def up + prepare_async_index TABLE_NAME, %i[id partition_id], name: PK_INDEX_NAME, unique: true + prepare_async_index TABLE_NAME, %i[pipeline_id key partition_id], name: UNIQUE_INDEX_NAME, unique: true + end + + def down + unprepare_async_index TABLE_NAME, %i[id partition_id], name: PK_INDEX_NAME, unique: true + unprepare_async_index TABLE_NAME, %i[pipeline_id key partition_id], name: UNIQUE_INDEX_NAME, unique: true + end +end diff --git a/db/post_migrate/20231128155514_finalize_backfill_admin_mode_scope_for_personal_access_tokens.rb b/db/post_migrate/20231128155514_finalize_backfill_admin_mode_scope_for_personal_access_tokens.rb new file mode 100644 index 00000000000..ccdd9454081 --- /dev/null +++ b/db/post_migrate/20231128155514_finalize_backfill_admin_mode_scope_for_personal_access_tokens.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeBackfillAdminModeScopeForPersonalAccessTokens < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillAdminModeScopeForPersonalAccessTokens', + table_name: :personal_access_tokens, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231128174345_remove_users_project_authorizations_user_id_fk.rb b/db/post_migrate/20231128174345_remove_users_project_authorizations_user_id_fk.rb new file mode 100644 index 00000000000..faffce473a7 --- /dev/null +++ b/db/post_migrate/20231128174345_remove_users_project_authorizations_user_id_fk.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveUsersProjectAuthorizationsUserIdFk < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + FOREIGN_KEY_NAME = "fk_rails_11e7aa3ed9" + + def up + with_lock_retries do + remove_foreign_key_if_exists(:project_authorizations, :users, + name: FOREIGN_KEY_NAME, reverse_lock_order: true) + end + end + + def down + add_concurrent_foreign_key(:project_authorizations, :users, + name: FOREIGN_KEY_NAME, column: :user_id, + target_column: :id, on_delete: :cascade) + end +end diff --git a/db/post_migrate/20231128201403_drop_index_users_for_auditors_for_gitlab_com.rb b/db/post_migrate/20231128201403_drop_index_users_for_auditors_for_gitlab_com.rb new file mode 100644 index 00000000000..fc452f7bfc0 --- /dev/null +++ b/db/post_migrate/20231128201403_drop_index_users_for_auditors_for_gitlab_com.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class DropIndexUsersForAuditorsForGitlabCom < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :users + INDEX_NAME = :index_users_for_auditors + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index TABLE_NAME, :created_at, name: INDEX_NAME + end + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231129105945_requeue_backfill_finding_id_in_vulnerabilities3.rb b/db/post_migrate/20231129105945_requeue_backfill_finding_id_in_vulnerabilities3.rb new file mode 100644 index 00000000000..8dd42dc4000 --- /dev/null +++ b/db/post_migrate/20231129105945_requeue_backfill_finding_id_in_vulnerabilities3.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class RequeueBackfillFindingIdInVulnerabilities3 < Gitlab::Database::Migration[2.2] + milestone '16.7' + + MIGRATION = "BackfillFindingIdInVulnerabilities" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 1000 + SUB_BATCH_SIZE = 100 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + delete_batched_background_migration( + MIGRATION, + :vulnerabilities, + :id, + [] + ) + + queue_batched_background_migration( + MIGRATION, + :vulnerabilities, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :vulnerabilities, :id, []) + end +end diff --git a/db/post_migrate/20231129132636_prepare_indexes_for_partitioning_ci_pipeline_variables.rb b/db/post_migrate/20231129132636_prepare_indexes_for_partitioning_ci_pipeline_variables.rb new file mode 100644 index 00000000000..efa0f6597e3 --- /dev/null +++ b/db/post_migrate/20231129132636_prepare_indexes_for_partitioning_ci_pipeline_variables.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class PrepareIndexesForPartitioningCiPipelineVariables < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + TABLE_NAME = :ci_pipeline_variables + PK_INDEX_NAME = :index_ci_pipeline_variables_on_id_partition_id_unique + UNIQUE_INDEX_NAME = :index_pipeline_variables_on_pipeline_id_key_partition_id_unique + + def up + add_concurrent_index(TABLE_NAME, %i[id partition_id], unique: true, name: PK_INDEX_NAME) + add_concurrent_index(TABLE_NAME, %i[pipeline_id key partition_id], unique: true, name: UNIQUE_INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(TABLE_NAME, PK_INDEX_NAME) + remove_concurrent_index_by_name(TABLE_NAME, UNIQUE_INDEX_NAME) + end +end diff --git a/db/post_migrate/20231129154701_remove_users_events_author_id_fk.rb b/db/post_migrate/20231129154701_remove_users_events_author_id_fk.rb new file mode 100644 index 00000000000..615715227ef --- /dev/null +++ b/db/post_migrate/20231129154701_remove_users_events_author_id_fk.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveUsersEventsAuthorIdFk < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + FOREIGN_KEY_NAME = "fk_edfd187b6f" + + def up + with_lock_retries do + remove_foreign_key_if_exists(:events, :users, + name: FOREIGN_KEY_NAME, reverse_lock_order: true) + end + end + + def down + add_concurrent_foreign_key(:events, :users, + name: FOREIGN_KEY_NAME, column: :author_id, + target_column: :id, on_delete: :cascade) + end +end diff --git a/db/post_migrate/20231129170203_remove_requirements_ignored_columns.rb b/db/post_migrate/20231129170203_remove_requirements_ignored_columns.rb new file mode 100644 index 00000000000..d85f07e5d05 --- /dev/null +++ b/db/post_migrate/20231129170203_remove_requirements_ignored_columns.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveRequirementsIgnoredColumns < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + def up + # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/17224 + end + + def down + # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/17224 + end +end diff --git a/db/post_migrate/20231129192345_drop_projects_on_path_and_id_index.rb b/db/post_migrate/20231129192345_drop_projects_on_path_and_id_index.rb new file mode 100644 index 00000000000..825cb8bb8d2 --- /dev/null +++ b/db/post_migrate/20231129192345_drop_projects_on_path_and_id_index.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropProjectsOnPathAndIdIndex < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :index_projects_on_path_and_id + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, [:path, :id], name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231130131808_remove_indexes_without_partition_id_from_ci_pipeline_variables.rb b/db/post_migrate/20231130131808_remove_indexes_without_partition_id_from_ci_pipeline_variables.rb new file mode 100644 index 00000000000..39ba44dc0fd --- /dev/null +++ b/db/post_migrate/20231130131808_remove_indexes_without_partition_id_from_ci_pipeline_variables.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveIndexesWithoutPartitionIdFromCiPipelineVariables < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + TABLE_NAME = :ci_pipeline_variables + OLD_UNIQUE_INDEX_NAME = :index_ci_pipeline_variables_on_pipeline_id_and_key + + def up + remove_concurrent_index_by_name(TABLE_NAME, OLD_UNIQUE_INDEX_NAME) + end + + def down + add_concurrent_index(TABLE_NAME, %i[pipeline_id key], unique: true, name: OLD_UNIQUE_INDEX_NAME) + end +end diff --git a/db/post_migrate/20231130140901_queue_backfill_vs_code_settings_uuid.rb b/db/post_migrate/20231130140901_queue_backfill_vs_code_settings_uuid.rb new file mode 100644 index 00000000000..7acfed7d154 --- /dev/null +++ b/db/post_migrate/20231130140901_queue_backfill_vs_code_settings_uuid.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class QueueBackfillVsCodeSettingsUuid < Gitlab::Database::Migration[2.2] + milestone "16.7" + + MIGRATION = "BackfillVsCodeSettingsUuid" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 1000 + SUB_BATCH_SIZE = 100 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :vs_code_settings, + :id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :vs_code_settings, :id, []) + end +end diff --git a/db/post_migrate/20231130142218_async_create_supporting_index_for_finding_id_backfill.rb b/db/post_migrate/20231130142218_async_create_supporting_index_for_finding_id_backfill.rb new file mode 100644 index 00000000000..95cad1d4e94 --- /dev/null +++ b/db/post_migrate/20231130142218_async_create_supporting_index_for_finding_id_backfill.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AsyncCreateSupportingIndexForFindingIdBackfill < Gitlab::Database::Migration[2.2] + milestone '16.7' + + INDEX_NAME = "tmp_index_vulnerabilities_on_id_finding_id_empty" + + # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/433253 + def up + prepare_async_index( + :vulnerabilities, + :id, + where: "finding_id IS NULL", + name: INDEX_NAME + ) + end + + def down + unprepare_async_index( + :vulnerabilities, + :id, + name: INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20231130193042_add_index_to_bulk_import_entities_on_updated_at_and_status.rb b/db/post_migrate/20231130193042_add_index_to_bulk_import_entities_on_updated_at_and_status.rb new file mode 100644 index 00000000000..318dea4ef79 --- /dev/null +++ b/db/post_migrate/20231130193042_add_index_to_bulk_import_entities_on_updated_at_and_status.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexToBulkImportEntitiesOnUpdatedAtAndStatus < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + INDEX_NAME = 'index_bulk_import_entities_for_stale_status' + + def up + add_concurrent_index :bulk_import_entities, [:updated_at, :id], + where: 'status in (0, 1)', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :bulk_import_entities, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231130200216_drop_projects_on_created_at_and_id_index.rb b/db/post_migrate/20231130200216_drop_projects_on_created_at_and_id_index.rb new file mode 100644 index 00000000000..ed033fa0f66 --- /dev/null +++ b/db/post_migrate/20231130200216_drop_projects_on_created_at_and_id_index.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropProjectsOnCreatedAtAndIdIndex < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :projects + INDEX_NAME = :index_projects_on_created_at_and_id + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, [:created_at, :id], name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231201144826_finalize_backfill_dismissal_reason_in_vulnerability_reads.rb b/db/post_migrate/20231201144826_finalize_backfill_dismissal_reason_in_vulnerability_reads.rb new file mode 100644 index 00000000000..bb85fff2ebd --- /dev/null +++ b/db/post_migrate/20231201144826_finalize_backfill_dismissal_reason_in_vulnerability_reads.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class FinalizeBackfillDismissalReasonInVulnerabilityReads < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + # no-op to fix to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/17224 + end + + def down; end +end diff --git a/db/post_migrate/20231201171229_detect_and_fix_duplicate_organizations_path.rb b/db/post_migrate/20231201171229_detect_and_fix_duplicate_organizations_path.rb new file mode 100644 index 00000000000..3b63cfef5ea --- /dev/null +++ b/db/post_migrate/20231201171229_detect_and_fix_duplicate_organizations_path.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +class DetectAndFixDuplicateOrganizationsPath < Gitlab::Database::Migration[2.2] + restrict_gitlab_migration gitlab_schema: :gitlab_main + milestone '16.7' + + module Organizations + class Organization < Gitlab::Database::Migration[2.2]::MigrationRecord + end + end + + def up + duplicate_paths = Organizations::Organization.group("lower(path)").having("count(path) > 1").count.keys + duplicate_paths.each do |dup_path| + # the first one found is the 'winner' here and so we'll drop it an only focus on others + Organizations::Organization.where('lower(path) = ?', dup_path).order(id: :asc).drop(1).each do |dup_path_record| + dup_path_record.update!(path: clean_path(dup_path_record.path)) + end + end + end + + def down + # no-op no reversal required here. + end + + private + + def clean_path(path) + slug = Gitlab::Slug::Path.new(path).generate + path = Namespaces::RandomizedSuffixPath.new(slug) + Gitlab::Utils::Uniquify.new.string(path) do |s| + Organizations::Organization.find_by('lower(path) = :value', value: s.downcase) + end + end +end diff --git a/db/post_migrate/20231201172203_add_organizations_path_unique_with_case_sensitivity.rb b/db/post_migrate/20231201172203_add_organizations_path_unique_with_case_sensitivity.rb new file mode 100644 index 00000000000..60ef6d8a2cb --- /dev/null +++ b/db/post_migrate/20231201172203_add_organizations_path_unique_with_case_sensitivity.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddOrganizationsPathUniqueWithCaseSensitivity < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + INDEX_NAME = 'unique_organizations_on_path_case_insensitive' + + def up + add_concurrent_index :organizations, '(lower(path))', unique: true, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :organizations, INDEX_NAME + end +end diff --git a/db/post_migrate/20231201204712_requeue2_backfill_has_remediations_of_vulnerability_reads.rb b/db/post_migrate/20231201204712_requeue2_backfill_has_remediations_of_vulnerability_reads.rb new file mode 100644 index 00000000000..35b6de08f10 --- /dev/null +++ b/db/post_migrate/20231201204712_requeue2_backfill_has_remediations_of_vulnerability_reads.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# rubocop: disable BackgroundMigration/DictionaryFile -- queued/introduced before the rule is introduced + +class Requeue2BackfillHasRemediationsOfVulnerabilityReads < Gitlab::Database::Migration[2.2] + milestone '16.7' + + MIGRATION = "BackfillHasRemediationsOfVulnerabilityReads" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 10_000 + SUB_BATCH_SIZE = 50 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + # remove the original migration + delete_batched_background_migration(MIGRATION, :vulnerability_reads, :vulnerability_id, []) + + queue_batched_background_migration( + MIGRATION, + :vulnerability_reads, + :vulnerability_id, + job_interval: DELAY_INTERVAL, + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :vulnerability_reads, :vulnerability_id, []) + end +end +# rubocop: enable BackgroundMigration/DictionaryFile diff --git a/db/post_migrate/20231202175941_index_projects_on_organization_id_and_id.rb b/db/post_migrate/20231202175941_index_projects_on_organization_id_and_id.rb new file mode 100644 index 00000000000..a536def7ff3 --- /dev/null +++ b/db/post_migrate/20231202175941_index_projects_on_organization_id_and_id.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class IndexProjectsOnOrganizationIdAndId < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + INDEX_NAME = "index_projects_on_organization_id_and_id" + + def up + # rubocop:disable Migration/PreventIndexCreation -- Replacing existing index + # on organization_id with an index on (organization_id, id) + add_concurrent_index :projects, [:organization_id, :id], name: INDEX_NAME + # rubocop:enable Migration/PreventIndexCreation + end + + def down + remove_concurrent_index :projects, [:organization_id, :id], name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231202180101_remove_index_on_organization_id_projects_table.rb b/db/post_migrate/20231202180101_remove_index_on_organization_id_projects_table.rb new file mode 100644 index 00000000000..ec5a6d33ca3 --- /dev/null +++ b/db/post_migrate/20231202180101_remove_index_on_organization_id_projects_table.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class RemoveIndexOnOrganizationIdProjectsTable < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + INDEX_NAME = 'index_projects_on_organization_id' + + def up + remove_concurrent_index_by_name :projects, INDEX_NAME + end + + def down + add_concurrent_index :projects, :organization_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20220916065418_add_index_id_partition_id_to_ci_builds_metadata.rb b/db/post_migrate/20231204090310_add_unique_index_id_partition_id_to_ci_job_artifact.rb index c781f2a9ef9..9d6aef69877 100644 --- a/db/post_migrate/20220916065418_add_index_id_partition_id_to_ci_builds_metadata.rb +++ b/db/post_migrate/20231204090310_add_unique_index_id_partition_id_to_ci_job_artifact.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -class AddIndexIdPartitionIdToCiBuildsMetadata < Gitlab::Database::Migration[2.0] +class AddUniqueIndexIdPartitionIdToCiJobArtifact < Gitlab::Database::Migration[2.2] + milestone '16.7' disable_ddl_transaction! - - TABLE_NAME = :ci_builds_metadata - INDEX_NAME = :index_ci_builds_metadata_on_id_partition_id_unique + TABLE_NAME = :ci_job_artifacts + INDEX_NAME = :index_ci_job_artifacts_on_id_partition_id_unique def up add_concurrent_index(TABLE_NAME, %i[id partition_id], unique: true, name: INDEX_NAME) diff --git a/db/post_migrate/20231204090413_add_unique_index_job_id_filte_type_partition_id_to_ci_job_artifact.rb b/db/post_migrate/20231204090413_add_unique_index_job_id_filte_type_partition_id_to_ci_job_artifact.rb new file mode 100644 index 00000000000..ad02456b1b9 --- /dev/null +++ b/db/post_migrate/20231204090413_add_unique_index_job_id_filte_type_partition_id_to_ci_job_artifact.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddUniqueIndexJobIdFilteTypePartitionIdToCiJobArtifact < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + TABLE_NAME = :ci_job_artifacts + INDEX_NAME = :idx_ci_job_artifacts_on_job_id_file_type_and_partition_id_uniq + + def up + add_concurrent_index(TABLE_NAME, %i[job_id file_type partition_id], unique: true, name: INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/post_migrate/20231204154826_remove_organizations_path_without_case_sensitivity.rb b/db/post_migrate/20231204154826_remove_organizations_path_without_case_sensitivity.rb new file mode 100644 index 00000000000..08affaeb792 --- /dev/null +++ b/db/post_migrate/20231204154826_remove_organizations_path_without_case_sensitivity.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class RemoveOrganizationsPathWithoutCaseSensitivity < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + INDEX_NAME = 'unique_organizations_on_path' + + def up + remove_concurrent_index_by_name :organizations, INDEX_NAME + end + + def down + add_concurrent_index :organizations, :path, unique: true, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231205092529_drop_unique_index_job_id_file_type_to_ci_job_artifact.rb b/db/post_migrate/20231205092529_drop_unique_index_job_id_file_type_to_ci_job_artifact.rb new file mode 100644 index 00000000000..df52f76e1c4 --- /dev/null +++ b/db/post_migrate/20231205092529_drop_unique_index_job_id_file_type_to_ci_job_artifact.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class DropUniqueIndexJobIdFileTypeToCiJobArtifact < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + TABLE_NAME = :ci_job_artifacts + INDEX_NAME = :index_ci_job_artifacts_on_job_id_and_file_type + + def up + remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) + end + + def down + add_concurrent_index(TABLE_NAME, %i[job_id file_type], unique: true, name: INDEX_NAME) + end +end diff --git a/db/post_migrate/20231205111453_prepare_indexes_for_partitioning_ci_stages.rb b/db/post_migrate/20231205111453_prepare_indexes_for_partitioning_ci_stages.rb new file mode 100644 index 00000000000..81f132db0ff --- /dev/null +++ b/db/post_migrate/20231205111453_prepare_indexes_for_partitioning_ci_stages.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class PrepareIndexesForPartitioningCiStages < Gitlab::Database::Migration[2.2] + milestone '16.7' + + TABLE_NAME = :ci_stages + PK_INDEX_NAME = :index_ci_stages_on_id_partition_id_unique + UNIQUE_INDEX_PIPELINE_ID_AND_NAME = :index_ci_stages_on_pipeline_id_name_partition_id_unique + + def up + prepare_async_index TABLE_NAME, %i[id partition_id], name: PK_INDEX_NAME, unique: true + prepare_async_index TABLE_NAME, %i[pipeline_id name partition_id], name: UNIQUE_INDEX_PIPELINE_ID_AND_NAME, + unique: true + end + + def down + unprepare_async_index_by_name(TABLE_NAME, PK_INDEX_NAME) + unprepare_async_index_by_name(TABLE_NAME, UNIQUE_INDEX_PIPELINE_ID_AND_NAME) + end +end diff --git a/db/post_migrate/20231205144253_schedule_index_to_ci_build_trace_metadata.rb b/db/post_migrate/20231205144253_schedule_index_to_ci_build_trace_metadata.rb new file mode 100644 index 00000000000..279c5256188 --- /dev/null +++ b/db/post_migrate/20231205144253_schedule_index_to_ci_build_trace_metadata.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class ScheduleIndexToCiBuildTraceMetadata < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + INDEX_NAME = :index_ci_build_trace_metadata_on_trace_artifact_id_partition_id + TABLE_NAME = :ci_build_trace_metadata + COLUMNS = [:trace_artifact_id, :partition_id] + + def up + prepare_async_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) + end + + def down + unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/post_migrate/20231205144349_schedule_index_to_ci_job_artifact_states.rb b/db/post_migrate/20231205144349_schedule_index_to_ci_job_artifact_states.rb new file mode 100644 index 00000000000..db62ba7bdf4 --- /dev/null +++ b/db/post_migrate/20231205144349_schedule_index_to_ci_job_artifact_states.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class ScheduleIndexToCiJobArtifactStates < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + INDEX_NAME = :index_ci_job_artifact_states_on_job_artifact_id_partition_id + TABLE_NAME = :ci_job_artifact_states + COLUMNS = [:job_artifact_id, :partition_id] + + def up + prepare_async_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) + end + + def down + unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) + end +end diff --git a/db/post_migrate/20231206115306_remove_index_users_with_static_object_token.rb b/db/post_migrate/20231206115306_remove_index_users_with_static_object_token.rb new file mode 100644 index 00000000000..cac8f84f5d4 --- /dev/null +++ b/db/post_migrate/20231206115306_remove_index_users_with_static_object_token.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class RemoveIndexUsersWithStaticObjectToken < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + INDEX_NAME = :index_users_with_static_object_token + TABLE_NAME = :users + WHERE_STATEMENT = 'static_object_token IS NOT NULL AND static_object_token_encrypted IS NULL' + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, :id, where: WHERE_STATEMENT, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20231206142250_sync_create_supporting_index_for_finding_id_backfill.rb b/db/post_migrate/20231206142250_sync_create_supporting_index_for_finding_id_backfill.rb new file mode 100644 index 00000000000..1371674a8d9 --- /dev/null +++ b/db/post_migrate/20231206142250_sync_create_supporting_index_for_finding_id_backfill.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class SyncCreateSupportingIndexForFindingIdBackfill < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + INDEX_NAME = "tmp_index_vulnerabilities_on_id_finding_id_empty" + + def up + add_concurrent_index( + :vulnerabilities, + :id, + where: "finding_id IS NULL", + name: INDEX_NAME + ) + end + + def down + remove_concurrent_index_by_name( + :vulnerabilities, + INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20231206145850_finalize_backfill_code_suggestions_namespace_settings.rb b/db/post_migrate/20231206145850_finalize_backfill_code_suggestions_namespace_settings.rb new file mode 100644 index 00000000000..c5b098e9da2 --- /dev/null +++ b/db/post_migrate/20231206145850_finalize_backfill_code_suggestions_namespace_settings.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeBackfillCodeSuggestionsNamespaceSettings < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillCodeSuggestionsNamespaceSettings', + table_name: :namespace_settings, + column_name: :namespace_id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20221002234454_finalize_group_member_namespace_id_migration.rb b/db/post_migrate/20231206145911_finalize_backfill_design_management_repositories.rb index 9c5ca6cbb42..0f8fcd91846 100644 --- a/db/post_migrate/20221002234454_finalize_group_member_namespace_id_migration.rb +++ b/db/post_migrate/20231206145911_finalize_backfill_design_management_repositories.rb @@ -1,22 +1,21 @@ # frozen_string_literal: true -class FinalizeGroupMemberNamespaceIdMigration < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillMemberNamespaceForGroupMembers' +class FinalizeBackfillDesignManagementRepositories < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! restrict_gitlab_migration gitlab_schema: :gitlab_main def up ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :members, + job_class_name: 'BackfillDesignManagementRepositories', + table_name: :projects, column_name: :id, job_arguments: [], finalize: true ) end - def down - # no-op - end + def down; end end diff --git a/db/post_migrate/20231206200121_remove_use_legacy_web_ide_column.rb b/db/post_migrate/20231206200121_remove_use_legacy_web_ide_column.rb new file mode 100644 index 00000000000..ca8d196a1a0 --- /dev/null +++ b/db/post_migrate/20231206200121_remove_use_legacy_web_ide_column.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class RemoveUseLegacyWebIdeColumn < Gitlab::Database::Migration[2.2] + milestone '16.7' + enable_lock_retries! + + def up + remove_column :user_preferences, :use_legacy_web_ide + end + + def down + add_column :user_preferences, :use_legacy_web_ide, :boolean, default: false, null: false + end +end diff --git a/db/post_migrate/20231207054819_cleanup_ci_stages_pipeline_id_bigint_for_self_host.rb b/db/post_migrate/20231207054819_cleanup_ci_stages_pipeline_id_bigint_for_self_host.rb new file mode 100644 index 00000000000..5d10e655cbf --- /dev/null +++ b/db/post_migrate/20231207054819_cleanup_ci_stages_pipeline_id_bigint_for_self_host.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +class CleanupCiStagesPipelineIdBigintForSelfHost < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone "16.7" + + TABLE = :ci_stages + REFERENCING_TABLE = :ci_pipelines + COLUMN = :pipeline_id + OLD_COLUMN = :pipeline_id_convert_to_bigint + INDEXES = { + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_name' => [ + [:pipeline_id_convert_to_bigint, :name], { unique: true } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint' => [ + [:pipeline_id_convert_to_bigint], {} + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_id' => [ + [:pipeline_id_convert_to_bigint, :id], { where: 'status = ANY (ARRAY[0, 1, 2, 8, 9, 10])' } + ], + 'index_ci_stages_on_pipeline_id_convert_to_bigint_and_position' => [ + [:pipeline_id_convert_to_bigint, :position], {} + ] + } + + def up + return unless column_exists?(TABLE, OLD_COLUMN) + + with_lock_retries(raise_on_exhaustion: true) do + lock_tables(REFERENCING_TABLE, TABLE) + cleanup_conversion_of_integer_to_bigint(TABLE, [COLUMN]) + end + end + + def down + return if column_exists?(TABLE, OLD_COLUMN) + # See db/post_migrate/20231120070345_cleanup_ci_stages_pipeline_id_bigint.rb + # Both Gitlab.com and dev/test envinronments will be handled in that migration. + return if Gitlab.com_except_jh? || Gitlab.dev_or_test_env? + + restore_conversion_of_integer_to_bigint(TABLE, [COLUMN]) + + INDEXES.each do |index_name, (columns, options)| + add_concurrent_index(TABLE, columns, name: index_name, **options) + end + + add_concurrent_foreign_key( + TABLE, REFERENCING_TABLE, + column: OLD_COLUMN, + on_delete: :cascade, validate: true, reverse_lock_order: true + ) + end +end diff --git a/db/post_migrate/20231207112632_add_unique_index_id_partition_id_to_ci_stages.rb b/db/post_migrate/20231207112632_add_unique_index_id_partition_id_to_ci_stages.rb new file mode 100644 index 00000000000..1edb4595f89 --- /dev/null +++ b/db/post_migrate/20231207112632_add_unique_index_id_partition_id_to_ci_stages.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddUniqueIndexIdPartitionIdToCiStages < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + TABLE_NAME = :ci_stages + PK_INDEX_NAME = :index_ci_stages_on_id_partition_id_unique + + def up + add_concurrent_index(TABLE_NAME, %i[id partition_id], unique: true, name: PK_INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(TABLE_NAME, PK_INDEX_NAME) + end +end diff --git a/db/post_migrate/20231207112650_add_unique_index_pipeline_id_name_partition_id_to_ci_stages.rb b/db/post_migrate/20231207112650_add_unique_index_pipeline_id_name_partition_id_to_ci_stages.rb new file mode 100644 index 00000000000..5d9a24261ea --- /dev/null +++ b/db/post_migrate/20231207112650_add_unique_index_pipeline_id_name_partition_id_to_ci_stages.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddUniqueIndexPipelineIdNamePartitionIdToCiStages < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + TABLE_NAME = :ci_stages + UNIQUE_INDEX_PIPELINE_ID_AND_NAME = :index_ci_stages_on_pipeline_id_name_partition_id_unique + + def up + add_concurrent_index(TABLE_NAME, %i[pipeline_id name partition_id], unique: true, + name: UNIQUE_INDEX_PIPELINE_ID_AND_NAME) + end + + def down + remove_concurrent_index_by_name(TABLE_NAME, UNIQUE_INDEX_PIPELINE_ID_AND_NAME) + end +end diff --git a/db/post_migrate/20231207115601_remove_unique_index_without_partition_id_from_ci_stages.rb b/db/post_migrate/20231207115601_remove_unique_index_without_partition_id_from_ci_stages.rb new file mode 100644 index 00000000000..6b4de15d21e --- /dev/null +++ b/db/post_migrate/20231207115601_remove_unique_index_without_partition_id_from_ci_stages.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveUniqueIndexWithoutPartitionIdFromCiStages < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + TABLE_NAME = :ci_stages + OLD_UNIQUE_INDEX_PIPELINE_ID_AND_NAME = :index_ci_stages_on_pipeline_id_and_name + + def up + remove_concurrent_index_by_name(TABLE_NAME, OLD_UNIQUE_INDEX_PIPELINE_ID_AND_NAME) + end + + def down + add_concurrent_index(TABLE_NAME, %i[pipeline_id name], unique: true, name: OLD_UNIQUE_INDEX_PIPELINE_ID_AND_NAME) + end +end diff --git a/db/post_migrate/20231207163648_re_finalize_backfill_dismissal_reason_in_vulnerability_reads.rb b/db/post_migrate/20231207163648_re_finalize_backfill_dismissal_reason_in_vulnerability_reads.rb new file mode 100644 index 00000000000..fcfa50c8f32 --- /dev/null +++ b/db/post_migrate/20231207163648_re_finalize_backfill_dismissal_reason_in_vulnerability_reads.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class ReFinalizeBackfillDismissalReasonInVulnerabilityReads < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillDismissalReasonInVulnerabilityReads', + table_name: :vulnerability_reads, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb b/db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb new file mode 100644 index 00000000000..808b0d983a8 --- /dev/null +++ b/db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class BackfillCatalogResourcesVisibilityLevel < Gitlab::Database::Migration[2.2] + milestone '16.7' + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + sql = <<-SQL + UPDATE catalog_resources + SET visibility_level = projects.visibility_level + FROM projects + WHERE catalog_resources.project_id = projects.id + SQL + + execute(sql) + end + + def down + # no-op + + # The `visibility_level` column in `catalog_resources` is denormalized; + # it should always stay in sync with the corresponding data in `projects`. + end +end diff --git a/db/post_migrate/20220628012902_finalise_project_namespace_members.rb b/db/post_migrate/20231207220916_finalize_backfill_missing_ci_cd_settings.rb index 29b11fb4357..486df165883 100644 --- a/db/post_migrate/20220628012902_finalise_project_namespace_members.rb +++ b/db/post_migrate/20231207220916_finalize_backfill_missing_ci_cd_settings.rb @@ -1,22 +1,21 @@ # frozen_string_literal: true -class FinaliseProjectNamespaceMembers < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillProjectMemberNamespaceId' +class FinalizeBackfillMissingCiCdSettings < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! restrict_gitlab_migration gitlab_schema: :gitlab_main def up ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :members, + job_class_name: 'BackfillMissingCiCdSettings', + table_name: :projects, column_name: :id, job_arguments: [], finalize: true ) end - def down - # no-op - end + def down; end end diff --git a/db/post_migrate/20231207220935_finalize_backfill_missing_vulnerability_dismissal_details.rb b/db/post_migrate/20231207220935_finalize_backfill_missing_vulnerability_dismissal_details.rb new file mode 100644 index 00000000000..9fa1b2e597f --- /dev/null +++ b/db/post_migrate/20231207220935_finalize_backfill_missing_vulnerability_dismissal_details.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeBackfillMissingVulnerabilityDismissalDetails < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillMissingVulnerabilityDismissalDetails', + table_name: :vulnerabilities, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207220954_finalize_backfill_project_statistics_storage_size_without_pipeline_artifacts_si.rb b/db/post_migrate/20231207220954_finalize_backfill_project_statistics_storage_size_without_pipeline_artifacts_si.rb new file mode 100644 index 00000000000..ab89def9065 --- /dev/null +++ b/db/post_migrate/20231207220954_finalize_backfill_project_statistics_storage_size_without_pipeline_artifacts_si.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeBackfillProjectStatisticsStorageSizeWithoutPipelineArtifactsSi < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillProjectStatisticsStorageSizeWithoutPipelineArtifactsSizeJob', + table_name: :project_statistics, + column_name: :project_id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221013_finalize_backfill_project_wiki_repositories.rb b/db/post_migrate/20231207221013_finalize_backfill_project_wiki_repositories.rb new file mode 100644 index 00000000000..b26ff3645e3 --- /dev/null +++ b/db/post_migrate/20231207221013_finalize_backfill_project_wiki_repositories.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeBackfillProjectWikiRepositories < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillProjectWikiRepositories', + table_name: :projects, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221036_finalize_backfill_root_storage_statistics_fork_storage_sizes.rb b/db/post_migrate/20231207221036_finalize_backfill_root_storage_statistics_fork_storage_sizes.rb new file mode 100644 index 00000000000..0284e4bd8b9 --- /dev/null +++ b/db/post_migrate/20231207221036_finalize_backfill_root_storage_statistics_fork_storage_sizes.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeBackfillRootStorageStatisticsForkStorageSizes < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillRootStorageStatisticsForkStorageSizes', + table_name: :namespace_root_storage_statistics, + column_name: :namespace_id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221056_finalize_backfill_uuid_conversion_column_in_vulnerability_occurrences.rb b/db/post_migrate/20231207221056_finalize_backfill_uuid_conversion_column_in_vulnerability_occurrences.rb new file mode 100644 index 00000000000..4426a915526 --- /dev/null +++ b/db/post_migrate/20231207221056_finalize_backfill_uuid_conversion_column_in_vulnerability_occurrences.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeBackfillUuidConversionColumnInVulnerabilityOccurrences < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'BackfillUuidConversionColumnInVulnerabilityOccurrences', + table_name: :vulnerability_occurrences, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221119_finalize_cleanup_personal_access_tokens_with_nil_expires_at.rb b/db/post_migrate/20231207221119_finalize_cleanup_personal_access_tokens_with_nil_expires_at.rb new file mode 100644 index 00000000000..75d9b6ed80e --- /dev/null +++ b/db/post_migrate/20231207221119_finalize_cleanup_personal_access_tokens_with_nil_expires_at.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeCleanupPersonalAccessTokensWithNilExpiresAt < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'CleanupPersonalAccessTokensWithNilExpiresAt', + table_name: :personal_access_tokens, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221140_finalize_delete_orphaned_transferred_project_approval_rules.rb b/db/post_migrate/20231207221140_finalize_delete_orphaned_transferred_project_approval_rules.rb new file mode 100644 index 00000000000..790e35ebfd2 --- /dev/null +++ b/db/post_migrate/20231207221140_finalize_delete_orphaned_transferred_project_approval_rules.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeDeleteOrphanedTransferredProjectApprovalRules < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'DeleteOrphanedTransferredProjectApprovalRules', + table_name: :approval_project_rules, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221159_finalize_fix_allow_descendants_override_disabled_shared_runners.rb b/db/post_migrate/20231207221159_finalize_fix_allow_descendants_override_disabled_shared_runners.rb new file mode 100644 index 00000000000..86dead2c54e --- /dev/null +++ b/db/post_migrate/20231207221159_finalize_fix_allow_descendants_override_disabled_shared_runners.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeFixAllowDescendantsOverrideDisabledSharedRunners < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'FixAllowDescendantsOverrideDisabledSharedRunners', + table_name: :namespaces, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221219_finalize_mark_duplicate_npm_packages_for_destruction.rb b/db/post_migrate/20231207221219_finalize_mark_duplicate_npm_packages_for_destruction.rb new file mode 100644 index 00000000000..a9340cbebb8 --- /dev/null +++ b/db/post_migrate/20231207221219_finalize_mark_duplicate_npm_packages_for_destruction.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeMarkDuplicateNpmPackagesForDestruction < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'MarkDuplicateNpmPackagesForDestruction', + table_name: :packages_packages, + column_name: :project_id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221241_finalize_populate_vulnerability_dismissal_fields.rb b/db/post_migrate/20231207221241_finalize_populate_vulnerability_dismissal_fields.rb new file mode 100644 index 00000000000..51c3dd5966f --- /dev/null +++ b/db/post_migrate/20231207221241_finalize_populate_vulnerability_dismissal_fields.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizePopulateVulnerabilityDismissalFields < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'PopulateVulnerabilityDismissalFields', + table_name: :vulnerabilities, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231207221300_finalize_remove_invalid_deploy_access_level_groups.rb b/db/post_migrate/20231207221300_finalize_remove_invalid_deploy_access_level_groups.rb new file mode 100644 index 00000000000..c20ff6673fe --- /dev/null +++ b/db/post_migrate/20231207221300_finalize_remove_invalid_deploy_access_level_groups.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FinalizeRemoveInvalidDeployAccessLevelGroups < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + ensure_batched_background_migration_is_finished( + job_class_name: 'RemoveInvalidDeployAccessLevelGroups', + table_name: :protected_environment_deploy_access_levels, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down; end +end diff --git a/db/post_migrate/20231208103049_drop_index_users_on_id_and_last_activity.rb b/db/post_migrate/20231208103049_drop_index_users_on_id_and_last_activity.rb new file mode 100644 index 00000000000..bf9b1800c68 --- /dev/null +++ b/db/post_migrate/20231208103049_drop_index_users_on_id_and_last_activity.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class DropIndexUsersOnIdAndLastActivity < Gitlab::Database::Migration[2.2] + milestone '16.7' + + disable_ddl_transaction! + + TABLE_NAME = :users + INDEX_NAME = :index_users_on_id_and_last_activity_on_for_active_human_service + + def up + return unless should_run? + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + return unless should_run? + + add_concurrent_index :users, [:id, :last_activity_on], + name: INDEX_NAME, + where: "state = 'active' AND user_type IN (0, 4)" + end + + def should_run? + Gitlab.com_except_jh? + end +end diff --git a/db/post_migrate/20231212132322_prepare_ci_pipeline_variables_primary_key_for_partitioning.rb b/db/post_migrate/20231212132322_prepare_ci_pipeline_variables_primary_key_for_partitioning.rb new file mode 100644 index 00000000000..4c1adadb06e --- /dev/null +++ b/db/post_migrate/20231212132322_prepare_ci_pipeline_variables_primary_key_for_partitioning.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class PrepareCiPipelineVariablesPrimaryKeyForPartitioning < Gitlab::Database::Migration[2.2] + milestone '16.7' + disable_ddl_transaction! + + TABLE_NAME = :ci_pipeline_variables + PRIMARY_KEY = :ci_pipeline_variables_pkey + NEW_INDEX = :index_ci_pipeline_variables_on_id_partition_id_unique + OLD_INDEX = :index_ci_pipeline_variables_on_id_unique + + def up + swap_primary_key(TABLE_NAME, PRIMARY_KEY, NEW_INDEX) + end + + def down + add_concurrent_index(TABLE_NAME, :id, unique: true, name: OLD_INDEX) + add_concurrent_index(TABLE_NAME, [:id, :partition_id], unique: true, name: NEW_INDEX) + + unswap_primary_key(TABLE_NAME, PRIMARY_KEY, OLD_INDEX) + end +end diff --git a/db/post_migrate/20231218062442_remove_max_workspaces_from_remote_development_agent_configs.rb b/db/post_migrate/20231218062442_remove_max_workspaces_from_remote_development_agent_configs.rb new file mode 100644 index 00000000000..523aae9f214 --- /dev/null +++ b/db/post_migrate/20231218062442_remove_max_workspaces_from_remote_development_agent_configs.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class RemoveMaxWorkspacesFromRemoteDevelopmentAgentConfigs < Gitlab::Database::Migration[2.2] + milestone '16.8' + enable_lock_retries! + + def change + remove_column :remote_development_agent_configs, :max_workspaces, :bigint, default: -1, null: false + end +end diff --git a/db/post_migrate/20231218062505_remove_max_workspaces_per_user_from_remote_development_agent_configs.rb b/db/post_migrate/20231218062505_remove_max_workspaces_per_user_from_remote_development_agent_configs.rb new file mode 100644 index 00000000000..10a5e314ef9 --- /dev/null +++ b/db/post_migrate/20231218062505_remove_max_workspaces_per_user_from_remote_development_agent_configs.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class RemoveMaxWorkspacesPerUserFromRemoteDevelopmentAgentConfigs < Gitlab::Database::Migration[2.2] + milestone '16.8' + enable_lock_retries! + + def change + remove_column :remote_development_agent_configs, :max_workspaces_per_user, :bigint, default: -1, null: false + end +end |