diff options
Diffstat (limited to 'db/post_migrate')
230 files changed, 18 insertions, 4955 deletions
diff --git a/db/post_migrate/20220826152430_remove_container_repository_deprecated_geo_fields.rb b/db/post_migrate/20220826152430_remove_container_repository_deprecated_geo_fields.rb deleted file mode 100644 index f5cb2be4ebe..00000000000 --- a/db/post_migrate/20220826152430_remove_container_repository_deprecated_geo_fields.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class RemoveContainerRepositoryDeprecatedGeoFields < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_column :geo_event_log, :container_repository_updated_event_id, :bigint - end - end - - def down - with_lock_retries do - unless column_exists?(:geo_event_log, :container_repository_updated_event_id) - add_column(:geo_event_log, :container_repository_updated_event_id, :bigint) - end - end - - add_concurrent_foreign_key :geo_event_log, :geo_container_repository_updated_events, - column: :container_repository_updated_event_id, - name: 'fk_6ada82d42a', - on_delete: :cascade - - add_concurrent_index :geo_event_log, - :container_repository_updated_event_id, - name: 'index_geo_event_log_on_container_repository_updated_event_id' - end -end diff --git a/db/post_migrate/20220826152432_remove_container_repository_updated_events.rb b/db/post_migrate/20220826152432_remove_container_repository_updated_events.rb deleted file mode 100644 index edce7b4e891..00000000000 --- a/db/post_migrate/20220826152432_remove_container_repository_updated_events.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class RemoveContainerRepositoryUpdatedEvents < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - drop_table :geo_container_repository_updated_events - end - - def down - create_table :geo_container_repository_updated_events, id: :bigserial do |t| - t.integer :container_repository_id, - null: false, - index: { name: :idx_geo_con_rep_updated_events_on_container_repository_id } - end - - add_concurrent_foreign_key :geo_container_repository_updated_events, :container_repositories, - column: :container_repository_id, - name: 'fk_212c89c706', - on_delete: :cascade - end -end diff --git a/db/post_migrate/20220920180451_schedule_vulnerabilities_feedback_migration.rb b/db/post_migrate/20220920180451_schedule_vulnerabilities_feedback_migration.rb deleted file mode 100644 index e5e16e5d0dc..00000000000 --- a/db/post_migrate/20220920180451_schedule_vulnerabilities_feedback_migration.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class ScheduleVulnerabilitiesFeedbackMigration < Gitlab::Database::Migration[2.0] - MIGRATION = 'MigrateVulnerabilitiesFeedbackToVulnerabilitiesStateTransition' - TABLE_NAME = :vulnerability_feedback - BATCH_COLUMN = :id - DELAY_INTERVAL = 5.minutes - BATCH_SIZE = 250 - MAX_BATCH_SIZE = 250 - SUB_BATCH_SIZE = 50 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # no-op - # Removing this migration due to subtransactions created. See discussion in - # https://gitlab.com/gitlab-org/gitlab/-/issues/386494#note_1217986034 - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221018095434_schedule_disable_legacy_open_source_license_for_projects_less_than_five_mb.rb b/db/post_migrate/20221018095434_schedule_disable_legacy_open_source_license_for_projects_less_than_five_mb.rb deleted file mode 100644 index 8b3f0668200..00000000000 --- a/db/post_migrate/20221018095434_schedule_disable_legacy_open_source_license_for_projects_less_than_five_mb.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb < Gitlab::Database::Migration[2.0] - MIGRATION = 'DisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb' - 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/20221102231130_finalize_backfill_user_details_fields.rb b/db/post_migrate/20221102231130_finalize_backfill_user_details_fields.rb deleted file mode 100644 index a6b5bdd307e..00000000000 --- a/db/post_migrate/20221102231130_finalize_backfill_user_details_fields.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class FinalizeBackfillUserDetailsFields < Gitlab::Database::Migration[2.0] - BACKFILL_MIGRATION = 'BackfillUserDetailsFields' - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # If the 20230116160904_remove_user_details_fields_from_user.rb migration already ran, - # finalizing this background migration will fail. - return unless column_exists?(:users, :linkedin) - - ensure_batched_background_migration_is_finished( - job_class_name: BACKFILL_MIGRATION, - table_name: :users, - column_name: :id, - job_arguments: [], - finalize: true) - end - - def down; end -end diff --git a/db/post_migrate/20221102231131_remove_temp_index_for_user_details_fields.rb b/db/post_migrate/20221102231131_remove_temp_index_for_user_details_fields.rb deleted file mode 100644 index c31513e00fc..00000000000 --- a/db/post_migrate/20221102231131_remove_temp_index_for_user_details_fields.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class RemoveTempIndexForUserDetailsFields < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_idx_where_user_details_fields_filled' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :users, INDEX_NAME - end - - def down - # 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 -end diff --git a/db/post_migrate/20221104115712_backfill_project_statistics_storage_size_without_uploads_size.rb b/db/post_migrate/20221104115712_backfill_project_statistics_storage_size_without_uploads_size.rb deleted file mode 100644 index 9dd64a3e7b5..00000000000 --- a/db/post_migrate/20221104115712_backfill_project_statistics_storage_size_without_uploads_size.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class BackfillProjectStatisticsStorageSizeWithoutUploadsSize < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 500 - MIGRATION_CLASS = 'BackfillProjectStatisticsStorageSizeWithoutUploadsSize' - SUB_BATCH_SIZE = 100 - - disable_ddl_transaction! - - def up - return unless Gitlab.dev_or_test_env? || Gitlab.org_or_com? - - queue_batched_background_migration( - MIGRATION_CLASS, - :project_statistics, - :project_id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - return unless Gitlab.dev_or_test_env? || Gitlab.org_or_com? - - delete_batched_background_migration(MIGRATION_CLASS, :project_statistics, :project_id, []) - end -end diff --git a/db/post_migrate/20221104141647_add_index_for_non_public_top_level_groups_to_namespaces.rb b/db/post_migrate/20221104141647_add_index_for_non_public_top_level_groups_to_namespaces.rb deleted file mode 100644 index ade35a39737..00000000000 --- a/db/post_migrate/20221104141647_add_index_for_non_public_top_level_groups_to_namespaces.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForNonPublicTopLevelGroupsToNamespaces < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - TABLE_NAME = 'namespaces' - INDEX_NAME = 'index_namespaces_on_type_and_visibility_and_parent_id' - CONDITIONS = "(type = 'Group' AND parent_id IS NULL AND visibility_level != 20)" - - def up - add_concurrent_index TABLE_NAME, :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/20221109160052_add_default_for_approval_project_rules_scanners.rb b/db/post_migrate/20221109160052_add_default_for_approval_project_rules_scanners.rb deleted file mode 100644 index a527bf4b2ef..00000000000 --- a/db/post_migrate/20221109160052_add_default_for_approval_project_rules_scanners.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddDefaultForApprovalProjectRulesScanners < Gitlab::Database::Migration[2.0] - def up - change_column_default :approval_project_rules, :scanners, from: nil, to: [] - end - - def down - change_column_default :approval_project_rules, :scanners, from: [], to: nil - end -end diff --git a/db/post_migrate/20221110100600_add_temp_index_on_overlong_vulnerability_html_title.rb b/db/post_migrate/20221110100600_add_temp_index_on_overlong_vulnerability_html_title.rb deleted file mode 100644 index 5ff56874e11..00000000000 --- a/db/post_migrate/20221110100600_add_temp_index_on_overlong_vulnerability_html_title.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddTempIndexOnOverlongVulnerabilityHtmlTitle < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'tmp_index_vulnerability_overlong_title_html' - - disable_ddl_transaction! - - def up - # Temporary index to speed up the truncation of vulnerabilities with invalid html title length - add_concurrent_index :vulnerabilities, [:id], - name: INDEX_NAME, - where: "LENGTH(title_html) > 800" - end - - def down - remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME - end -end diff --git a/db/post_migrate/20221110100602_queue_truncate_overlong_vulnerability_html_titles.rb b/db/post_migrate/20221110100602_queue_truncate_overlong_vulnerability_html_titles.rb deleted file mode 100644 index 48301498c5a..00000000000 --- a/db/post_migrate/20221110100602_queue_truncate_overlong_vulnerability_html_titles.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class QueueTruncateOverlongVulnerabilityHtmlTitles < Gitlab::Database::Migration[2.0] - MIGRATION = 'TruncateOverlongVulnerabilityHtmlTitles' - 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, - :vulnerabilities, - :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, :vulnerabilities, :id, []) - end -end diff --git a/db/post_migrate/20221110152133_delete_orphans_approval_rules.rb b/db/post_migrate/20221110152133_delete_orphans_approval_rules.rb deleted file mode 100644 index 55b6a10d786..00000000000 --- a/db/post_migrate/20221110152133_delete_orphans_approval_rules.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class DeleteOrphansApprovalRules < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 500 - MERGE_REQUEST_MIGRATION = 'DeleteOrphansApprovalMergeRequestRules' - PROJECT_MIGRATION = 'DeleteOrphansApprovalProjectRules' - INTERVAL = 2.minutes - - def up - 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/20221110190340_add_partial_legacy_open_source_license_available_project_id_index.rb b/db/post_migrate/20221110190340_add_partial_legacy_open_source_license_available_project_id_index.rb deleted file mode 100644 index 9931b25eb3c..00000000000 --- a/db/post_migrate/20221110190340_add_partial_legacy_open_source_license_available_project_id_index.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddPartialLegacyOpenSourceLicenseAvailableProjectIdIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_project_settings_on_legacy_os_license_project_id' - - def up - add_concurrent_index :project_settings, - :project_id, - 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/20221114142044_delete_experiments_foreign_keys.rb b/db/post_migrate/20221114142044_delete_experiments_foreign_keys.rb deleted file mode 100644 index d44b7a6eb51..00000000000 --- a/db/post_migrate/20221114142044_delete_experiments_foreign_keys.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -class DeleteExperimentsForeignKeys < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - with_lock_retries do - remove_foreign_key_if_exists :experiment_subjects, :users, name: 'fk_dfc3e211d4' - end - - with_lock_retries do - remove_foreign_key_if_exists :experiment_subjects, :experiments, name: 'fk_rails_ede5754774' - end - - with_lock_retries do - remove_foreign_key_if_exists :experiment_subjects, :projects, name: 'fk_ccc28f8ceb' - end - - with_lock_retries do - remove_foreign_key_if_exists :experiment_subjects, :namespaces, name: 'fk_842649f2f5' - end - end - - def down - add_concurrent_foreign_key :experiment_subjects, - :users, column: :user_id, name: 'fk_dfc3e211d4', on_delete: :cascade - add_concurrent_foreign_key :experiment_subjects, - :experiments, column: :experiment_id, name: 'fk_rails_ede5754774', on_delete: :cascade - add_concurrent_foreign_key :experiment_subjects, - :projects, column: :project_id, name: 'fk_ccc28f8ceb', on_delete: :cascade - add_concurrent_foreign_key :experiment_subjects, - :namespaces, column: :namespace_id, name: 'fk_842649f2f5', on_delete: :cascade - end -end diff --git a/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb b/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb deleted file mode 100644 index f7c10192afb..00000000000 --- a/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class DropExperimentSubjectsTable < Gitlab::Database::Migration[2.0] - def up - drop_table :experiment_subjects, if_exists: true - end - - def down - unless table_exists?(:experiment_subjects) - create_table :experiment_subjects do |t| - t.bigint :experiment_id, null: false - t.bigint :user_id - t.bigint :project_id - t.integer :variant, limit: 2, null: false, default: 0 - t.timestamps_with_timezone null: false - t.datetime_with_timezone :converted_at - t.jsonb :context, null: false, default: {} - t.bigint :namespace_id - - t.index :experiment_id - t.index :namespace_id - t.index :project_id - t.index :user_id - end - end - - # Require exactly one of user_id, group_id, or project_id to be NOT NULL - execute <<-SQL - ALTER TABLE experiment_subjects ADD CONSTRAINT check_f6411bc4b5 CHECK (num_nonnulls(user_id, namespace_id, project_id) = 1); - SQL - end -end diff --git a/db/post_migrate/20221114142616_drop_experiments_table.rb b/db/post_migrate/20221114142616_drop_experiments_table.rb deleted file mode 100644 index a8280eb9f69..00000000000 --- a/db/post_migrate/20221114142616_drop_experiments_table.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class DropExperimentsTable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - drop_table :experiments, if_exists: true - end - - def down - unless table_exists?(:experiments) - create_table :experiments do |t| - t.text :name, null: false - - t.index :name, unique: true - end - end - - add_text_limit :experiments, :name, 255 - end -end diff --git a/db/post_migrate/20221115120602_add_index_for_issues_health_status_ordering.rb b/db/post_migrate/20221115120602_add_index_for_issues_health_status_ordering.rb deleted file mode 100644 index d7d861387fd..00000000000 --- a/db/post_migrate/20221115120602_add_index_for_issues_health_status_ordering.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForIssuesHealthStatusOrdering < Gitlab::Database::Migration[2.0] - INDEX_NAME_DESC = 'index_on_issues_health_status_desc_order' - INDEX_NAME_ASC = 'index_on_issues_health_status_asc_order' - - def up - prepare_async_index :issues, - [:project_id, :health_status, :id, :state_id, :issue_type], - order: { health_status: 'DESC NULLS LAST', id: :desc }, - name: INDEX_NAME_DESC - - prepare_async_index :issues, - [:project_id, :health_status, :id, :state_id, :issue_type], - order: { health_status: 'ASC NULLS LAST', id: :desc }, - name: INDEX_NAME_ASC - end - - def down - unprepare_async_index :issues, INDEX_NAME_DESC - unprepare_async_index :issues, INDEX_NAME_ASC - end -end diff --git a/db/post_migrate/20221115173607_ensure_work_item_type_backfill_migration_finished.rb b/db/post_migrate/20221115173607_ensure_work_item_type_backfill_migration_finished.rb deleted file mode 100644 index 2cec1919e82..00000000000 --- a/db/post_migrate/20221115173607_ensure_work_item_type_backfill_migration_finished.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -class EnsureWorkItemTypeBackfillMigrationFinished < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'BackfillWorkItemTypeIdForIssues' - - class MigrationWorkItemType < MigrationRecord - self.table_name = 'work_item_types' - - def self.id_by_type(types) - where(namespace_id: nil, base_type: types).pluck(:base_type, :id).to_h - end - end - - def up - # more types were added to the types table after the backfill run - # so we cannot fetch all from the DB but only those that were backfilled - relevant_types = { - issue: 0, - incident: 1, - test_case: 2, - requirement: 3, - task: 4 - } - - MigrationWorkItemType.id_by_type(relevant_types.values).each do |base_type, type_id| - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :issues, - column_name: :id, - job_arguments: [base_type, type_id] - ) - end - end - - def down - # noop - end -end diff --git a/db/post_migrate/20221115184525_remove_namespaces_tmp_project_id_column.rb b/db/post_migrate/20221115184525_remove_namespaces_tmp_project_id_column.rb deleted file mode 100644 index d044c44e95e..00000000000 --- a/db/post_migrate/20221115184525_remove_namespaces_tmp_project_id_column.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class RemoveNamespacesTmpProjectIdColumn < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_on_tmp_project_id_on_namespaces' - - def up - with_lock_retries do - remove_column :namespaces, :tmp_project_id if column_exists?(:namespaces, :tmp_project_id) - end - end - - def down - unless column_exists?(:namespaces, :tmp_project_id) - with_lock_retries do - # rubocop:disable Migration/AddColumnsToWideTables - add_column :namespaces, :tmp_project_id, :integer - # rubocop:enable Migration/AddColumnsToWideTables - end - end - - add_concurrent_foreign_key :namespaces, :projects, column: :tmp_project_id - - add_concurrent_index :namespaces, :tmp_project_id, name: INDEX_NAME, unique: true - end -end diff --git a/db/post_migrate/20221116105434_remove_index_project_settings_on_legacy_open_source_license_available.rb b/db/post_migrate/20221116105434_remove_index_project_settings_on_legacy_open_source_license_available.rb deleted file mode 100644 index 363c9b6e572..00000000000 --- a/db/post_migrate/20221116105434_remove_index_project_settings_on_legacy_open_source_license_available.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexProjectSettingsOnLegacyOpenSourceLicenseAvailable < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_project_settings_on_legacy_open_source_license_available' - - def up - remove_concurrent_index_by_name(:project_settings, INDEX_NAME) - end - - def down - add_concurrent_index :project_settings, - %i[legacy_open_source_license_available], - where: "legacy_open_source_license_available = TRUE", - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221116134611_add_namespaces_emails_enabled_column_data.rb b/db/post_migrate/20221116134611_add_namespaces_emails_enabled_column_data.rb deleted file mode 100644 index e3efc18f3fd..00000000000 --- a/db/post_migrate/20221116134611_add_namespaces_emails_enabled_column_data.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true -class AddNamespacesEmailsEnabledColumnData < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'AddNamespacesEmailsEnabledColumnData' - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 200 - MAX_BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 20 - - def up - queue_batched_background_migration( - MIGRATION, - :namespaces, - :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, :namespaces, :id, []) - end -end diff --git a/db/post_migrate/20221116134633_add_projects_emails_enabled_column_data.rb b/db/post_migrate/20221116134633_add_projects_emails_enabled_column_data.rb deleted file mode 100644 index 9f0edbd0707..00000000000 --- a/db/post_migrate/20221116134633_add_projects_emails_enabled_column_data.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true -class AddProjectsEmailsEnabledColumnData < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'AddProjectsEmailsEnabledColumnData' - DELAY_INTERVAL = 2.minutes.to_i - BATCH_SIZE = 200 - MAX_BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 20 - - def up - queue_batched_background_migration( - MIGRATION, - :projects, - :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, :projects, :id, []) - end -end diff --git a/db/post_migrate/20221116143854_add_okr_hierarchy_restrictions.rb b/db/post_migrate/20221116143854_add_okr_hierarchy_restrictions.rb deleted file mode 100644 index 658ce0287f8..00000000000 --- a/db/post_migrate/20221116143854_add_okr_hierarchy_restrictions.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -class AddOkrHierarchyRestrictions < Gitlab::Database::Migration[2.0] - class WorkItemType < MigrationRecord - self.table_name = 'work_item_types' - end - - class HierarchyRestriction < MigrationRecord - self.table_name = 'work_item_hierarchy_restrictions' - end - - restrict_gitlab_migration gitlab_schema: :gitlab_main - disable_ddl_transaction! - - def up - objective = WorkItemType.find_by_name_and_namespace_id('Objective', nil) - key_result = WorkItemType.find_by_name_and_namespace_id('Key Result', nil) - issue = WorkItemType.find_by_name_and_namespace_id('Issue', nil) - task = WorkItemType.find_by_name_and_namespace_id('Task', nil) - incident = WorkItemType.find_by_name_and_namespace_id('Incident', nil) - - # work item default types should be filled, if this is not the case - # then restrictions will be created together with work item types - unless objective && key_result && issue && task && incident - Gitlab::AppLogger.warn('default types are missing, not adding restrictions') - - return - end - - restrictions = [ - { parent_type_id: objective.id, child_type_id: objective.id, maximum_depth: 9 }, - { parent_type_id: objective.id, child_type_id: key_result.id, maximum_depth: 1 }, - { parent_type_id: issue.id, child_type_id: task.id, maximum_depth: 1 }, - { parent_type_id: incident.id, child_type_id: task.id, maximum_depth: 1 } - ] - - HierarchyRestriction.upsert_all( - restrictions, - unique_by: :index_work_item_hierarchy_restrictions_on_parent_and_child - ) - end - - def down - # so far restrictions table was empty so we can delete all records when - # migrating down - HierarchyRestriction.delete_all - end -end diff --git a/db/post_migrate/20221117103015_add_async_index_author_id_created_at_on_merge_requests.rb b/db/post_migrate/20221117103015_add_async_index_author_id_created_at_on_merge_requests.rb deleted file mode 100644 index a45fdcccc27..00000000000 --- a/db/post_migrate/20221117103015_add_async_index_author_id_created_at_on_merge_requests.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddAsyncIndexAuthorIdCreatedAtOnMergeRequests < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_merge_requests_on_author_id_and_created_at' - - def up - prepare_async_index :merge_requests, %i[author_id created_at], name: INDEX_NAME - end - - def down - unprepare_async_index_by_name :merge_requests, INDEX_NAME - end -end diff --git a/db/post_migrate/20221117135032_remove_clusters_applications_job_instances.rb b/db/post_migrate/20221117135032_remove_clusters_applications_job_instances.rb deleted file mode 100644 index 80cd00e7737..00000000000 --- a/db/post_migrate/20221117135032_remove_clusters_applications_job_instances.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class RemoveClustersApplicationsJobInstances < Gitlab::Database::Migration[2.0] - DEPRECATED_JOB_CLASSES = %w[ - ClusterConfigureIstioWorker - ClusterInstallAppWorker - ClusterPatchAppWorker - ClusterUpdateAppWorker - ClusterUpgradeAppWorker - ClusterWaitForAppInstallationWorker - ClusterWaitForAppUpdateWorker - ClusterWaitForIngressIpAddressWorker - ] - - disable_ddl_transaction! - - def up - sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES) - end - - def down - # no-op Why: This migration removes any instances of deprecated job classes - # from expected queues via the sidekiq_queue_length method. Once the job - # class instances are removed, they cannot be added back. These job classes - # are deprecated and previous MRs have already no-op'd their perform - # methods to further increase confidence that removal is OK. - end -end diff --git a/db/post_migrate/20221117153015_add_index_merge_request_id_created_at_on_scan_finding_approval_merge_request_rules.rb b/db/post_migrate/20221117153015_add_index_merge_request_id_created_at_on_scan_finding_approval_merge_request_rules.rb deleted file mode 100644 index ecd3a8be02e..00000000000 --- a/db/post_migrate/20221117153015_add_index_merge_request_id_created_at_on_scan_finding_approval_merge_request_rules.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexMergeRequestIdCreatedAtOnScanFindingApprovalMergeRequestRules < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'scan_finding_approval_mr_rule_index_mr_id_and_created_at' - SCAN_FINDING_REPORT_TYPE = 4 - - disable_ddl_transaction! - - def up - add_concurrent_index :approval_merge_request_rules, %i[merge_request_id created_at], - 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/20221118103152_finalize_issues_namespace_id_backfilling.rb b/db/post_migrate/20221118103152_finalize_issues_namespace_id_backfilling.rb deleted file mode 100644 index c0a95b3e348..00000000000 --- a/db/post_migrate/20221118103152_finalize_issues_namespace_id_backfilling.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class FinalizeIssuesNamespaceIdBackfilling < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'BackfillProjectNamespaceOnIssues' - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :issues, - column_name: :id, - job_arguments: [] - ) - end - - def down - # noop - end -end diff --git a/db/post_migrate/20221118103352_add_cascade_delete_fk_on_issues_namespace_id.rb b/db/post_migrate/20221118103352_add_cascade_delete_fk_on_issues_namespace_id.rb deleted file mode 100644 index 094ac3abe0f..00000000000 --- a/db/post_migrate/20221118103352_add_cascade_delete_fk_on_issues_namespace_id.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -class AddCascadeDeleteFkOnIssuesNamespaceId < 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( - :issues, - :namespaces, - column: TARGET_COLUMN, - name: fk_name("#{TARGET_COLUMN}_new"), - on_delete: :cascade - ) - - with_lock_retries do - remove_foreign_key_if_exists(:issues, column: TARGET_COLUMN, name: fk_name(TARGET_COLUMN)) - end - end - - def down - add_concurrent_foreign_key( - :issues, - :namespaces, - column: TARGET_COLUMN, - name: fk_name(TARGET_COLUMN), - on_delete: :nullify - ) - - with_lock_retries do - remove_foreign_key_if_exists(:issues, column: TARGET_COLUMN, name: fk_name("#{TARGET_COLUMN}_new")) - end - end - - def fk_name(column_name) - # generate a FK name - concurrent_foreign_key_name(:issues, column_name) - end -end diff --git a/db/post_migrate/20221118103752_add_not_null_contraint_to_issues_namespace_id.rb b/db/post_migrate/20221118103752_add_not_null_contraint_to_issues_namespace_id.rb deleted file mode 100644 index 22a69c2bac0..00000000000 --- a/db/post_migrate/20221118103752_add_not_null_contraint_to_issues_namespace_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullContraintToIssuesNamespaceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_not_null_constraint :issues, :namespace_id, validate: false - end - - def down - remove_not_null_constraint :issues, :namespace_id - end -end diff --git a/db/post_migrate/20221118104752_validate_not_null_contraint_to_issues_namespace_id.rb b/db/post_migrate/20221118104752_validate_not_null_contraint_to_issues_namespace_id.rb deleted file mode 100644 index f7aad9d3606..00000000000 --- a/db/post_migrate/20221118104752_validate_not_null_contraint_to_issues_namespace_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class ValidateNotNullContraintToIssuesNamespaceId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - validate_not_null_constraint :issues, :namespace_id - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221121000127_index_security_scans_on_created_at_and_id_for_non_purged_records.rb b/db/post_migrate/20221121000127_index_security_scans_on_created_at_and_id_for_non_purged_records.rb deleted file mode 100644 index 0085005166f..00000000000 --- a/db/post_migrate/20221121000127_index_security_scans_on_created_at_and_id_for_non_purged_records.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class IndexSecurityScansOnCreatedAtAndIdForNonPurgedRecords < Gitlab::Database::Migration[2.0] - INDEX_NAME = :index_security_scans_for_non_purged_records - PURGED_STATE = 6 - - disable_ddl_transaction! - - def up - add_concurrent_index :security_scans, %w[created_at id], where: "status != #{PURGED_STATE}", name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :security_scans, INDEX_NAME - end -end diff --git a/db/post_migrate/20221121000451_drop_index_security_scans_on_id_for_non_purged_records.rb b/db/post_migrate/20221121000451_drop_index_security_scans_on_id_for_non_purged_records.rb deleted file mode 100644 index 06e614101e0..00000000000 --- a/db/post_migrate/20221121000451_drop_index_security_scans_on_id_for_non_purged_records.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class DropIndexSecurityScansOnIdForNonPurgedRecords < Gitlab::Database::Migration[2.0] - INDEX_NAME = :index_security_scans_on_id_for_non_purged_records - PURGED_STATE = 6 - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :security_scans, INDEX_NAME - end - - def down - add_concurrent_index :security_scans, :id, where: "status != #{PURGED_STATE}", name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221121152048_remove_unused_feedback_migration_index.rb b/db/post_migrate/20221121152048_remove_unused_feedback_migration_index.rb deleted file mode 100644 index b5dbafccd3a..00000000000 --- a/db/post_migrate/20221121152048_remove_unused_feedback_migration_index.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class RemoveUnusedFeedbackMigrationIndex < 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 - remove_concurrent_index_by_name( - :vulnerability_feedback, - INDEX_NAME - ) - end - - def down - add_concurrent_index( - :vulnerability_feedback, - %i[migrated_to_state_transition feedback_type], - where: WHERE_CLAUSE, - name: INDEX_NAME - ) - end -end diff --git a/db/post_migrate/20221121152515_add_supporting_index_for_vulnerabilities_feedback_migration2.rb b/db/post_migrate/20221121152515_add_supporting_index_for_vulnerabilities_feedback_migration2.rb deleted file mode 100644 index 8c55f2da957..00000000000 --- a/db/post_migrate/20221121152515_add_supporting_index_for_vulnerabilities_feedback_migration2.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddSupportingIndexForVulnerabilitiesFeedbackMigration2 < 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, - :id, - 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/20221121155850_change_vulnerabilities_state_transitions_comment_limit.rb b/db/post_migrate/20221121155850_change_vulnerabilities_state_transitions_comment_limit.rb deleted file mode 100644 index b75216ee413..00000000000 --- a/db/post_migrate/20221121155850_change_vulnerabilities_state_transitions_comment_limit.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class ChangeVulnerabilitiesStateTransitionsCommentLimit < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_text_limit( - :vulnerability_state_transitions, - :comment, - 50_000, - constraint_name: check_constraint_name(:vulnerability_state_transitions, :comment, 'max_length_50000') - ) - remove_text_limit( - :vulnerability_state_transitions, - :comment, - constraint_name: 'check_fca4a7ca39' - ) - end - - def down - # no-op: this can fail if records with length > 255 (previous limit) show up - end -end diff --git a/db/post_migrate/20221121180138_drop_index_on_vulnerabilities_state_case_id.rb b/db/post_migrate/20221121180138_drop_index_on_vulnerabilities_state_case_id.rb deleted file mode 100644 index 87f1e5d3ba2..00000000000 --- a/db/post_migrate/20221121180138_drop_index_on_vulnerabilities_state_case_id.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnVulnerabilitiesStateCaseId < Gitlab::Database::Migration[2.0] - INDEX_NAME = "index_vulnerabilities_on_state_case_id" - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name( - :vulnerabilities, - INDEX_NAME - ) - end - - def down - execute <<~SQL - CREATE INDEX CONCURRENTLY index_vulnerabilities_on_state_case_id ON vulnerabilities - USING btree (array_position(ARRAY[(1)::smallint, (4)::smallint, (3)::smallint, (2)::smallint], state), id DESC); - SQL - end -end diff --git a/db/post_migrate/20221121181627_drop_index_on_vulnerabilities_state_case_id_desc.rb b/db/post_migrate/20221121181627_drop_index_on_vulnerabilities_state_case_id_desc.rb deleted file mode 100644 index 712343bc7b0..00000000000 --- a/db/post_migrate/20221121181627_drop_index_on_vulnerabilities_state_case_id_desc.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnVulnerabilitiesStateCaseIdDesc < Gitlab::Database::Migration[2.0] - INDEX_NAME = "index_vulnerabilities_on_state_case_id_desc" - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name( - :vulnerabilities, - INDEX_NAME - ) - end - - def down - execute <<~SQL - CREATE INDEX CONCURRENTLY index_vulnerabilities_on_state_case_id_desc ON vulnerabilities - USING btree (array_position(ARRAY[(1)::smallint, (4)::smallint, (3)::smallint, (2)::smallint], state) DESC, id DESC); - SQL - end -end diff --git a/db/post_migrate/20221121184931_validate_not_null_contraint_on_issues_work_item_type_id.rb b/db/post_migrate/20221121184931_validate_not_null_contraint_on_issues_work_item_type_id.rb deleted file mode 100644 index be09f2ebe3a..00000000000 --- a/db/post_migrate/20221121184931_validate_not_null_contraint_on_issues_work_item_type_id.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class ValidateNotNullContraintOnIssuesWorkItemTypeId < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - def up - add_not_null_constraint :issues, :work_item_type_id, validate: true - end - - def down - remove_not_null_constraint :issues, :work_item_type_id - end -end diff --git a/db/post_migrate/20221122063922_remove_issue_title_trigram_index.rb b/db/post_migrate/20221122063922_remove_issue_title_trigram_index.rb deleted file mode 100644 index 80a2020a364..00000000000 --- a/db/post_migrate/20221122063922_remove_issue_title_trigram_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveIssueTitleTrigramIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_title_trigram' - - def up - remove_concurrent_index_by_name :issues, name: INDEX_NAME - end - - def down - disable_statement_timeout do - execute <<-SQL - CREATE INDEX CONCURRENTLY IF NOT EXISTS #{INDEX_NAME} ON issues - USING gin (title gin_trgm_ops) WITH (fastupdate='false') - SQL - end - end -end diff --git a/db/post_migrate/20221122064537_remove_issue_description_trigram_index.rb b/db/post_migrate/20221122064537_remove_issue_description_trigram_index.rb deleted file mode 100644 index c6d4f62de3e..00000000000 --- a/db/post_migrate/20221122064537_remove_issue_description_trigram_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveIssueDescriptionTrigramIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_description_trigram' - - def up - remove_concurrent_index_by_name :issues, name: INDEX_NAME - end - - def down - disable_statement_timeout do - execute <<-SQL - CREATE INDEX CONCURRENTLY IF NOT EXISTS #{INDEX_NAME} ON issues - USING gin (description gin_trgm_ops) WITH (fastupdate='false') - SQL - end - end -end diff --git a/db/post_migrate/20221122132812_schedule_prune_stale_project_export_jobs.rb b/db/post_migrate/20221122132812_schedule_prune_stale_project_export_jobs.rb deleted file mode 100644 index 871224ea18e..00000000000 --- a/db/post_migrate/20221122132812_schedule_prune_stale_project_export_jobs.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class SchedulePruneStaleProjectExportJobs < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - MIGRATION = 'PruneStaleProjectExportJobs' - DELAY_INTERVAL = 2.minutes - - def up - queue_batched_background_migration( - MIGRATION, - :project_export_jobs, - :id, - job_interval: DELAY_INTERVAL - ) - end - - def down - delete_batched_background_migration(MIGRATION, :project_export_jobs, :id, []) - end -end diff --git a/db/post_migrate/20221122155149_add_index_for_paths_on_non_projects.rb b/db/post_migrate/20221122155149_add_index_for_paths_on_non_projects.rb deleted file mode 100644 index e9a90844550..00000000000 --- a/db/post_migrate/20221122155149_add_index_for_paths_on_non_projects.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForPathsOnNonProjects < Gitlab::Database::Migration[2.0] - TABLE_NAME = 'namespaces' - INDEX_NAME = 'index_namespaces_on_path_for_top_level_non_projects' - COLUMN = "(lower(path::text))" - CONDITIONS = "(parent_id IS NULL AND type::text <> 'Project'::text)" - - def up - prepare_async_index TABLE_NAME, COLUMN, name: INDEX_NAME, where: CONDITIONS - end - - def down - unprepare_async_index TABLE_NAME, COLUMN, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221123133054_queue_reset_status_on_container_repositories.rb b/db/post_migrate/20221123133054_queue_reset_status_on_container_repositories.rb deleted file mode 100644 index 2d482e0b83c..00000000000 --- a/db/post_migrate/20221123133054_queue_reset_status_on_container_repositories.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class QueueResetStatusOnContainerRepositories < Gitlab::Database::Migration[2.0] - MIGRATION = 'ResetStatusOnContainerRepositories' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 50 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - return unless ::Gitlab.config.registry.enabled - - queue_batched_background_migration( - MIGRATION, - :container_repositories, - :id, - job_interval: DELAY_INTERVAL, - sub_batch_size: BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :container_repositories, :id, []) - end -end diff --git a/db/post_migrate/20221124153602_add_supporting_index_for_vulnerabilities_feedback_comment_proccessing.rb b/db/post_migrate/20221124153602_add_supporting_index_for_vulnerabilities_feedback_comment_proccessing.rb deleted file mode 100644 index 71f48e22b52..00000000000 --- a/db/post_migrate/20221124153602_add_supporting_index_for_vulnerabilities_feedback_comment_proccessing.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class AddSupportingIndexForVulnerabilitiesFeedbackCommentProccessing < Gitlab::Database::Migration[2.0] - INDEX_NAME = "tmp_idx_for_feedback_comment_processing" - WHERE_CLAUSE = "char_length(comment) > 50000" - - disable_ddl_transaction! - - def up - add_concurrent_index( - :vulnerability_feedback, - :id, - 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/20221125222221_add_metrics_index_to_authentication_events.rb b/db/post_migrate/20221125222221_add_metrics_index_to_authentication_events.rb deleted file mode 100644 index 2d3181dea67..00000000000 --- a/db/post_migrate/20221125222221_add_metrics_index_to_authentication_events.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddMetricsIndexToAuthenticationEvents < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_successful_authentication_events_for_metrics' - disable_ddl_transaction! - - def up - add_concurrent_index :authentication_events, - %i[user_id provider created_at], - where: "result = 1", - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :authentication_events, INDEX_NAME - end -end diff --git a/db/post_migrate/20221125222341_remove_result_index_from_authentication_events.rb b/db/post_migrate/20221125222341_remove_result_index_from_authentication_events.rb deleted file mode 100644 index 97fb4b320d1..00000000000 --- a/db/post_migrate/20221125222341_remove_result_index_from_authentication_events.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveResultIndexFromAuthenticationEvents < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_authentication_events_on_provider_user_id_created_at' - - def up - remove_concurrent_index_by_name :authentication_events, INDEX_NAME - end - - def down - add_concurrent_index :authentication_events, - [:provider, :user_id, :created_at], - where: 'result = 1', - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221128120634_schedule_fixing_security_scan_statuses.rb b/db/post_migrate/20221128120634_schedule_fixing_security_scan_statuses.rb deleted file mode 100644 index 1cf4a33e09f..00000000000 --- a/db/post_migrate/20221128120634_schedule_fixing_security_scan_statuses.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -class ScheduleFixingSecurityScanStatuses < Gitlab::Database::Migration[2.0] - MIGRATION = 'FixSecurityScanStatuses' - TABLE_NAME = :security_scans - BATCH_COLUMN = :id - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 10_000 - MAX_BATCH_SIZE = 50_000 - SUB_BATCH_SIZE = 100 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class SecurityScan < MigrationRecord - def self.start_migration_from - sort_order = Arel::Nodes::SqlLiteral.new("date(timezone('UTC'::text, created_at)) ASC, id ASC") - - where("date(timezone('UTC'::text, created_at)) > ?", 90.days.ago).order(sort_order).first&.id - end - end - - def up - # Only the SaaS application is affected - return unless Gitlab.dev_or_test_env? || Gitlab.com? - - batch_min_value = SecurityScan.start_migration_from - - return unless batch_min_value # It is possible that some users don't have corrupted records - - queue_batched_background_migration( - MIGRATION, - TABLE_NAME, - BATCH_COLUMN, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - max_batch_size: MAX_BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE, - batch_min_value: batch_min_value - ) - end - - def down - delete_batched_background_migration( - MIGRATION, - TABLE_NAME, - BATCH_COLUMN, - [] - ) - end -end diff --git a/db/post_migrate/20221128220043_drop_temp_work_item_type_id_backfill_index.rb b/db/post_migrate/20221128220043_drop_temp_work_item_type_id_backfill_index.rb deleted file mode 100644 index 97fb1202e6e..00000000000 --- a/db/post_migrate/20221128220043_drop_temp_work_item_type_id_backfill_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropTempWorkItemTypeIdBackfillIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_issues_on_issue_type_and_id' - - def up - remove_concurrent_index_by_name :issues, INDEX_NAME - end - - def down - add_concurrent_index :issues, [:issue_type, :id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221128222417_add_back_issues_work_item_type_id_index.rb b/db/post_migrate/20221128222417_add_back_issues_work_item_type_id_index.rb deleted file mode 100644 index 3ee6f0a6179..00000000000 --- a/db/post_migrate/20221128222417_add_back_issues_work_item_type_id_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddBackIssuesWorkItemTypeIdIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_work_item_type_id' - - def up - prepare_async_index :issues, :work_item_type_id, name: INDEX_NAME - end - - def down - unprepare_async_index :issues, :work_item_type_id, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221129124240_remove_flowdock_integration_records.rb b/db/post_migrate/20221129124240_remove_flowdock_integration_records.rb deleted file mode 100644 index 6390ed0d53b..00000000000 --- a/db/post_migrate/20221129124240_remove_flowdock_integration_records.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class RemoveFlowdockIntegrationRecords < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class Integration < MigrationRecord - include EachBatch - - self.table_name = 'integrations' - end - - def up - Integration.each_batch(of: 1000, column: :id) do |relation| - relation.delete_by(type_new: 'Integrations::Flowdock') - end - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221130192239_fix_approval_project_rules_without_protected_branches.rb b/db/post_migrate/20221130192239_fix_approval_project_rules_without_protected_branches.rb deleted file mode 100644 index 9cfe958ff60..00000000000 --- a/db/post_migrate/20221130192239_fix_approval_project_rules_without_protected_branches.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class FixApprovalProjectRulesWithoutProtectedBranches < Gitlab::Database::Migration[2.0] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 500 - MIGRATION = 'FixApprovalProjectRulesWithoutProtectedBranches' - 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, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :approval_project_rules, :id, []) - end -end diff --git a/db/post_migrate/20221202031332_add_index_to_issue_assignees_on_user_id_and_issue_id.rb b/db/post_migrate/20221202031332_add_index_to_issue_assignees_on_user_id_and_issue_id.rb deleted file mode 100644 index 5c008008218..00000000000 --- a/db/post_migrate/20221202031332_add_index_to_issue_assignees_on_user_id_and_issue_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToIssueAssigneesOnUserIdAndIssueId < Gitlab::Database::Migration[2.1] - INDEX_NAME = "index_issue_assignees_on_user_id_and_issue_id" - - disable_ddl_transaction! - - def up - add_concurrent_index :issue_assignees, [:user_id, :issue_id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :issue_assignees, INDEX_NAME - end -end diff --git a/db/post_migrate/20221202031417_remove_index_to_issue_assignees_on_user_id.rb b/db/post_migrate/20221202031417_remove_index_to_issue_assignees_on_user_id.rb deleted file mode 100644 index abdda680098..00000000000 --- a/db/post_migrate/20221202031417_remove_index_to_issue_assignees_on_user_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveIndexToIssueAssigneesOnUserId < Gitlab::Database::Migration[2.1] - INDEX_NAME = "index_issue_assignees_on_user_id" - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :issue_assignees, INDEX_NAME - end - - def down - add_concurrent_index :issue_assignees, [:user_id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221202154128_add_pipeline_metadata_name_index.rb b/db/post_migrate/20221202154128_add_pipeline_metadata_name_index.rb deleted file mode 100644 index 3d1d7fa7e5a..00000000000 --- a/db/post_migrate/20221202154128_add_pipeline_metadata_name_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddPipelineMetadataNameIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_pipeline_metadata_on_pipeline_id_name_lower_text_pattern' - - def up - add_concurrent_index :ci_pipeline_metadata, 'pipeline_id, lower(name) text_pattern_ops', name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :ci_pipeline_metadata, INDEX_NAME - end -end diff --git a/db/post_migrate/20221202154151_remove_pipeline_metadata_pipeline_id_index.rb b/db/post_migrate/20221202154151_remove_pipeline_metadata_pipeline_id_index.rb deleted file mode 100644 index 1c551f49fa6..00000000000 --- a/db/post_migrate/20221202154151_remove_pipeline_metadata_pipeline_id_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemovePipelineMetadataPipelineIdIndex < Gitlab::Database::Migration[2.0] - disable_ddl_transaction! - - INDEX_NAME = 'index_ci_pipeline_metadata_on_pipeline_id_name' - - def up - remove_concurrent_index_by_name :ci_pipeline_metadata, INDEX_NAME - end - - def down - add_concurrent_index :ci_pipeline_metadata, [:pipeline_id, :name], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20221205134448_set_index_for_issues_health_status_ordering.rb b/db/post_migrate/20221205134448_set_index_for_issues_health_status_ordering.rb deleted file mode 100644 index 38426c3ba15..00000000000 --- a/db/post_migrate/20221205134448_set_index_for_issues_health_status_ordering.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class SetIndexForIssuesHealthStatusOrdering < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME_DESC = 'index_on_issues_health_status_desc_order' - INDEX_NAME_ASC = 'index_on_issues_health_status_asc_order' - - def up - add_concurrent_index :issues, - [:project_id, :health_status, :id, :state_id, :issue_type], - order: { health_status: 'DESC NULLS LAST', id: :desc }, - name: INDEX_NAME_DESC - - add_concurrent_index :issues, - [:project_id, :health_status, :id, :state_id, :issue_type], - order: { health_status: 'ASC NULLS LAST', id: :desc }, - name: INDEX_NAME_ASC - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME_DESC - remove_concurrent_index_by_name :issues, INDEX_NAME_ASC - end -end diff --git a/db/post_migrate/20221205151917_schedule_backfill_environment_tier.rb b/db/post_migrate/20221205151917_schedule_backfill_environment_tier.rb deleted file mode 100644 index eb62e50ea65..00000000000 --- a/db/post_migrate/20221205151917_schedule_backfill_environment_tier.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillEnvironmentTier < Gitlab::Database::Migration[2.0] - MIGRATION = 'BackfillEnvironmentTiers' - DELAY_INTERVAL = 2.minutes - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :environments, - :id, - job_interval: DELAY_INTERVAL - ) - end - - def down - delete_batched_background_migration(MIGRATION, :environments, :id, []) - end -end diff --git a/db/post_migrate/20221205170310_add_index_for_active_members.rb b/db/post_migrate/20221205170310_add_index_for_active_members.rb deleted file mode 100644 index c52b8ccfd04..00000000000 --- a/db/post_migrate/20221205170310_add_index_for_active_members.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForActiveMembers < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_members_on_source_state_type_access_level_and_user_id' - - disable_ddl_transaction! - - def up - where_clause = 'requested_at is null and invite_token is null' - - add_concurrent_index :members, [:source_id, :source_type, :state, :type, :access_level, :user_id], - name: INDEX_NAME, where: where_clause - end - - def down - remove_concurrent_index_by_name :members, INDEX_NAME - end -end diff --git a/db/post_migrate/20221206012013_add_index_author_id_created_at_on_merge_requests.rb b/db/post_migrate/20221206012013_add_index_author_id_created_at_on_merge_requests.rb deleted file mode 100644 index 886d8aed71a..00000000000 --- a/db/post_migrate/20221206012013_add_index_author_id_created_at_on_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexAuthorIdCreatedAtOnMergeRequests < Gitlab::Database::Migration[2.0] - INDEX_NAME = 'index_merge_requests_on_author_id_and_created_at' - - disable_ddl_transaction! - - def up - add_concurrent_index :merge_requests, %i[author_id created_at], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :merge_requests, INDEX_NAME - end -end diff --git a/db/post_migrate/20221206075631_add_unique_id_partition_id_index_to_ci_build.rb b/db/post_migrate/20221206075631_add_unique_id_partition_id_index_to_ci_build.rb deleted file mode 100644 index c3e7a5799d0..00000000000 --- a/db/post_migrate/20221206075631_add_unique_id_partition_id_index_to_ci_build.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIdPartitionIdIndexToCiBuild < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_builds - INDEX_NAME = :index_ci_builds_on_id_partition_id_unique - COLUMNS = %i[id partition_id].freeze - - 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/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb b/db/post_migrate/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb deleted file mode 100644 index c330ece1a60..00000000000 --- a/db/post_migrate/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueTokenEncryptedPartitionIdIndexToCiBuild < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_builds - INDEX_NAME = :index_ci_builds_on_token_encrypted_partition_id_unique - COLUMNS = %i[token_encrypted partition_id].freeze - - def up - prepare_async_index( - TABLE_NAME, - COLUMNS, - where: 'token_encrypted IS NOT NULL', - 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/20221206173132_add_issues_work_item_type_id_index.rb b/db/post_migrate/20221206173132_add_issues_work_item_type_id_index.rb deleted file mode 100644 index b50da0e4644..00000000000 --- a/db/post_migrate/20221206173132_add_issues_work_item_type_id_index.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIssuesWorkItemTypeIdIndex < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_issues_on_work_item_type_id' - - def up - add_concurrent_index :issues, :work_item_type_id, name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :issues, INDEX_NAME - end -end diff --git a/db/post_migrate/20221209235939_add_tmp_index_oauth_access_tokens_on_id_where_expires_in_null.rb b/db/post_migrate/20221209235939_add_tmp_index_oauth_access_tokens_on_id_where_expires_in_null.rb deleted file mode 100644 index 0f313f420f0..00000000000 --- a/db/post_migrate/20221209235939_add_tmp_index_oauth_access_tokens_on_id_where_expires_in_null.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexOauthAccessTokensOnIdWhereExpiresInNull < Gitlab::Database::Migration[2.1] - TMP_INDEX = 'tmp_index_oauth_access_tokens_on_id_where_expires_in_null' - - disable_ddl_transaction! - - def up - # Temporary index to be removed in %15.9 or later https://gitlab.com/gitlab-org/gitlab/-/issues/385343 - add_concurrent_index :oauth_access_tokens, :id, where: "expires_in IS NULL", name: TMP_INDEX - end - - def down - remove_concurrent_index_by_name :oauth_access_tokens, TMP_INDEX - end -end diff --git a/db/post_migrate/20221209235940_cleanup_o_auth_access_tokens_with_null_expires_in.rb b/db/post_migrate/20221209235940_cleanup_o_auth_access_tokens_with_null_expires_in.rb deleted file mode 100644 index 8daf5bf4d93..00000000000 --- a/db/post_migrate/20221209235940_cleanup_o_auth_access_tokens_with_null_expires_in.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class CleanupOAuthAccessTokensWithNullExpiresIn < Gitlab::Database::Migration[2.1] - MIGRATION = 'ReExpireOAuthTokens' - INTERVAL = 2.minutes - MAX_BATCH_SIZE = 50_000 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :oauth_access_tokens, - :id, - job_interval: INTERVAL, - max_batch_size: MAX_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :oauth_access_tokens, :id, []) - end -end diff --git a/db/post_migrate/20221210154044_update_active_billable_users_index.rb b/db/post_migrate/20221210154044_update_active_billable_users_index.rb deleted file mode 100644 index 9d306eff16b..00000000000 --- a/db/post_migrate/20221210154044_update_active_billable_users_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true -class UpdateActiveBillableUsersIndex < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - OLD_INDEX_NAME = 'active_billable_users' - NEW_INDEX_NAME = 'index_users_for_active_billable' - TABLE_NAME = 'users' - COLUMNS = %i[id] - OLD_INDEX_FILTER_CONDITION = <<~QUERY - ((state)::text = 'active'::text) AND ((user_type IS NULL) - OR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL) - OR (user_type <> ALL ('{2,6,1,3,7,8}'::smallint[]))) - QUERY - NEW_INDEX_FILTER_CONDITION = <<~QUERY - ((state)::text = 'active'::text) AND ((user_type IS NULL) - OR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL) - OR (user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[]))) - QUERY - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, where: NEW_INDEX_FILTER_CONDITION, name: NEW_INDEX_NAME) - remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME) - end - - def down - add_concurrent_index(TABLE_NAME, COLUMNS, where: OLD_INDEX_FILTER_CONDITION, name: OLD_INDEX_NAME) - remove_concurrent_index_by_name(TABLE_NAME, NEW_INDEX_NAME) - end -end diff --git a/db/post_migrate/20221212103743_add_index_id_partition_id_to_ci_build.rb b/db/post_migrate/20221212103743_add_index_id_partition_id_to_ci_build.rb deleted file mode 100644 index aab67272a77..00000000000 --- a/db/post_migrate/20221212103743_add_index_id_partition_id_to_ci_build.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexIdPartitionIdToCiBuild < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - TABLE_NAME = :ci_builds - INDEX_NAME = :index_ci_builds_on_id_partition_id_unique - COLUMNS = %i[id partition_id].freeze - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, 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/20221213064717_change_default_partition_id_on_ci_resources.rb b/db/post_migrate/20221213064717_change_default_partition_id_on_ci_resources.rb deleted file mode 100644 index 889659cdc2c..00000000000 --- a/db/post_migrate/20221213064717_change_default_partition_id_on_ci_resources.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class ChangeDefaultPartitionIdOnCiResources < Gitlab::Database::Migration[2.1] - enable_lock_retries! - - def change - change_column_default :ci_resources, :partition_id, from: 100, to: nil - end -end diff --git a/db/post_migrate/20221214095129_second_recount_epic_cache_counts.rb b/db/post_migrate/20221214095129_second_recount_epic_cache_counts.rb deleted file mode 100644 index 608e27c344e..00000000000 --- a/db/post_migrate/20221214095129_second_recount_epic_cache_counts.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class SecondRecountEpicCacheCounts < Gitlab::Database::Migration[2.0] - MIGRATION = 'SecondRecountEpicCacheCounts' - 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/20221214105307_add_token_encrypted_partition_id_index_to_ci_build.rb b/db/post_migrate/20221214105307_add_token_encrypted_partition_id_index_to_ci_build.rb deleted file mode 100644 index 4c64e9b0e70..00000000000 --- a/db/post_migrate/20221214105307_add_token_encrypted_partition_id_index_to_ci_build.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddTokenEncryptedPartitionIdIndexToCiBuild < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - TABLE_NAME = :ci_builds - INDEX_NAME = :unique_ci_builds_token_encrypted_and_partition_id - COLUMNS = %i[token_encrypted partition_id].freeze - - def up - prepare_async_index( - TABLE_NAME, - COLUMNS, - where: 'token_encrypted IS NOT NULL', - 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/20221215151822_schedule_backfill_releases_author_id.rb b/db/post_migrate/20221215151822_schedule_backfill_releases_author_id.rb deleted file mode 100644 index 4d8343ca2dd..00000000000 --- a/db/post_migrate/20221215151822_schedule_backfill_releases_author_id.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -class ScheduleBackfillReleasesAuthorId < Gitlab::Database::Migration[2.1] - MIGRATION = 'BackfillReleasesAuthorId' - JOB_DELAY_INTERVAL = 2.minutes - GHOST_USER_TYPE = 5 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class User < MigrationRecord - self.table_name = 'users' - end - - class Release < MigrationRecord - self.table_name = 'releases' - end - - def up - unless release_with_empty_author_exists? - say "There are no releases with empty author_id, so skipping migration #{self.class.name}" - return - end - - create_ghost_user if ghost_user_id.nil? - - queue_batched_background_migration( - MIGRATION, - :releases, - :id, - ghost_user_id, - job_interval: JOB_DELAY_INTERVAL - ) - end - - def down - delete_batched_background_migration(MIGRATION, :releases, :id, [ghost_user_id]) - end - - private - - def ghost_user_id - User.find_by(user_type: GHOST_USER_TYPE)&.id - end - - def create_ghost_user - user = User.new - user.name = 'Ghost User' - user.username = 'ghost' - user.email = 'ghost@example.com' - user.user_type = GHOST_USER_TYPE - user.projects_limit = 100000 - - user.save! - end - - def release_with_empty_author_exists? - Release.exists?(author_id: nil) - end -end diff --git a/db/post_migrate/20221216131710_add_index_to_ci_unit_test_failure.rb b/db/post_migrate/20221216131710_add_index_to_ci_unit_test_failure.rb deleted file mode 100644 index f99d2914aa4..00000000000 --- a/db/post_migrate/20221216131710_add_index_to_ci_unit_test_failure.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToCiUnitTestFailure < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_unit_test_failures_on_partition_id_build_id - TABLE_NAME = :ci_unit_test_failures - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20221216131935_add_index_to_ci_build_pending_state.rb b/db/post_migrate/20221216131935_add_index_to_ci_build_pending_state.rb deleted file mode 100644 index 4fec5e016a4..00000000000 --- a/db/post_migrate/20221216131935_add_index_to_ci_build_pending_state.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToCiBuildPendingState < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_build_pending_states_on_partition_id_build_id - TABLE_NAME = :ci_build_pending_states - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20221216131958_add_index_to_ci_build_trace_chunk.rb b/db/post_migrate/20221216131958_add_index_to_ci_build_trace_chunk.rb deleted file mode 100644 index 5577a18c144..00000000000 --- a/db/post_migrate/20221216131958_add_index_to_ci_build_trace_chunk.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToCiBuildTraceChunk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_build_trace_chunks_on_partition_id_build_id - TABLE_NAME = :ci_build_trace_chunks - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20221216144854_add_foreign_key_to_ci_unit_test_failure.rb b/db/post_migrate/20221216144854_add_foreign_key_to_ci_unit_test_failure.rb deleted file mode 100644 index e04647d7c92..00000000000 --- a/db/post_migrate/20221216144854_add_foreign_key_to_ci_unit_test_failure.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCiUnitTestFailure < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_unit_test_failures - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_0f09856e1f_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end -end diff --git a/db/post_migrate/20221216150304_add_foreign_key_to_ci_build_pending_state.rb b/db/post_migrate/20221216150304_add_foreign_key_to_ci_build_pending_state.rb deleted file mode 100644 index ef9ecc3033f..00000000000 --- a/db/post_migrate/20221216150304_add_foreign_key_to_ci_build_pending_state.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCiBuildPendingState < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_pending_states - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_0bbbfeaf9d_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end -end diff --git a/db/post_migrate/20221216150321_add_foreign_key_to_ci_build_trace_chunk.rb b/db/post_migrate/20221216150321_add_foreign_key_to_ci_build_trace_chunk.rb deleted file mode 100644 index dd16d3d7787..00000000000 --- a/db/post_migrate/20221216150321_add_foreign_key_to_ci_build_trace_chunk.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCiBuildTraceChunk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_trace_chunks - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_1013b761f2_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end -end diff --git a/db/post_migrate/20221216150919_validate_foreign_key_on_ci_unit_test_failure_partition_id_build_id.rb b/db/post_migrate/20221216150919_validate_foreign_key_on_ci_unit_test_failure_partition_id_build_id.rb deleted file mode 100644 index a886949aea7..00000000000 --- a/db/post_migrate/20221216150919_validate_foreign_key_on_ci_unit_test_failure_partition_id_build_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class ValidateForeignKeyOnCiUnitTestFailurePartitionIdBuildId < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_unit_test_failures - FK_NAME = :fk_0f09856e1f_p - PARTITION_COLUMN = :partition_id - COLUMN = :build_id - - def up - validate_foreign_key(TABLE_NAME, [PARTITION_COLUMN, COLUMN], name: FK_NAME) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221216151459_validate_foreign_key_on_ci_build_pending_state_partition_id_build_id.rb b/db/post_migrate/20221216151459_validate_foreign_key_on_ci_build_pending_state_partition_id_build_id.rb deleted file mode 100644 index 6ea8cb213ab..00000000000 --- a/db/post_migrate/20221216151459_validate_foreign_key_on_ci_build_pending_state_partition_id_build_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class ValidateForeignKeyOnCiBuildPendingStatePartitionIdBuildId < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_build_pending_states - FK_NAME = :fk_rails_0bbbfeaf9d_p - PARTITION_COLUMN = :partition_id - COLUMN = :build_id - - def up - validate_foreign_key(TABLE_NAME, [PARTITION_COLUMN, COLUMN], name: FK_NAME) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221216151649_validate_foreign_key_on_ci_build_trace_chunk_partition_id_build_id.rb b/db/post_migrate/20221216151649_validate_foreign_key_on_ci_build_trace_chunk_partition_id_build_id.rb deleted file mode 100644 index 8afd7de808b..00000000000 --- a/db/post_migrate/20221216151649_validate_foreign_key_on_ci_build_trace_chunk_partition_id_build_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class ValidateForeignKeyOnCiBuildTraceChunkPartitionIdBuildId < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_build_trace_chunks - FK_NAME = :fk_rails_1013b761f2_p - PARTITION_COLUMN = :partition_id - COLUMN = :build_id - - def up - validate_foreign_key(TABLE_NAME, [PARTITION_COLUMN, COLUMN], name: FK_NAME) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221216232658_index_members_on_member_namespace_id_compound.rb b/db/post_migrate/20221216232658_index_members_on_member_namespace_id_compound.rb deleted file mode 100644 index 56adad1e4a5..00000000000 --- a/db/post_migrate/20221216232658_index_members_on_member_namespace_id_compound.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class IndexMembersOnMemberNamespaceIdCompound < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_members_on_member_namespace_id_compound' - - disable_ddl_transaction! - - def up - prepare_async_index( - :members, - [:member_namespace_id, :type, :requested_at, :id], - name: INDEX_NAME - ) - end - - def down - remove_concurrent_index_by_name :members, INDEX_NAME - end -end diff --git a/db/post_migrate/20221216232659_index_members_on_member_namespace_id_compound_sync.rb b/db/post_migrate/20221216232659_index_members_on_member_namespace_id_compound_sync.rb deleted file mode 100644 index f37a1b694b4..00000000000 --- a/db/post_migrate/20221216232659_index_members_on_member_namespace_id_compound_sync.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class IndexMembersOnMemberNamespaceIdCompoundSync < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_members_on_member_namespace_id_compound' - - disable_ddl_transaction! - - def up - add_concurrent_index( - :members, - [:member_namespace_id, :type, :requested_at, :id], - name: INDEX_NAME - ) - end - - def down - remove_concurrent_index_by_name :members, INDEX_NAME - end -end diff --git a/db/post_migrate/20221220075936_add_query_index_for_ci_pipeline_schedules.rb b/db/post_migrate/20221220075936_add_query_index_for_ci_pipeline_schedules.rb deleted file mode 100644 index 4fc64f66a83..00000000000 --- a/db/post_migrate/20221220075936_add_query_index_for_ci_pipeline_schedules.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddQueryIndexForCiPipelineSchedules < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_pipeline_schedules - INDEX_NAME = :index_ci_pipeline_schedules_on_id_and_next_run_at_and_active - COLUMNS = %i[id next_run_at].freeze - INDEX_CONDITION = 'active = TRUE' - - disable_ddl_transaction! - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME, where: INDEX_CONDITION) - end - - def down - remove_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20221220131020_bump_default_partition_id_value_for_ci_tables.rb b/db/post_migrate/20221220131020_bump_default_partition_id_value_for_ci_tables.rb deleted file mode 100644 index 3d06f02a6d6..00000000000 --- a/db/post_migrate/20221220131020_bump_default_partition_id_value_for_ci_tables.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -class BumpDefaultPartitionIdValueForCiTables < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - TABLES = { - ci_build_needs: [:partition_id], - ci_build_pending_states: [:partition_id], - ci_build_report_results: [:partition_id], - ci_build_trace_chunks: [:partition_id], - ci_build_trace_metadata: [:partition_id], - ci_builds: [:partition_id], - ci_builds_runner_session: [:partition_id], - ci_job_artifacts: [:partition_id], - ci_job_variables: [:partition_id], - ci_pending_builds: [:partition_id], - ci_pipeline_variables: [:partition_id], - ci_pipelines: [:partition_id], - ci_running_builds: [:partition_id], - ci_sources_pipelines: [:partition_id, :source_partition_id], - ci_stages: [:partition_id], - ci_unit_test_failures: [:partition_id], - p_ci_builds_metadata: [:partition_id] - } - - def up - change_partitions_default_value(from: 100, to: 101) - end - - def down - change_partitions_default_value(from: 101, to: 100) - end - - private - - def change_partitions_default_value(from:, to:) - return unless Gitlab.com? - - TABLES.each do |table_name, columns| - next if columns.all? { |column_name| default_value_for(table_name, column_name) == to } - - with_lock_retries do - columns.each do |column_name| # rubocop:disable Migration/WithLockRetriesDisallowedMethod - change_column_default(table_name, column_name, from: from, to: to) - end - end - end - end - - def default_value_for(table_name, column_name) - connection - .columns(table_name) - .find { |column| column.name == column_name.to_s } - .default&.to_i - end -end diff --git a/db/post_migrate/20221221110733_remove_temp_index_for_project_statistics_upload_size_migration.rb b/db/post_migrate/20221221110733_remove_temp_index_for_project_statistics_upload_size_migration.rb deleted file mode 100644 index 1df6ad274f9..00000000000 --- a/db/post_migrate/20221221110733_remove_temp_index_for_project_statistics_upload_size_migration.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveTempIndexForProjectStatisticsUploadSizeMigration < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'tmp_index_project_statistics_uploads_size' - TABLE_NAME = 'project_statistics' - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :project_statistics, INDEX_NAME - end - - def down - add_concurrent_index :project_statistics, [:project_id], - name: INDEX_NAME, - where: "uploads_size <> 0" - end -end diff --git a/db/post_migrate/20221221150123_update_billable_users_index.rb b/db/post_migrate/20221221150123_update_billable_users_index.rb deleted file mode 100644 index d77669f6a69..00000000000 --- a/db/post_migrate/20221221150123_update_billable_users_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class UpdateBillableUsersIndex < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - NEW_INDEX = 'index_users_for_billable_users' - OLD_INDEX = 'index_users_for_active_billable' - - OLD_INDEX_CONDITION = <<~QUERY - ((state)::text = 'active'::text) AND ((user_type IS NULL) - OR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL) - OR (user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[]))) - QUERY - NEW_INDEX_CONDITION = <<~QUERY - state = 'active' AND (user_type IS NULL OR user_type IN (6, 4)) AND (user_type IS NULL OR user_type IN (4, 5)) - QUERY - - def up - # rubocop:disable Migration/PreventIndexCreation - add_concurrent_index(:users, :id, where: NEW_INDEX_CONDITION, name: NEW_INDEX) - # rubocop:enable Migration/PreventIndexCreation - remove_concurrent_index_by_name(:users, OLD_INDEX) - end - - def down - add_concurrent_index(:users, :id, where: OLD_INDEX_CONDITION, name: OLD_INDEX) - remove_concurrent_index_by_name(:users, NEW_INDEX) - end -end diff --git a/db/post_migrate/20221222092958_sync_new_amount_used_with_amount_used.rb b/db/post_migrate/20221222092958_sync_new_amount_used_with_amount_used.rb deleted file mode 100644 index 9d8e2ee54d6..00000000000 --- a/db/post_migrate/20221222092958_sync_new_amount_used_with_amount_used.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class SyncNewAmountUsedWithAmountUsed < Gitlab::Database::Migration[2.1] - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - def up - # This migration will only run on rollback, there is no need for the positive case - end - - def down - 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 -end diff --git a/db/post_migrate/20221223123019_delete_queued_jobs_for_vulnerabilities_feedback_migration.rb b/db/post_migrate/20221223123019_delete_queued_jobs_for_vulnerabilities_feedback_migration.rb deleted file mode 100644 index e5822d2d7a2..00000000000 --- a/db/post_migrate/20221223123019_delete_queued_jobs_for_vulnerabilities_feedback_migration.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class DeleteQueuedJobsForVulnerabilitiesFeedbackMigration < Gitlab::Database::Migration[2.1] - MIGRATION = 'MigrateVulnerabilitiesFeedbackToVulnerabilitiesStateTransition' - TABLE_NAME = :vulnerability_feedback - BATCH_COLUMN = :id - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - delete_batched_background_migration( - MIGRATION, - TABLE_NAME, - BATCH_COLUMN, - [] - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20221226153240_remove_chat_names_integration_id_foreign_key.rb b/db/post_migrate/20221226153240_remove_chat_names_integration_id_foreign_key.rb deleted file mode 100644 index 51baa9c9f57..00000000000 --- a/db/post_migrate/20221226153240_remove_chat_names_integration_id_foreign_key.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class RemoveChatNamesIntegrationIdForeignKey < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :chat_names - TARGET_TABLE_NAME = :integrations - COLUMN = :integration_id - TARGET_COLUMN = :id - FK_NAME = :fk_99a1348daf - - def up - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: COLUMN, - name: FK_NAME, - on_delete: :cascade - ) - end -end diff --git a/db/post_migrate/20221226154458_drop_index_on_chat_names_on_integration_id_and_team_id_and_chat_id.rb b/db/post_migrate/20221226154458_drop_index_on_chat_names_on_integration_id_and_team_id_and_chat_id.rb deleted file mode 100644 index d5aeb704983..00000000000 --- a/db/post_migrate/20221226154458_drop_index_on_chat_names_on_integration_id_and_team_id_and_chat_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnChatNamesOnIntegrationIdAndTeamIdAndChatId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_chat_names_on_integration_id_and_team_id_and_chat_id' - - def up - remove_concurrent_index_by_name(:chat_names, INDEX_NAME) - end - - def down - add_concurrent_index(:chat_names, [:integration_id, :team_id, :chat_id], name: INDEX_NAME, unique: true) - end -end diff --git a/db/post_migrate/20221227100751_add_user_index_to_chat_names.rb b/db/post_migrate/20221227100751_add_user_index_to_chat_names.rb deleted file mode 100644 index 7be671b2cbd..00000000000 --- a/db/post_migrate/20221227100751_add_user_index_to_chat_names.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUserIndexToChatNames < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_chat_names_on_user_id' - - def up - add_concurrent_index(:chat_names, :user_id, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(:chat_names, name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20221227101436_drop_index_on_chat_names_on_user_id_and_integration_id.rb b/db/post_migrate/20221227101436_drop_index_on_chat_names_on_user_id_and_integration_id.rb deleted file mode 100644 index ab2842ea775..00000000000 --- a/db/post_migrate/20221227101436_drop_index_on_chat_names_on_user_id_and_integration_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnChatNamesOnUserIdAndIntegrationId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_chat_names_on_user_id_and_integration_id' - - def up - remove_concurrent_index_by_name(:chat_names, INDEX_NAME) - end - - def down - add_concurrent_index(:chat_names, [:user_id, :integration_id], name: INDEX_NAME, unique: true) - end -end diff --git a/db/post_migrate/20221228103133_queue_backfill_admin_mode_scope_for_personal_access_tokens.rb b/db/post_migrate/20221228103133_queue_backfill_admin_mode_scope_for_personal_access_tokens.rb deleted file mode 100644 index 577d55f4df6..00000000000 --- a/db/post_migrate/20221228103133_queue_backfill_admin_mode_scope_for_personal_access_tokens.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class QueueBackfillAdminModeScopeForPersonalAccessTokens < Gitlab::Database::Migration[2.1] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - # no-op as the original migration is rescheduled - # in migrations version 20230406093640 - def up; end - - def down; end -end diff --git a/db/post_migrate/20221228163035_cleanup_appearances_short_title_rename.rb b/db/post_migrate/20221228163035_cleanup_appearances_short_title_rename.rb deleted file mode 100644 index 300d53f227a..00000000000 --- a/db/post_migrate/20221228163035_cleanup_appearances_short_title_rename.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupAppearancesShortTitleRename < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :appearances, :short_title, :pwa_short_name - end - - def down - undo_cleanup_concurrent_column_rename :appearances, :short_title, :pwa_short_name - end -end diff --git a/db/post_migrate/20221228210616_add_index_on_ci_runners_on_runner_type_and_id.rb b/db/post_migrate/20221228210616_add_index_on_ci_runners_on_runner_type_and_id.rb deleted file mode 100644 index 62c40b78945..00000000000 --- a/db/post_migrate/20221228210616_add_index_on_ci_runners_on_runner_type_and_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnCiRunnersOnRunnerTypeAndId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - OLD_INDEX_NAME = 'index_ci_runners_on_runner_type' - NEW_INDEX_NAME = 'index_ci_runners_on_runner_type_and_id' - - def up - add_concurrent_index :ci_runners, [:runner_type, :id], name: NEW_INDEX_NAME - remove_concurrent_index_by_name :ci_runners, OLD_INDEX_NAME - end - - def down - add_concurrent_index :ci_runners, :runner_type, name: OLD_INDEX_NAME - remove_concurrent_index_by_name :ci_runners, NEW_INDEX_NAME - end -end diff --git a/db/post_migrate/20230104103748_remove_new_amount_used_column.rb b/db/post_migrate/20230104103748_remove_new_amount_used_column.rb deleted file mode 100644 index b93879c2b50..00000000000 --- a/db/post_migrate/20230104103748_remove_new_amount_used_column.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class RemoveNewAmountUsedColumn < Gitlab::Database::Migration[2.1] - TRIGGER_NAME = 'sync_projects_amount_used_columns' - def up - remove_rename_triggers :ci_project_monthly_usages, TRIGGER_NAME - remove_column :ci_project_monthly_usages, :new_amount_used - end - - def down - return if column_exists?(:ci_project_monthly_usages, :new_amount_used) - - # rubocop:disable Migration/AddColumnsToWideTables - add_column :ci_project_monthly_usages, :new_amount_used, :decimal, default: 0.0, - precision: 18, scale: 2, null: false - # rubocop:enable Migration/AddColumnsToWideTables - - install_rename_triggers :ci_project_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME - end -end diff --git a/db/post_migrate/20230104150601_prepare_builds_metadata_async_idx.rb b/db/post_migrate/20230104150601_prepare_builds_metadata_async_idx.rb deleted file mode 100644 index 83dfe62ad71..00000000000 --- a/db/post_migrate/20230104150601_prepare_builds_metadata_async_idx.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class PrepareBuildsMetadataAsyncIdx < Gitlab::Database::Migration[2.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'p_ci_builds_metadata_on_runner_machine_id_idx' - - def up - # Break up the logic from add_concurrent_partitioned_index so that the partition indices can be created async - # A follow-up migration will complete the index creation by creating the index on the metadata table, and - # creating the concurrent foreign key - each_partition(:p_ci_builds_metadata) do |partition, partition_index_name| - prepare_async_index(partition.identifier, :runner_machine_id, - name: partition_index_name, where: 'runner_machine_id IS NOT NULL') - end - end - - def down - each_partition(:p_ci_builds_metadata) do |partition, partition_index_name| - unprepare_async_index_by_name(partition.identifier, partition_index_name) - end - end - - private - - def each_partition(table_name) - partitioned_table = find_partitioned_table(table_name) - partitioned_table.postgres_partitions.order(:name).each do |partition| - partition_index_name = generated_index_name(partition.identifier, INDEX_NAME) - - yield partition, partition_index_name - end - end -end diff --git a/db/post_migrate/20230104220137_reindex_vuln_reads_on_default_branch_with_common_query.rb b/db/post_migrate/20230104220137_reindex_vuln_reads_on_default_branch_with_common_query.rb deleted file mode 100644 index 114a1a84fa0..00000000000 --- a/db/post_migrate/20230104220137_reindex_vuln_reads_on_default_branch_with_common_query.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class ReindexVulnReadsOnDefaultBranchWithCommonQuery < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_vuln_reads_common_query_on_resolved_on_default_branch' - - COLUMNS = %i[project_id state report_type vulnerability_id] - - disable_ddl_transaction! - - def up - add_concurrent_index( - :vulnerability_reads, - COLUMNS, - name: INDEX_NAME, - where: 'resolved_on_default_branch IS TRUE', - order: { vulnerability_id: :desc } - ) - end - - def down - remove_concurrent_index_by_name( - :vulnerability_reads, - INDEX_NAME - ) - end -end diff --git a/db/post_migrate/20230104222438_add_partition_index_to_builds_metadata.rb b/db/post_migrate/20230104222438_add_partition_index_to_builds_metadata.rb deleted file mode 100644 index 474f6f8540b..00000000000 --- a/db/post_migrate/20230104222438_add_partition_index_to_builds_metadata.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddPartitionIndexToBuildsMetadata < Gitlab::Database::Migration[2.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'p_ci_builds_metadata_on_runner_machine_id_idx' - - def up - add_concurrent_partitioned_index :p_ci_builds_metadata, :runner_machine_id, name: INDEX_NAME, - where: 'runner_machine_id IS NOT NULL' - end - - def down - remove_concurrent_partitioned_index_by_name :p_ci_builds_metadata, INDEX_NAME - end -end diff --git a/db/post_migrate/20230104222514_add_foreign_key_to_builds_metadata.rb b/db/post_migrate/20230104222514_add_foreign_key_to_builds_metadata.rb deleted file mode 100644 index b9c78e4eeb9..00000000000 --- a/db/post_migrate/20230104222514_add_foreign_key_to_builds_metadata.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToBuildsMetadata < Gitlab::Database::Migration[2.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - def up - add_concurrent_partitioned_foreign_key :p_ci_builds_metadata, - :ci_runner_machines, - column: :runner_machine_id, - on_delete: :nullify - end - - def down - remove_foreign_key_if_exists :p_ci_builds_metadata, column: :runner_machine_id - end -end diff --git a/db/post_migrate/20230104224020_drop_vuln_reads_on_default_branch_index.rb b/db/post_migrate/20230104224020_drop_vuln_reads_on_default_branch_index.rb deleted file mode 100644 index acac69478a3..00000000000 --- a/db/post_migrate/20230104224020_drop_vuln_reads_on_default_branch_index.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class DropVulnReadsOnDefaultBranchIndex < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_vuln_reads_on_resolved_on_default_branch' - - COLUMNS = %i[project_id state id] - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :vulnerability_reads, name: INDEX_NAME - end - - def down - add_concurrent_index :vulnerability_reads, COLUMNS, - where: 'resolved_on_default_branch IS TRUE', - name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230105172120_sync_new_amount_used_with_amount_used_on_ci_namespace_monthly_usages_table.rb b/db/post_migrate/20230105172120_sync_new_amount_used_with_amount_used_on_ci_namespace_monthly_usages_table.rb deleted file mode 100644 index 4181d6a0f92..00000000000 --- a/db/post_migrate/20230105172120_sync_new_amount_used_with_amount_used_on_ci_namespace_monthly_usages_table.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - def up - # This migration will only run on rollback, there is no need for the positive case - end - - def down - project_usages = define_batchable_model('ci_namespace_monthly_usages') - - project_usages.each_batch(of: 500) do |batch| - batch.where('amount_used > 0').update_all('new_amount_used = amount_used') - end - end -end diff --git a/db/post_migrate/20230105180002_remove_new_amount_used_column_on_ci_namespace_monthly_usages.rb b/db/post_migrate/20230105180002_remove_new_amount_used_column_on_ci_namespace_monthly_usages.rb deleted file mode 100644 index 11e212a697d..00000000000 --- a/db/post_migrate/20230105180002_remove_new_amount_used_column_on_ci_namespace_monthly_usages.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages < Gitlab::Database::Migration[2.1] - enable_lock_retries! - - TRIGGER_NAME = 'sync_namespaces_amount_used_columns' - def up - remove_rename_triggers :ci_namespace_monthly_usages, TRIGGER_NAME - remove_column :ci_namespace_monthly_usages, :new_amount_used - end - - def down - return if column_exists?(:ci_namespace_monthly_usages, :new_amount_used) - - # rubocop:disable Migration/AddColumnsToWideTables - add_column :ci_namespace_monthly_usages, :new_amount_used, :decimal, default: 0.0, - precision: 18, scale: 2, null: false - # rubocop:enable Migration/AddColumnsToWideTables - - install_rename_triggers :ci_namespace_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME - end -end diff --git a/db/post_migrate/20230106124332_change_keys_relation_to_ssh_signatures.rb b/db/post_migrate/20230106124332_change_keys_relation_to_ssh_signatures.rb deleted file mode 100644 index e76a3617ba3..00000000000 --- a/db/post_migrate/20230106124332_change_keys_relation_to_ssh_signatures.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -class ChangeKeysRelationToSshSignatures < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - TARGET_COLUMN = :key_id - - def up - add_concurrent_foreign_key( - :ssh_signatures, - :keys, - column: :key_id, - name: fk_name("#{TARGET_COLUMN}_nullify"), - on_delete: :nullify - ) - - with_lock_retries do - remove_foreign_key_if_exists(:ssh_signatures, column: TARGET_COLUMN, name: fk_name(TARGET_COLUMN)) - end - end - - def down - add_concurrent_foreign_key( - :ssh_signatures, - :keys, - column: :key_id, - name: fk_name(TARGET_COLUMN), - on_delete: :cascade - ) - - with_lock_retries do - remove_foreign_key_if_exists(:ssh_signatures, column: TARGET_COLUMN, name: fk_name("#{TARGET_COLUMN}_nullify")) - end - end - - private - - def fk_name(column_name) - concurrent_foreign_key_name(:ssh_signatures, column_name) - end -end diff --git a/db/post_migrate/20230109100044_cleanup_web_hook_calls_column_rename.rb b/db/post_migrate/20230109100044_cleanup_web_hook_calls_column_rename.rb deleted file mode 100644 index eca75bff199..00000000000 --- a/db/post_migrate/20230109100044_cleanup_web_hook_calls_column_rename.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupWebHookCallsColumnRename < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - # noop, related incident: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/8264 - end - - def down - undo_cleanup_concurrent_column_rename :plan_limits, :web_hook_calls, :web_hook_calls_high - end -end diff --git a/db/post_migrate/20230109144915_remove_push_rules_application_settings_push_rule_id_fk.rb b/db/post_migrate/20230109144915_remove_push_rules_application_settings_push_rule_id_fk.rb deleted file mode 100644 index 7ac492a6e62..00000000000 --- a/db/post_migrate/20230109144915_remove_push_rules_application_settings_push_rule_id_fk.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemovePushRulesApplicationSettingsPushRuleIdFk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - return unless foreign_key_exists?(:application_settings, :push_rules, name: "fk_693b8795e4") - - with_lock_retries do - execute('LOCK push_rules, application_settings IN ACCESS EXCLUSIVE MODE') if transaction_open? - - remove_foreign_key_if_exists(:application_settings, :push_rules, name: "fk_693b8795e4") - end - end - - def down - add_concurrent_foreign_key(:application_settings, :push_rules, - name: "fk_693b8795e4", column: :push_rule_id, - target_column: :id, on_delete: :nullify) - end -end diff --git a/db/post_migrate/20230109144928_remove_users_application_settings_usage_stats_set_by_user_id_fk.rb b/db/post_migrate/20230109144928_remove_users_application_settings_usage_stats_set_by_user_id_fk.rb deleted file mode 100644 index a8b9b48dbc7..00000000000 --- a/db/post_migrate/20230109144928_remove_users_application_settings_usage_stats_set_by_user_id_fk.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveUsersApplicationSettingsUsageStatsSetByUserIdFk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - return unless foreign_key_exists?(:application_settings, :users, name: "fk_964370041d") - - with_lock_retries do - execute('LOCK users, application_settings IN ACCESS EXCLUSIVE MODE') if transaction_open? - - remove_foreign_key_if_exists(:application_settings, :users, name: "fk_964370041d") - end - end - - def down - add_concurrent_foreign_key(:application_settings, :users, - name: "fk_964370041d", column: :usage_stats_set_by_user_id, - target_column: :id, on_delete: :nullify) - end -end diff --git a/db/post_migrate/20230109144941_remove_namespaces_application_settings_instance_administrators_group_id_fk.rb b/db/post_migrate/20230109144941_remove_namespaces_application_settings_instance_administrators_group_id_fk.rb deleted file mode 100644 index 82f0d8a2e47..00000000000 --- a/db/post_migrate/20230109144941_remove_namespaces_application_settings_instance_administrators_group_id_fk.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveNamespacesApplicationSettingsInstanceAdministratorsGroupIdFk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - return unless foreign_key_exists?(:application_settings, :namespaces, name: "fk_e8a145f3a7") - - with_lock_retries do - execute('LOCK namespaces, application_settings IN ACCESS EXCLUSIVE MODE') if transaction_open? - - remove_foreign_key_if_exists(:application_settings, :namespaces, name: "fk_e8a145f3a7") - end - end - - def down - add_concurrent_foreign_key(:application_settings, :namespaces, - name: "fk_e8a145f3a7", column: :instance_administrators_group_id, - target_column: :id, on_delete: :nullify) - end -end diff --git a/db/post_migrate/20230109144953_remove_projects_application_settings_file_template_project_id_fk.rb b/db/post_migrate/20230109144953_remove_projects_application_settings_file_template_project_id_fk.rb deleted file mode 100644 index 8527930e5a7..00000000000 --- a/db/post_migrate/20230109144953_remove_projects_application_settings_file_template_project_id_fk.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveProjectsApplicationSettingsFileTemplateProjectIdFk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - return unless foreign_key_exists?(:application_settings, :projects, name: "fk_ec757bd087") - - with_lock_retries do - execute('LOCK projects, application_settings IN ACCESS EXCLUSIVE MODE') if transaction_open? - - remove_foreign_key_if_exists(:application_settings, :projects, name: "fk_ec757bd087") - end - end - - def down - add_concurrent_foreign_key(:application_settings, :projects, - name: "fk_ec757bd087", column: :file_template_project_id, - target_column: :id, on_delete: :nullify) - end -end diff --git a/db/post_migrate/20230109145005_remove_projects_application_settings_instance_administration_project_id_fk.rb b/db/post_migrate/20230109145005_remove_projects_application_settings_instance_administration_project_id_fk.rb deleted file mode 100644 index e91769a90bb..00000000000 --- a/db/post_migrate/20230109145005_remove_projects_application_settings_instance_administration_project_id_fk.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveProjectsApplicationSettingsInstanceAdministrationProjectIdFk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - return unless foreign_key_exists?(:application_settings, :projects, name: "fk_rails_7e112a9599") - - with_lock_retries do - execute('LOCK projects, application_settings IN ACCESS EXCLUSIVE MODE') if transaction_open? - - remove_foreign_key_if_exists(:application_settings, :projects, name: "fk_rails_7e112a9599") - end - end - - def down - add_concurrent_foreign_key(:application_settings, :projects, - name: "fk_rails_7e112a9599", column: :instance_administration_project_id, - target_column: :id, on_delete: :nullify) - end -end diff --git a/db/post_migrate/20230109145018_remove_namespaces_application_settings_custom_project_templates_group_id_fk.rb b/db/post_migrate/20230109145018_remove_namespaces_application_settings_custom_project_templates_group_id_fk.rb deleted file mode 100644 index cfc915f57b4..00000000000 --- a/db/post_migrate/20230109145018_remove_namespaces_application_settings_custom_project_templates_group_id_fk.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class RemoveNamespacesApplicationSettingsCustomProjectTemplatesGroupIdFk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - return unless foreign_key_exists?(:application_settings, :namespaces, name: "fk_rails_b53e481273") - - with_lock_retries do - execute('LOCK namespaces, application_settings IN ACCESS EXCLUSIVE MODE') if transaction_open? - - remove_foreign_key_if_exists(:application_settings, :namespaces, name: "fk_rails_b53e481273") - end - end - - def down - add_concurrent_foreign_key(:application_settings, :namespaces, - name: "fk_rails_b53e481273", column: :custom_project_templates_group_id, - target_column: :id, on_delete: :nullify) - end -end diff --git a/db/post_migrate/20230110172751_add_partial_index_on_group_path_id.rb b/db/post_migrate/20230110172751_add_partial_index_on_group_path_id.rb deleted file mode 100644 index 2135f241fd1..00000000000 --- a/db/post_migrate/20230110172751_add_partial_index_on_group_path_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddPartialIndexOnGroupPathId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_groups_on_path_and_id - - # rubocop:disable Migration/PreventIndexCreation - def up - add_concurrent_index :namespaces, [:path, :id], 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/20230111125148_add_user_id_and_source_id_and_source_type_and_member_role_id_index_to_members.rb b/db/post_migrate/20230111125148_add_user_id_and_source_id_and_source_type_and_member_role_id_index_to_members.rb deleted file mode 100644 index 82e2ea8bf29..00000000000 --- a/db/post_migrate/20230111125148_add_user_id_and_source_id_and_source_type_and_member_role_id_index_to_members.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddUserIdAndSourceIdAndSourceTypeAndMemberRoleIdIndexToMembers < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'idx_members_on_user_and_source_and_source_type_and_member_role' - - def up - add_concurrent_index :members, [:user_id, :source_id, :source_type, :member_role_id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :members, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230111125150_drop_user_id_and_source_id_and_source_type_index_from_members.rb b/db/post_migrate/20230111125150_drop_user_id_and_source_id_and_source_type_index_from_members.rb deleted file mode 100644 index c1c56a4073c..00000000000 --- a/db/post_migrate/20230111125150_drop_user_id_and_source_id_and_source_type_index_from_members.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class DropUserIdAndSourceIdAndSourceTypeIndexFromMembers < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_members_on_user_id_source_id_source_type' - - def up - remove_concurrent_index_by_name :members, name: INDEX_NAME - end - - def down - add_concurrent_index :members, [:user_id, :source_id, :source_type], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230112051854_add_not_null_constraint_to_o_auth_access_tokens_expires_in.rb b/db/post_migrate/20230112051854_add_not_null_constraint_to_o_auth_access_tokens_expires_in.rb deleted file mode 100644 index 21028993f5d..00000000000 --- a/db/post_migrate/20230112051854_add_not_null_constraint_to_o_auth_access_tokens_expires_in.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddNotNullConstraintToOAuthAccessTokensExpiresIn < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - # validate: false ensures that existing records are not affected - # https://docs.gitlab.com/ee/development/database/not_null_constraints.html#prevent-new-invalid-records-current-release - add_not_null_constraint :oauth_access_tokens, :expires_in, validate: false - change_column_default :oauth_access_tokens, :expires_in, 7200 - end - - def down - remove_not_null_constraint :oauth_access_tokens, :expires_in - change_column_default :oauth_access_tokens, :expires_in, nil - end -end diff --git a/db/post_migrate/20230112085143_add_index_environments_on_project_id_and_id.rb b/db/post_migrate/20230112085143_add_index_environments_on_project_id_and_id.rb deleted file mode 100644 index bfb85557714..00000000000 --- a/db/post_migrate/20230112085143_add_index_environments_on_project_id_and_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexEnvironmentsOnProjectIdAndId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_environments_on_project_id_and_id' - - def up - add_concurrent_index :environments, %i[project_id id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :environments, INDEX_NAME - end -end diff --git a/db/post_migrate/20230112141236_schedule_vulnerabilities_feedback_migration2.rb b/db/post_migrate/20230112141236_schedule_vulnerabilities_feedback_migration2.rb deleted file mode 100644 index 7d8cba96a91..00000000000 --- a/db/post_migrate/20230112141236_schedule_vulnerabilities_feedback_migration2.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class ScheduleVulnerabilitiesFeedbackMigration2 < Gitlab::Database::Migration[2.1] - MIGRATION = 'MigrateVulnerabilitiesFeedbackToVulnerabilitiesStateTransition' - TABLE_NAME = :vulnerability_feedback - BATCH_COLUMN = :id - DELAY_INTERVAL = 5.minutes - BATCH_SIZE = 250 - MAX_BATCH_SIZE = 250 - SUB_BATCH_SIZE = 50 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # rescheduled by 20230203122602_schedule_vulnerabilities_feedback_migration3.rb - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb b/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb deleted file mode 100644 index d1e0ae6665f..00000000000 --- a/db/post_migrate/20230112144946_add_tmp_index_to_ci_build_need.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiBuildNeed < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_build_needs_on_partition_id_and_id - TABLE_NAME = :ci_build_needs - - def up - return unless Gitlab.com? - - prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) - end - - def down - return unless Gitlab.com? - - unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb b/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb deleted file mode 100644 index 920b70765cc..00000000000 --- a/db/post_migrate/20230112145326_add_tmp_index_to_ci_pipeline_variable.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiPipelineVariable < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_pipeline_variables_on_partition_id_and_id - TABLE_NAME = :ci_pipeline_variables - - def up - return unless Gitlab.com? - - prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) - end - - def down - return unless Gitlab.com? - - unprepare_async_index_by_name(TABLE_NAME, 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 deleted file mode 100644 index 7929d4495c0..00000000000 --- a/db/post_migrate/20230113003255_remove_atlassian_refresh_token_constraint.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveAtlassianRefreshTokenConstraint < Gitlab::Database::Migration[2.1] - CONSTRAINT_NAME = 'atlassian_identities_refresh_token_length_constraint' - - disable_ddl_transaction! - - def up - remove_check_constraint(:atlassian_identities, CONSTRAINT_NAME) - add_check_constraint :atlassian_identities, 'octet_length(encrypted_refresh_token) <= 5000', CONSTRAINT_NAME - end - - def down - remove_check_constraint(:atlassian_identities, CONSTRAINT_NAME) - add_check_constraint :atlassian_identities, 'octet_length(encrypted_refresh_token) <= 512', CONSTRAINT_NAME - end -end diff --git a/db/post_migrate/20230116083826_drop_index_on_ci_build_token_encrypted.rb b/db/post_migrate/20230116083826_drop_index_on_ci_build_token_encrypted.rb deleted file mode 100644 index 429388b1742..00000000000 --- a/db/post_migrate/20230116083826_drop_index_on_ci_build_token_encrypted.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class DropIndexOnCiBuildTokenEncrypted < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - TABLE_NAME = :ci_builds - INDEX_NAME = :index_ci_builds_on_token_encrypted_partition_id_unique - COLUMNS = %i[token_encrypted partition_id].freeze - - def up - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end - - def down - add_concurrent_index(TABLE_NAME, COLUMNS, unique: true, where: 'token_encrypted IS NOT NULL', name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20230116090630_add_index_for_group_activity_events.rb b/db/post_migrate/20230116090630_add_index_for_group_activity_events.rb deleted file mode 100644 index a775a471f98..00000000000 --- a/db/post_migrate/20230116090630_add_index_for_group_activity_events.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForGroupActivityEvents < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_events_for_group_activity' - - def up - add_concurrent_index :events, %i[group_id target_type action id], name: INDEX_NAME, where: 'group_id IS NOT NULL' - end - - def down - remove_concurrent_index_by_name :events, INDEX_NAME - end -end diff --git a/db/post_migrate/20230116090852_add_index_for_project_activity_events.rb b/db/post_migrate/20230116090852_add_index_for_project_activity_events.rb deleted file mode 100644 index f0d757ad885..00000000000 --- a/db/post_migrate/20230116090852_add_index_for_project_activity_events.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForProjectActivityEvents < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_events_for_project_activity' - - def up - add_concurrent_index :events, %i[project_id target_type action id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :events, INDEX_NAME - end -end diff --git a/db/post_migrate/20230116090920_add_index_to_events_on_group_id_and_id.rb b/db/post_migrate/20230116090920_add_index_to_events_on_group_id_and_id.rb deleted file mode 100644 index 4c2a9af7df9..00000000000 --- a/db/post_migrate/20230116090920_add_index_to_events_on_group_id_and_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToEventsOnGroupIdAndId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_events_on_group_id_and_id' - - def up - add_concurrent_index :events, %i[group_id id], name: INDEX_NAME, where: 'group_id IS NOT NULL' - end - - def down - remove_concurrent_index_by_name :events, INDEX_NAME - end -end diff --git a/db/post_migrate/20230116091626_add_index_for_events_followed_users.rb b/db/post_migrate/20230116091626_add_index_for_events_followed_users.rb deleted file mode 100644 index 24358814521..00000000000 --- a/db/post_migrate/20230116091626_add_index_for_events_followed_users.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddIndexForEventsFollowedUsers < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'index_events_for_followed_users' - - def up - add_concurrent_index :events, %I[author_id target_type action id], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :events, INDEX_NAME - end -end diff --git a/db/post_migrate/20230116111252_finalize_todo_sanitization.rb b/db/post_migrate/20230116111252_finalize_todo_sanitization.rb deleted file mode 100644 index b3da479aa57..00000000000 --- a/db/post_migrate/20230116111252_finalize_todo_sanitization.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class FinalizeTodoSanitization < Gitlab::Database::Migration[2.1] - MIGRATION = 'SanitizeConfidentialTodos' - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :notes, - column_name: :id, - job_arguments: [], - finalize: true - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230116160904_remove_user_details_fields_from_user.rb b/db/post_migrate/20230116160904_remove_user_details_fields_from_user.rb deleted file mode 100644 index 8842f75e691..00000000000 --- a/db/post_migrate/20230116160904_remove_user_details_fields_from_user.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class RemoveUserDetailsFieldsFromUser < Gitlab::Database::Migration[2.1] - enable_lock_retries! - - def change - %i[linkedin twitter skype website_url].each do |column| - remove_column :users, column, :string, null: false, default: '' - end - %i[location organization].each do |column| - remove_column :users, column, :string, null: true - end - end -end diff --git a/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb b/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb deleted file mode 100644 index a116562e9ec..00000000000 --- a/db/post_migrate/20230117092947_add_tmp_index_to_ci_build_report_results.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiBuildReportResults < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_build_report_results_on_partition_id_and_id - TABLE_NAME = :ci_build_report_results - - def up - return unless Gitlab.com? - - prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) - end - - def down - return unless Gitlab.com? - - unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230117093222_add_tmp_index_to_ci_builds_on_partition_id.rb b/db/post_migrate/20230117093222_add_tmp_index_to_ci_builds_on_partition_id.rb deleted file mode 100644 index 3a40e636ef9..00000000000 --- a/db/post_migrate/20230117093222_add_tmp_index_to_ci_builds_on_partition_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiBuildsOnPartitionId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_builds_on_partition_id_and_id - - def up - return unless Gitlab.com? - - prepare_async_index :ci_builds, [:partition_id, :id], name: INDEX_NAME, where: 'partition_id = 101' - end - - def down - return unless Gitlab.com? - - unprepare_async_index :ci_builds, [:partition_id, :id], name: INDEX_NAME, where: 'partition_id = 101' - end -end diff --git a/db/post_migrate/20230117093736_add_tmp_index_to_ci_pipelines_on_partition_id.rb b/db/post_migrate/20230117093736_add_tmp_index_to_ci_pipelines_on_partition_id.rb deleted file mode 100644 index a8e5da592af..00000000000 --- a/db/post_migrate/20230117093736_add_tmp_index_to_ci_pipelines_on_partition_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiPipelinesOnPartitionId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_pipelines_on_partition_id_and_id - - def up - return unless Gitlab.com? - - prepare_async_index :ci_pipelines, [:partition_id, :id], name: INDEX_NAME, where: 'partition_id = 101' - end - - def down - return unless Gitlab.com? - - unprepare_async_index :ci_pipelines, [:partition_id, :id], name: INDEX_NAME, where: 'partition_id = 101' - end -end diff --git a/db/post_migrate/20230117093924_add_tmp_index_to_ci_stages_on_partition_id.rb b/db/post_migrate/20230117093924_add_tmp_index_to_ci_stages_on_partition_id.rb deleted file mode 100644 index 33273ee2ba4..00000000000 --- a/db/post_migrate/20230117093924_add_tmp_index_to_ci_stages_on_partition_id.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiStagesOnPartitionId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_stages_on_partition_id_and_id - - def up - return unless Gitlab.com? - - prepare_async_index :ci_stages, [:partition_id, :id], name: INDEX_NAME, where: 'partition_id = 101' - end - - def down - return unless Gitlab.com? - - unprepare_async_index :ci_stages, [:partition_id, :id], name: INDEX_NAME, where: 'partition_id = 101' - end -end diff --git a/db/post_migrate/20230117094111_prepare_tmp_index_to_ci_build_trace_metadata.rb b/db/post_migrate/20230117094111_prepare_tmp_index_to_ci_build_trace_metadata.rb deleted file mode 100644 index 93356b4eb3f..00000000000 --- a/db/post_migrate/20230117094111_prepare_tmp_index_to_ci_build_trace_metadata.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class PrepareTmpIndexToCiBuildTraceMetadata < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_build_trace_metadata_on_partition_id_and_id - TABLE_NAME = :ci_build_trace_metadata - - def up - return unless Gitlab.com? - - prepare_async_index(TABLE_NAME, [:partition_id, :build_id], where: 'partition_id = 101', name: INDEX_NAME) - end - - def down - return unless Gitlab.com? - - unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230117094226_prepare_tmp_index_to_ci_job_artifact.rb b/db/post_migrate/20230117094226_prepare_tmp_index_to_ci_job_artifact.rb deleted file mode 100644 index db0c51e4cfd..00000000000 --- a/db/post_migrate/20230117094226_prepare_tmp_index_to_ci_job_artifact.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class PrepareTmpIndexToCiJobArtifact < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_job_artifacts_on_partition_id_and_id - TABLE_NAME = :ci_job_artifacts - - def up - return unless Gitlab.com? - - prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) - end - - def down - return unless Gitlab.com? - - unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230117094316_add_tmp_index_to_ci_job_variable.rb b/db/post_migrate/20230117094316_add_tmp_index_to_ci_job_variable.rb deleted file mode 100644 index 96de0c9fed1..00000000000 --- a/db/post_migrate/20230117094316_add_tmp_index_to_ci_job_variable.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiJobVariable < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_job_variables_on_partition_id_and_id - TABLE_NAME = :ci_job_variables - - def up - return unless Gitlab.com? - - add_concurrent_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) - end - - def down - return unless Gitlab.com? - - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230117113719_add_tmp_index_to_ci_sources_pipelines_on_partition_id.rb b/db/post_migrate/20230117113719_add_tmp_index_to_ci_sources_pipelines_on_partition_id.rb deleted file mode 100644 index 28c722893bc..00000000000 --- a/db/post_migrate/20230117113719_add_tmp_index_to_ci_sources_pipelines_on_partition_id.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class AddTmpIndexToCiSourcesPipelinesOnPartitionId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_sources_pipelines_on_partition_id_and_id - SOURCE_INDEX_NAME = :tmp_index_ci_sources_pipelines_on_source_partition_id_and_id - TABLE_NAME = :ci_sources_pipelines - - def up - return unless Gitlab.com? - - add_concurrent_index TABLE_NAME, - [:partition_id, :id], - name: INDEX_NAME, where: 'partition_id = 101' - - add_concurrent_index TABLE_NAME, - [:source_partition_id, :id], - name: SOURCE_INDEX_NAME, - where: 'source_partition_id = 101' - end - - def down - return unless Gitlab.com? - - remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME - remove_concurrent_index_by_name TABLE_NAME, SOURCE_INDEX_NAME - end -end diff --git a/db/post_migrate/20230117114739_clear_duplicate_jobs_cookies.rb b/db/post_migrate/20230117114739_clear_duplicate_jobs_cookies.rb deleted file mode 100644 index ce587e6c902..00000000000 --- a/db/post_migrate/20230117114739_clear_duplicate_jobs_cookies.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# This is workaround for -# https://gitlab.com/gitlab-org/gitlab/-/issues/388253. During a -# zero-downtime upgrade, duplicate jobs cookies can fail to get deleted. -# This post-deployment migration deletes all such cookies. This can -# cause some jobs that normally would have been deduplicated to twice -# instead of once. -class ClearDuplicateJobsCookies < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - Gitlab::Redis::Queues.with do |redis| # rubocop:disable Cop/RedisQueueUsage - redis.scan_each(match: "resque:gitlab:duplicate:*:cookie:v2").each_slice(100) do |keys| - redis.del(keys) - end - end - end - - def down; end -end diff --git a/db/post_migrate/20230117145628_add_token_encrypted_and_partition_id_index_to_ci_build.rb b/db/post_migrate/20230117145628_add_token_encrypted_and_partition_id_index_to_ci_build.rb deleted file mode 100644 index ffcf56dd2ca..00000000000 --- a/db/post_migrate/20230117145628_add_token_encrypted_and_partition_id_index_to_ci_build.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddTokenEncryptedAndPartitionIdIndexToCiBuild < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - TABLE_NAME = :ci_builds - INDEX_NAME = :unique_ci_builds_token_encrypted_and_partition_id - COLUMNS = %i[token_encrypted partition_id].freeze - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, unique: true, where: 'token_encrypted IS NOT NULL', name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230118083437_redefine_foreign_key_on_ci_unit_test_failure.rb b/db/post_migrate/20230118083437_redefine_foreign_key_on_ci_unit_test_failure.rb deleted file mode 100644 index 220da0908a9..00000000000 --- a/db/post_migrate/20230118083437_redefine_foreign_key_on_ci_unit_test_failure.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -class RedefineForeignKeyOnCiUnitTestFailure < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_unit_test_failures - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - OLD_FK_NAME = :fk_0f09856e1f_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: new_foreign_key_name, - on_update: :cascade - ) - - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: OLD_FK_NAME) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: OLD_FK_NAME - ) - - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: new_foreign_key_name) - end - end - - private - - def new_foreign_key_name - "#{concurrent_foreign_key_name(SOURCE_TABLE_NAME, [PARTITION_COLUMN, COLUMN])}_p" - end -end diff --git a/db/post_migrate/20230118083632_redefine_foreign_key_on_ci_build_pending_state.rb b/db/post_migrate/20230118083632_redefine_foreign_key_on_ci_build_pending_state.rb deleted file mode 100644 index 002ec923989..00000000000 --- a/db/post_migrate/20230118083632_redefine_foreign_key_on_ci_build_pending_state.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -class RedefineForeignKeyOnCiBuildPendingState < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_pending_states - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - OLD_FK_NAME = :fk_rails_0bbbfeaf9d_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: new_foreign_key_name, - on_update: :cascade - ) - - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: OLD_FK_NAME) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: OLD_FK_NAME - ) - - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: new_foreign_key_name) - end - end - - private - - def new_foreign_key_name - "#{concurrent_foreign_key_name(SOURCE_TABLE_NAME, [PARTITION_COLUMN, COLUMN])}_p" - end -end diff --git a/db/post_migrate/20230118083748_redefine_foreign_key_on_ci_build_trace_chunk.rb b/db/post_migrate/20230118083748_redefine_foreign_key_on_ci_build_trace_chunk.rb deleted file mode 100644 index 3474e672dfa..00000000000 --- a/db/post_migrate/20230118083748_redefine_foreign_key_on_ci_build_trace_chunk.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -class RedefineForeignKeyOnCiBuildTraceChunk < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_trace_chunks - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - OLD_FK_NAME = :fk_rails_1013b761f2_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: new_foreign_key_name, - on_update: :cascade - ) - - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: OLD_FK_NAME) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: OLD_FK_NAME - ) - - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: new_foreign_key_name) - end - end - - private - - def new_foreign_key_name - "#{concurrent_foreign_key_name(SOURCE_TABLE_NAME, [PARTITION_COLUMN, COLUMN])}_p" - end -end diff --git a/db/post_migrate/20230119085509_add_index_to_ci_running_build.rb b/db/post_migrate/20230119085509_add_index_to_ci_running_build.rb deleted file mode 100644 index f340b78801f..00000000000 --- a/db/post_migrate/20230119085509_add_index_to_ci_running_build.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToCiRunningBuild < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_running_builds_on_partition_id_build_id - TABLE_NAME = :ci_running_builds - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, 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/20230119085552_add_foreign_key_to_ci_running_build.rb b/db/post_migrate/20230119085552_add_foreign_key_to_ci_running_build.rb deleted file mode 100644 index 94dfdc5b967..00000000000 --- a/db/post_migrate/20230119085552_add_foreign_key_to_ci_running_build.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCiRunningBuild < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_running_builds - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_da45cfa165_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: FK_NAME, - on_update: :cascade - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end -end diff --git a/db/post_migrate/20230119090944_add_index_to_ci_pending_build.rb b/db/post_migrate/20230119090944_add_index_to_ci_pending_build.rb deleted file mode 100644 index de58b6a0ef8..00000000000 --- a/db/post_migrate/20230119090944_add_index_to_ci_pending_build.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToCiPendingBuild < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_pending_builds_on_partition_id_build_id - TABLE_NAME = :ci_pending_builds - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, 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/20230119091027_add_foreign_key_to_ci_pending_build.rb b/db/post_migrate/20230119091027_add_foreign_key_to_ci_pending_build.rb deleted file mode 100644 index 9f7f807e738..00000000000 --- a/db/post_migrate/20230119091027_add_foreign_key_to_ci_pending_build.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class AddForeignKeyToCiPendingBuild < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_pending_builds - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_725a2644a3_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: true, - reverse_lock_order: true, - name: FK_NAME, - on_update: :cascade - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end -end diff --git a/db/post_migrate/20230119095022_add_fk_index_to_ci_builds_runner_session_on_partition_id_and_build_id.rb b/db/post_migrate/20230119095022_add_fk_index_to_ci_builds_runner_session_on_partition_id_and_build_id.rb deleted file mode 100644 index 9fee62e55f2..00000000000 --- a/db/post_migrate/20230119095022_add_fk_index_to_ci_builds_runner_session_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiBuildsRunnerSessionOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_builds_runner_session_on_partition_id_build_id - TABLE_NAME = :ci_builds_runner_session - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME, unique: true) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230119095023_add_fk_to_ci_builds_runner_session_on_partition_id_and_build_id.rb b/db/post_migrate/20230119095023_add_fk_to_ci_builds_runner_session_on_partition_id_and_build_id.rb deleted file mode 100644 index e3aed238e0f..00000000000 --- a/db/post_migrate/20230119095023_add_fk_to_ci_builds_runner_session_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiBuildsRunnerSessionOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_builds_runner_session - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_70707857d3_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :cascade, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end -end diff --git a/db/post_migrate/20230119095024_validate_fk_on_ci_builds_runner_session_partition_id_and_build_id.rb b/db/post_migrate/20230119095024_validate_fk_on_ci_builds_runner_session_partition_id_and_build_id.rb deleted file mode 100644 index 07402b749ea..00000000000 --- a/db/post_migrate/20230119095024_validate_fk_on_ci_builds_runner_session_partition_id_and_build_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ValidateFkOnCiBuildsRunnerSessionPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_builds_runner_session - FK_NAME = :fk_rails_70707857d3_p - COLUMNS = [:partition_id, :build_id] - - def up - validate_foreign_key(TABLE_NAME, COLUMNS, name: FK_NAME) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230119095025_remove_fk_to_ci_builds_ci_builds_runner_session_on_build_id.rb b/db/post_migrate/20230119095025_remove_fk_to_ci_builds_ci_builds_runner_session_on_build_id.rb deleted file mode 100644 index 0707114d3a5..00000000000 --- a/db/post_migrate/20230119095025_remove_fk_to_ci_builds_ci_builds_runner_session_on_build_id.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class RemoveFkToCiBuildsCiBuildsRunnerSessionOnBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_builds_runner_session - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_70707857d3 - - def up - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: COLUMN, - target_column: TARGET_COLUMN, - validate: true, - reverse_lock_order: true, - on_delete: :cascade, - name: FK_NAME - ) - end -end diff --git a/db/post_migrate/20230119123256_add_fk_index_to_ci_resources_on_partition_id_and_build_id.rb b/db/post_migrate/20230119123256_add_fk_index_to_ci_resources_on_partition_id_and_build_id.rb deleted file mode 100644 index 8c1b8c81235..00000000000 --- a/db/post_migrate/20230119123256_add_fk_index_to_ci_resources_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiResourcesOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_resources_on_partition_id_build_id - TABLE_NAME = :ci_resources - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230119123257_add_fk_to_ci_resources_on_partition_id_and_build_id.rb b/db/post_migrate/20230119123257_add_fk_to_ci_resources_on_partition_id_and_build_id.rb deleted file mode 100644 index 8279def779e..00000000000 --- a/db/post_migrate/20230119123257_add_fk_to_ci_resources_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiResourcesOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_resources - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_e169a8e3d5_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :nullify, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end -end diff --git a/db/post_migrate/20230119123258_validate_fk_on_ci_resources_partition_id_and_build_id.rb b/db/post_migrate/20230119123258_validate_fk_on_ci_resources_partition_id_and_build_id.rb deleted file mode 100644 index 3df7f27d921..00000000000 --- a/db/post_migrate/20230119123258_validate_fk_on_ci_resources_partition_id_and_build_id.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class ValidateFkOnCiResourcesPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_resources - FK_NAME = :fk_e169a8e3d5_p - COLUMNS = [:partition_id, :build_id] - - def up - validate_foreign_key(TABLE_NAME, COLUMNS, name: FK_NAME) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230119123259_remove_fk_to_ci_builds_ci_resources_on_build_id.rb b/db/post_migrate/20230119123259_remove_fk_to_ci_builds_ci_resources_on_build_id.rb deleted file mode 100644 index fcf6989f30d..00000000000 --- a/db/post_migrate/20230119123259_remove_fk_to_ci_builds_ci_resources_on_build_id.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class RemoveFkToCiBuildsCiResourcesOnBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_resources - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_e169a8e3d5 - - def up - with_lock_retries do - remove_foreign_key_if_exists(SOURCE_TABLE_NAME, name: FK_NAME) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: COLUMN, - target_column: TARGET_COLUMN, - validate: true, - reverse_lock_order: true, - on_delete: :nullify, - name: FK_NAME - ) - end -end diff --git a/db/post_migrate/20230119123908_add_temporary_size_index_to_package_files.rb b/db/post_migrate/20230119123908_add_temporary_size_index_to_package_files.rb deleted file mode 100644 index dbd1f2ce112..00000000000 --- a/db/post_migrate/20230119123908_add_temporary_size_index_to_package_files.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class AddTemporarySizeIndexToPackageFiles < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'tmp_idx_package_files_on_non_zero_size' - - disable_ddl_transaction! - - def up - # Temporary index to be removed in 16.0 https://gitlab.com/gitlab-org/gitlab/-/issues/386695 - add_concurrent_index :packages_package_files, - %i[package_id size], - where: 'size IS NOT NULL', - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :packages_package_files, INDEX_NAME - end -end diff --git a/db/post_migrate/20230119123937_queue_fix_incoherent_packages_size_on_project_statistics.rb b/db/post_migrate/20230119123937_queue_fix_incoherent_packages_size_on_project_statistics.rb deleted file mode 100644 index b00888e28d5..00000000000 --- a/db/post_migrate/20230119123937_queue_fix_incoherent_packages_size_on_project_statistics.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class QueueFixIncoherentPackagesSizeOnProjectStatistics < Gitlab::Database::Migration[2.1] - MIGRATION = 'FixIncoherentPackagesSizeOnProjectStatistics' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 17000 - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - class Package < MigrationRecord - self.table_name = 'packages_packages' - end - - def up - return unless ::QueueFixIncoherentPackagesSizeOnProjectStatistics::Package.exists? - - queue_batched_background_migration( - MIGRATION, - :project_statistics, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :project_statistics, :id, []) - end -end diff --git a/db/post_migrate/20230123095023_add_scan_result_policy_id_to_software_license_policies.rb b/db/post_migrate/20230123095023_add_scan_result_policy_id_to_software_license_policies.rb deleted file mode 100644 index 7f61b3bfe85..00000000000 --- a/db/post_migrate/20230123095023_add_scan_result_policy_id_to_software_license_policies.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddScanResultPolicyIdToSoftwareLicensePolicies < Gitlab::Database::Migration[2.1] - INDEX_NAME = "index_software_license_policies_on_scan_result_policy_id" - - def change - # rubocop:disable Migration/AddReference - add_reference :software_license_policies, - :scan_result_policy, - foreign_key: { on_delete: :cascade }, - index: { name: INDEX_NAME }, - null: true - # rubocop:enable Migration/AddReference - end -end diff --git a/db/post_migrate/20230124101832_remove_fk_to_ci_builds_ci_unit_test_failure_on_build_id.rb b/db/post_migrate/20230124101832_remove_fk_to_ci_builds_ci_unit_test_failure_on_build_id.rb deleted file mode 100644 index 943c458d0fe..00000000000 --- a/db/post_migrate/20230124101832_remove_fk_to_ci_builds_ci_unit_test_failure_on_build_id.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class RemoveFkToCiBuildsCiUnitTestFailureOnBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_unit_test_failures - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_0f09856e1f - - def up - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: COLUMN, - target_column: TARGET_COLUMN, - validate: true, - reverse_lock_order: true, - on_delete: :cascade, - name: FK_NAME - ) - end -end diff --git a/db/post_migrate/20230124102131_remove_fk_to_ci_builds_ci_build_pending_state_on_build_id.rb b/db/post_migrate/20230124102131_remove_fk_to_ci_builds_ci_build_pending_state_on_build_id.rb deleted file mode 100644 index a969aec0968..00000000000 --- a/db/post_migrate/20230124102131_remove_fk_to_ci_builds_ci_build_pending_state_on_build_id.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class RemoveFkToCiBuildsCiBuildPendingStateOnBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_pending_states - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_0bbbfeaf9d - - def up - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: COLUMN, - target_column: TARGET_COLUMN, - validate: true, - reverse_lock_order: true, - on_delete: :cascade, - name: FK_NAME - ) - end -end diff --git a/db/post_migrate/20230124102222_remove_fk_to_ci_builds_ci_build_trace_chunk_on_build_id.rb b/db/post_migrate/20230124102222_remove_fk_to_ci_builds_ci_build_trace_chunk_on_build_id.rb deleted file mode 100644 index 3e03b0774ee..00000000000 --- a/db/post_migrate/20230124102222_remove_fk_to_ci_builds_ci_build_trace_chunk_on_build_id.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class RemoveFkToCiBuildsCiBuildTraceChunkOnBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_trace_chunks - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_1013b761f2 - - def up - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end - - def down - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: COLUMN, - target_column: TARGET_COLUMN, - validate: true, - reverse_lock_order: true, - on_delete: :cascade, - name: FK_NAME - ) - end -end 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 deleted file mode 100644 index d22fda092d3..00000000000 --- a/db/post_migrate/20230124104310_prepare_web_hook_logs_id_created_at_async_index.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class PrepareWebHookLogsIdCreatedAtAsyncIndex < Gitlab::Database::Migration[2.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_web_hook_logs_on_web_hook_id_and_created_at' - - def up - # Since web_hook_logs is a partitioned table, we need to prepare the index - # for each partition individually. We can't use the `prepare_async_index` - # method directly because it will try to prepare the index for the whole - # table, which will fail. - - # In a future migration after this one, we will create the index on the - # parent table itself. - each_partition(:web_hook_logs) do |partition, partition_index_name| - prepare_async_index(partition.identifier, [:web_hook_id, :created_at], - name: partition_index_name) - end - end - - def down - each_partition(:web_hook_logs) do |partition, partition_index_name| - unprepare_async_index_by_name(partition.identifier, partition_index_name) - end - end - - private - - def each_partition(table_name) - partitioned_table = find_partitioned_table(table_name) - partitioned_table.postgres_partitions.order(:name).each do |partition| - partition_index_name = generated_index_name(partition.identifier, INDEX_NAME) - - yield partition, partition_index_name - end - end -end diff --git a/db/post_migrate/20230125093723_rebalance_partition_id_ci_pipeline.rb b/db/post_migrate/20230125093723_rebalance_partition_id_ci_pipeline.rb deleted file mode 100644 index c7a7d966911..00000000000 --- a/db/post_migrate/20230125093723_rebalance_partition_id_ci_pipeline.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RebalancePartitionIdCiPipeline < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230125093840_rebalance_partition_id_ci_build.rb b/db/post_migrate/20230125093840_rebalance_partition_id_ci_build.rb deleted file mode 100644 index a4514e958f9..00000000000 --- a/db/post_migrate/20230125093840_rebalance_partition_id_ci_build.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class RebalancePartitionIdCiBuild < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230126091522_add_unique_index_to_ci_build_pending_state.rb b/db/post_migrate/20230126091522_add_unique_index_to_ci_build_pending_state.rb deleted file mode 100644 index 484b64feb97..00000000000 --- a/db/post_migrate/20230126091522_add_unique_index_to_ci_build_pending_state.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueIndexToCiBuildPendingState < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - OLD_INDEX_NAME = :index_ci_build_pending_states_on_partition_id_build_id - NEW_INDEX_NAME = :unique_index_ci_build_pending_states_on_partition_id_build_id - TABLE_NAME = :ci_build_pending_states - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, unique: true, name: NEW_INDEX_NAME) - - remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME) - end - - def down - add_concurrent_index(TABLE_NAME, COLUMNS, name: OLD_INDEX_NAME) - - remove_concurrent_index_by_name(TABLE_NAME, NEW_INDEX_NAME) - end -end diff --git a/db/post_migrate/20230126133531_remove_not_null_constraints_for_tables_with_schema_differences_v3.rb b/db/post_migrate/20230126133531_remove_not_null_constraints_for_tables_with_schema_differences_v3.rb deleted file mode 100644 index 04ed7a7ee12..00000000000 --- a/db/post_migrate/20230126133531_remove_not_null_constraints_for_tables_with_schema_differences_v3.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class RemoveNotNullConstraintsForTablesWithSchemaDifferencesV3 < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - return unless Gitlab.com? - - change_column_null :integrations, :updated_at, true - change_column_null :integrations, :created_at, true - - change_column_null :project_settings, :show_default_award_emojis, true - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230127101834_backfill_merge_request_metrics_for_bigint_conversion.rb b/db/post_migrate/20230127101834_backfill_merge_request_metrics_for_bigint_conversion.rb deleted file mode 100644 index 02ef1c230da..00000000000 --- a/db/post_migrate/20230127101834_backfill_merge_request_metrics_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillMergeRequestMetricsForBigintConversion < Gitlab::Database::Migration[2.1] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - TABLE = :merge_request_metrics - COLUMNS = %i[id] - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, sub_batch_size: 200) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230127115607_add_hosted_plan_id_and_trial_index_to_gitlab_subscriptions.rb b/db/post_migrate/20230127115607_add_hosted_plan_id_and_trial_index_to_gitlab_subscriptions.rb deleted file mode 100644 index 1b16ac5c187..00000000000 --- a/db/post_migrate/20230127115607_add_hosted_plan_id_and_trial_index_to_gitlab_subscriptions.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddHostedPlanIdAndTrialIndexToGitlabSubscriptions < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_gitlab_subscriptions_on_hosted_plan_id_and_trial' - - disable_ddl_transaction! - - def up - add_concurrent_index :gitlab_subscriptions, [:hosted_plan_id, :trial], name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :gitlab_subscriptions, INDEX_NAME - end -end diff --git a/db/post_migrate/20230127123947_add_fk_index_to_ci_sources_pipelines_on_source_partition_id_and_source_job_id.rb b/db/post_migrate/20230127123947_add_fk_index_to_ci_sources_pipelines_on_source_partition_id_and_source_job_id.rb deleted file mode 100644 index f2a9d362cc4..00000000000 --- a/db/post_migrate/20230127123947_add_fk_index_to_ci_sources_pipelines_on_source_partition_id_and_source_job_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiSourcesPipelinesOnSourcePartitionIdAndSourceJobId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_sources_pipelines_on_source_partition_id_source_job_id - TABLE_NAME = :ci_sources_pipelines - COLUMNS = [:source_partition_id, :source_job_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230127123948_add_fk_to_ci_sources_pipelines_on_source_partition_id_and_source_job_id.rb b/db/post_migrate/20230127123948_add_fk_to_ci_sources_pipelines_on_source_partition_id_and_source_job_id.rb deleted file mode 100644 index 7adf97268ff..00000000000 --- a/db/post_migrate/20230127123948_add_fk_to_ci_sources_pipelines_on_source_partition_id_and_source_job_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiSourcesPipelinesOnSourcePartitionIdAndSourceJobId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_sources_pipelines - TARGET_TABLE_NAME = :ci_builds - COLUMN = :source_job_id - TARGET_COLUMN = :id - FK_NAME = :fk_be5624bf37_p - PARTITION_COLUMN = :source_partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [:partition_id, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :cascade, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end -end diff --git a/db/post_migrate/20230127125018_remove_hosted_plan_id_index_from_gitlab_subscriptions.rb b/db/post_migrate/20230127125018_remove_hosted_plan_id_index_from_gitlab_subscriptions.rb deleted file mode 100644 index 6cc21920748..00000000000 --- a/db/post_migrate/20230127125018_remove_hosted_plan_id_index_from_gitlab_subscriptions.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class RemoveHostedPlanIdIndexFromGitlabSubscriptions < Gitlab::Database::Migration[2.1] - OLD_INDEX_NAME = 'index_gitlab_subscriptions_on_hosted_plan_id' - NEW_INDEX_NAME = 'index_gitlab_subscriptions_on_hosted_plan_id_and_trial' - TABLE = :gitlab_subscriptions - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name TABLE, OLD_INDEX_NAME if index_exists_by_name?(TABLE, NEW_INDEX_NAME) - end - - def down - add_concurrent_index TABLE, :hosted_plan_id, name: OLD_INDEX_NAME - end -end diff --git a/db/post_migrate/20230127131835_add_application_settings_git_users_alertlist_max_usernames_constraint.rb b/db/post_migrate/20230127131835_add_application_settings_git_users_alertlist_max_usernames_constraint.rb deleted file mode 100644 index 77ef7e7eba5..00000000000 --- a/db/post_migrate/20230127131835_add_application_settings_git_users_alertlist_max_usernames_constraint.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class AddApplicationSettingsGitUsersAlertlistMaxUsernamesConstraint < Gitlab::Database::Migration[2.1] - CONSTRAINT_NAME = 'app_settings_git_rate_limit_users_alertlist_max_usernames' - - disable_ddl_transaction! - - def up - add_check_constraint :application_settings, 'CARDINALITY(git_rate_limit_users_alertlist) <= 100', CONSTRAINT_NAME - end - - def down - remove_check_constraint :application_settings, CONSTRAINT_NAME - end -end diff --git a/db/post_migrate/20230127131915_add_namespace_settings_unique_project_download_limit_alertlist_size_constraint.rb b/db/post_migrate/20230127131915_add_namespace_settings_unique_project_download_limit_alertlist_size_constraint.rb deleted file mode 100644 index 0777d31aa3b..00000000000 --- a/db/post_migrate/20230127131915_add_namespace_settings_unique_project_download_limit_alertlist_size_constraint.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddNamespaceSettingsUniqueProjectDownloadLimitAlertlistSizeConstraint < Gitlab::Database::Migration[2.1] - CONSTRAINT_NAME = 'namespace_settings_unique_project_download_limit_alertlist_size' - - disable_ddl_transaction! - - def up - add_check_constraint :namespace_settings, - 'CARDINALITY(unique_project_download_limit_alertlist) <= 100', - CONSTRAINT_NAME - end - - def down - remove_check_constraint :namespace_settings, CONSTRAINT_NAME - end -end diff --git a/db/post_migrate/20230127151606_add_fk_index_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb b/db/post_migrate/20230127151606_add_fk_index_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb deleted file mode 100644 index a13ba0c21fb..00000000000 --- a/db/post_migrate/20230127151606_add_fk_index_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiBuildTraceMetadataOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_build_trace_metadata_on_partition_id_build_id - TABLE_NAME = :ci_build_trace_metadata - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME, unique: true) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230127151607_add_fk_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb b/db/post_migrate/20230127151607_add_fk_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb deleted file mode 100644 index 389cfc6a4ec..00000000000 --- a/db/post_migrate/20230127151607_add_fk_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiBuildTraceMetadataOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_trace_metadata - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_aebc78111f_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :cascade, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end -end diff --git a/db/post_migrate/20230127152727_add_fk_index_to_ci_job_artifacts_on_partition_id_and_job_id.rb b/db/post_migrate/20230127152727_add_fk_index_to_ci_job_artifacts_on_partition_id_and_job_id.rb deleted file mode 100644 index 66933fa600e..00000000000 --- a/db/post_migrate/20230127152727_add_fk_index_to_ci_job_artifacts_on_partition_id_and_job_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiJobArtifactsOnPartitionIdAndJobId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_job_artifacts_on_partition_id_job_id - TABLE_NAME = :ci_job_artifacts - COLUMNS = [:partition_id, :job_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230127152728_add_fk_to_ci_job_artifacts_on_partition_id_and_job_id.rb b/db/post_migrate/20230127152728_add_fk_to_ci_job_artifacts_on_partition_id_and_job_id.rb deleted file mode 100644 index 7c7cf7861ea..00000000000 --- a/db/post_migrate/20230127152728_add_fk_to_ci_job_artifacts_on_partition_id_and_job_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiJobArtifactsOnPartitionIdAndJobId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_job_artifacts - TARGET_TABLE_NAME = :ci_builds - COLUMN = :job_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_c5137cb2c1_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :cascade, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end -end diff --git a/db/post_migrate/20230127153229_add_fk_index_to_ci_job_variables_on_partition_id_and_job_id.rb b/db/post_migrate/20230127153229_add_fk_index_to_ci_job_variables_on_partition_id_and_job_id.rb deleted file mode 100644 index b06da3fc933..00000000000 --- a/db/post_migrate/20230127153229_add_fk_index_to_ci_job_variables_on_partition_id_and_job_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiJobVariablesOnPartitionIdAndJobId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_job_variables_on_partition_id_job_id - TABLE_NAME = :ci_job_variables - COLUMNS = [:partition_id, :job_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230127153230_add_fk_to_ci_job_variables_on_partition_id_and_job_id.rb b/db/post_migrate/20230127153230_add_fk_to_ci_job_variables_on_partition_id_and_job_id.rb deleted file mode 100644 index 7a6950fa96c..00000000000 --- a/db/post_migrate/20230127153230_add_fk_to_ci_job_variables_on_partition_id_and_job_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiJobVariablesOnPartitionIdAndJobId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_job_variables - TARGET_TABLE_NAME = :ci_builds - COLUMN = :job_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_fbf3b34792_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :cascade, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end -end diff --git a/db/post_migrate/20230130070623_add_index_on_packages_package_file_file_name.rb b/db/post_migrate/20230130070623_add_index_on_packages_package_file_file_name.rb deleted file mode 100644 index d7b495df272..00000000000 --- a/db/post_migrate/20230130070623_add_index_on_packages_package_file_file_name.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnPackagesPackageFileFileName < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_packages_package_files_on_file_name' - - def up - prepare_async_index :packages_package_files, :file_name, name: INDEX_NAME, using: :gin, - opclass: { description: :gin_trgm_ops } - end - - def down - unprepare_async_index :packages_package_files, :file_name, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230130073109_nullify_creator_id_of_orphaned_projects.rb b/db/post_migrate/20230130073109_nullify_creator_id_of_orphaned_projects.rb deleted file mode 100644 index c13c6552c8e..00000000000 --- a/db/post_migrate/20230130073109_nullify_creator_id_of_orphaned_projects.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -class NullifyCreatorIdOfOrphanedProjects < Gitlab::Database::Migration[2.1] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 500 - MAX_BATCH_SIZE = 5000 - MIGRATION = 'NullifyCreatorIdColumnOfOrphanedProjects' - INTERVAL = 2.minutes - - 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/20230130075434_schedule_tmp_index_to_ci_build_report_results.rb b/db/post_migrate/20230130075434_schedule_tmp_index_to_ci_build_report_results.rb deleted file mode 100644 index 778510e9fcb..00000000000 --- a/db/post_migrate/20230130075434_schedule_tmp_index_to_ci_build_report_results.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class ScheduleTmpIndexToCiBuildReportResults < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :tmp_index_ci_build_report_results_on_partition_id_and_build_id - TABLE_NAME = :ci_build_report_results - - def up - return unless Gitlab.com? - - prepare_async_index(TABLE_NAME, [:partition_id, :build_id], where: 'partition_id = 101', name: INDEX_NAME) - end - - def down - return unless Gitlab.com? - - unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230130084718_drop_invalid_async_index_from_postgres_async_index.rb b/db/post_migrate/20230130084718_drop_invalid_async_index_from_postgres_async_index.rb deleted file mode 100644 index ebe28eb4088..00000000000 --- a/db/post_migrate/20230130084718_drop_invalid_async_index_from_postgres_async_index.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class DropInvalidAsyncIndexFromPostgresAsyncIndex < Gitlab::Database::Migration[2.1] - # rollback 20230117092947_add_tmp_index_to_ci_build_report_results.rb - disable_ddl_transaction! - - INDEX_NAME = 'tmp_index_ci_build_report_results_on_partition_id_and_id' - TABLE_NAME = 'ci_build_report_results' - - def up - return unless Gitlab.com? - - unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) - end - - def down - return unless Gitlab.com? - - prepare_async_index(TABLE_NAME, [:partition_id, :id], where: 'partition_id = 101', name: INDEX_NAME) - end -end diff --git a/db/post_migrate/20230130102855_add_fk_index_to_ci_build_report_results_on_partition_id_and_build_id.rb b/db/post_migrate/20230130102855_add_fk_index_to_ci_build_report_results_on_partition_id_and_build_id.rb deleted file mode 100644 index 4fe71ba46d9..00000000000 --- a/db/post_migrate/20230130102855_add_fk_index_to_ci_build_report_results_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiBuildReportResultsOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_build_report_results_on_partition_id_build_id - TABLE_NAME = :ci_build_report_results - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, 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/20230130102856_add_fk_to_ci_build_report_results_on_partition_id_and_build_id.rb b/db/post_migrate/20230130102856_add_fk_to_ci_build_report_results_on_partition_id_and_build_id.rb deleted file mode 100644 index ef301af2c9f..00000000000 --- a/db/post_migrate/20230130102856_add_fk_to_ci_build_report_results_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiBuildReportResultsOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_report_results - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_16cb1ff064_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :cascade, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end -end diff --git a/db/post_migrate/20230130103957_add_fk_index_to_ci_build_needs_on_partition_id_and_build_id.rb b/db/post_migrate/20230130103957_add_fk_index_to_ci_build_needs_on_partition_id_and_build_id.rb deleted file mode 100644 index cea4070a8be..00000000000 --- a/db/post_migrate/20230130103957_add_fk_index_to_ci_build_needs_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddFkIndexToCiBuildNeedsOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_build_needs_on_partition_id_build_id - TABLE_NAME = :ci_build_needs - COLUMNS = [:partition_id, :build_id] - - def up - add_concurrent_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) - end - - def down - remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230130103958_add_fk_to_ci_build_needs_on_partition_id_and_build_id.rb b/db/post_migrate/20230130103958_add_fk_to_ci_build_needs_on_partition_id_and_build_id.rb deleted file mode 100644 index 46985f12ff9..00000000000 --- a/db/post_migrate/20230130103958_add_fk_to_ci_build_needs_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -class AddFkToCiBuildNeedsOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - SOURCE_TABLE_NAME = :ci_build_needs - TARGET_TABLE_NAME = :ci_builds - COLUMN = :build_id - TARGET_COLUMN = :id - FK_NAME = :fk_rails_3cf221d4ed_p - PARTITION_COLUMN = :partition_id - - def up - add_concurrent_foreign_key( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - column: [PARTITION_COLUMN, COLUMN], - target_column: [PARTITION_COLUMN, TARGET_COLUMN], - validate: false, - reverse_lock_order: true, - on_update: :cascade, - on_delete: :cascade, - name: FK_NAME - ) - end - - def down - with_lock_retries do - remove_foreign_key_if_exists( - SOURCE_TABLE_NAME, - TARGET_TABLE_NAME, - name: FK_NAME, - reverse_lock_order: true - ) - end - end -end diff --git a/db/post_migrate/20230130202201_backfill_sent_notifications_for_bigint_conversion.rb b/db/post_migrate/20230130202201_backfill_sent_notifications_for_bigint_conversion.rb deleted file mode 100644 index 2c8efed8dc2..00000000000 --- a/db/post_migrate/20230130202201_backfill_sent_notifications_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillSentNotificationsForBigintConversion < Gitlab::Database::Migration[2.1] - restrict_gitlab_migration gitlab_schema: :gitlab_main - - TABLE = :sent_notifications - COLUMNS = %i[id] - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230131005411_backfill_notes_id_for_bigint_conversion.rb b/db/post_migrate/20230131005411_backfill_notes_id_for_bigint_conversion.rb deleted file mode 100644 index b0ccc14e947..00000000000 --- a/db/post_migrate/20230131005411_backfill_notes_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillNotesIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :notes - COLUMNS = %i[id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, sub_batch_size: 500) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230131194959_remove_invalid_deploy_access_level.rb b/db/post_migrate/20230131194959_remove_invalid_deploy_access_level.rb deleted file mode 100644 index 13e49ca087d..00000000000 --- a/db/post_migrate/20230131194959_remove_invalid_deploy_access_level.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class RemoveInvalidDeployAccessLevel < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - # no-op, moved to 20230322151605_rerun_remove_invalid_deploy_access_level.rb - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230131210921_prepare_index_for_vulnerability_reads_on_project_id_scanner_id_vulnerability_id.rb b/db/post_migrate/20230131210921_prepare_index_for_vulnerability_reads_on_project_id_scanner_id_vulnerability_id.rb deleted file mode 100644 index 0ac4e805f8a..00000000000 --- a/db/post_migrate/20230131210921_prepare_index_for_vulnerability_reads_on_project_id_scanner_id_vulnerability_id.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class PrepareIndexForVulnerabilityReadsOnProjectIdScannerIdVulnerabilityId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = 'idx_vulnerability_reads_project_id_scanner_id_vulnerability_id' - - # Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/382625 - def up - prepare_async_index :vulnerability_reads, [:project_id, :scanner_id, :vulnerability_id], name: INDEX_NAME - end - - def down - unprepare_async_index :vulnerability_reads, [:project_id, :scanner_id, :vulnerability_id], name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230201012846_backfill_todos_note_id_for_bigint_conversion.rb b/db/post_migrate/20230201012846_backfill_todos_note_id_for_bigint_conversion.rb deleted file mode 100644 index a105bea13ab..00000000000 --- a/db/post_migrate/20230201012846_backfill_todos_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillTodosNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :todos - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, sub_batch_size: 500) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230201014238_backfill_system_note_metadata_note_id_for_bigint_conversion.rb b/db/post_migrate/20230201014238_backfill_system_note_metadata_note_id_for_bigint_conversion.rb deleted file mode 100644 index df24b755b7f..00000000000 --- a/db/post_migrate/20230201014238_backfill_system_note_metadata_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillSystemNoteMetadataNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :system_note_metadata - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230201082038_drop_web_hook_calls_high_column.rb b/db/post_migrate/20230201082038_drop_web_hook_calls_high_column.rb deleted file mode 100644 index 76c93be0f42..00000000000 --- a/db/post_migrate/20230201082038_drop_web_hook_calls_high_column.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class DropWebHookCallsHighColumn < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - with_lock_retries do - if column_exists?(:plan_limits, :web_hook_calls_high) # rubocop:disable Style/IfUnlessModifier - remove_column :plan_limits, :web_hook_calls_high - end - end - end - - def down - with_lock_retries do - unless column_exists?(:plan_limits, :web_hook_calls_high) - add_column :plan_limits, :web_hook_calls_high, :integer, default: 0 - end - end - end -end diff --git a/db/post_migrate/20230201152525_schedule_fk_index_to_ci_build_needs_on_partition_id_and_build_id.rb b/db/post_migrate/20230201152525_schedule_fk_index_to_ci_build_needs_on_partition_id_and_build_id.rb deleted file mode 100644 index 674d92295c3..00000000000 --- a/db/post_migrate/20230201152525_schedule_fk_index_to_ci_build_needs_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ScheduleFkIndexToCiBuildNeedsOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_build_needs_on_partition_id_build_id - TABLE_NAME = :ci_build_needs - COLUMNS = [:partition_id, :build_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/20230201153450_add_index_on_lfs_objects_file.rb b/db/post_migrate/20230201153450_add_index_on_lfs_objects_file.rb deleted file mode 100644 index 669b3faf3d6..00000000000 --- a/db/post_migrate/20230201153450_add_index_on_lfs_objects_file.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnLfsObjectsFile < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_lfs_objects_on_file' - - # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/390401 - def up - prepare_async_index :lfs_objects, :file, name: INDEX_NAME - end - - def down - unprepare_async_index :lfs_objects, :file, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230201171450_finalize_backfill_environment_tier_migration.rb b/db/post_migrate/20230201171450_finalize_backfill_environment_tier_migration.rb deleted file mode 100644 index ae4062cb764..00000000000 --- a/db/post_migrate/20230201171450_finalize_backfill_environment_tier_migration.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -class FinalizeBackfillEnvironmentTierMigration < Gitlab::Database::Migration[2.1] - MIGRATION = 'BackfillEnvironmentTiers' - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - ensure_batched_background_migration_is_finished( - job_class_name: MIGRATION, - table_name: :environments, - column_name: :id, - job_arguments: [], - finalize: true - ) - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230202002637_backfill_epic_user_mentions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230202002637_backfill_epic_user_mentions_note_id_for_bigint_conversion.rb deleted file mode 100644 index 1f7af1af78f..00000000000 --- a/db/post_migrate/20230202002637_backfill_epic_user_mentions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillEpicUserMentionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :epic_user_mentions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230202004247_add_index_on_merge_request_diffs_external_diff.rb b/db/post_migrate/20230202004247_add_index_on_merge_request_diffs_external_diff.rb deleted file mode 100644 index 6f8cfced238..00000000000 --- a/db/post_migrate/20230202004247_add_index_on_merge_request_diffs_external_diff.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class AddIndexOnMergeRequestDiffsExternalDiff < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_merge_request_diffs_on_external_diff' - - # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/390399 - def up - prepare_async_index :merge_request_diffs, :external_diff, name: INDEX_NAME - end - - def down - unprepare_async_index :merge_request_diffs, :external_diff, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230202023224_backfill_suggestions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230202023224_backfill_suggestions_note_id_for_bigint_conversion.rb deleted file mode 100644 index c4bd2ccf0c7..00000000000 --- a/db/post_migrate/20230202023224_backfill_suggestions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillSuggestionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :suggestions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230202032302_backfill_issue_user_mentions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230202032302_backfill_issue_user_mentions_note_id_for_bigint_conversion.rb deleted file mode 100644 index 749a2f97d7c..00000000000 --- a/db/post_migrate/20230202032302_backfill_issue_user_mentions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillIssueUserMentionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :issue_user_mentions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, batch_size: 40_000, sub_batch_size: 500) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230202131928_encrypt_ci_trigger_token.rb b/db/post_migrate/20230202131928_encrypt_ci_trigger_token.rb deleted file mode 100644 index c1cb40d1da1..00000000000 --- a/db/post_migrate/20230202131928_encrypt_ci_trigger_token.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class EncryptCiTriggerToken < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_ci - - MIGRATION = 'EncryptCiTriggerToken' - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 1_000 - MAX_BATCH_SIZE = 2_000 - SUB_BATCH_SIZE = 100 - - def up - queue_batched_background_migration( - MIGRATION, - :ci_triggers, - :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_triggers, :id, []) - end -end diff --git a/db/post_migrate/20230203122602_schedule_vulnerabilities_feedback_migration3.rb b/db/post_migrate/20230203122602_schedule_vulnerabilities_feedback_migration3.rb deleted file mode 100644 index 7fed726823b..00000000000 --- a/db/post_migrate/20230203122602_schedule_vulnerabilities_feedback_migration3.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class ScheduleVulnerabilitiesFeedbackMigration3 < Gitlab::Database::Migration[2.1] - MIGRATION = 'MigrateVulnerabilitiesFeedbackToVulnerabilitiesStateTransition' - TABLE_NAME = :vulnerability_feedback - BATCH_COLUMN = :id - DELAY_INTERVAL = 5.minutes - BATCH_SIZE = 250 - MAX_BATCH_SIZE = 250 - SUB_BATCH_SIZE = 50 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # replaced by db/post_migrate/20230209171547_schedule_vulnerabilities_feedback_migration4.rb - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230203122609_change_pipeline_name_index.rb b/db/post_migrate/20230203122609_change_pipeline_name_index.rb deleted file mode 100644 index 2f2fef82c9d..00000000000 --- a/db/post_migrate/20230203122609_change_pipeline_name_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class ChangePipelineNameIndex < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - OLD_INDEX_NAME = 'index_pipeline_metadata_on_pipeline_id_name_lower_text_pattern' - NEW_INDEX_NAME = 'index_pipeline_metadata_on_pipeline_id_name_text_pattern' - - def up - add_concurrent_index :ci_pipeline_metadata, 'pipeline_id, name text_pattern_ops', name: NEW_INDEX_NAME - - remove_concurrent_index_by_name :ci_pipeline_metadata, OLD_INDEX_NAME - end - - def down - add_concurrent_index :ci_pipeline_metadata, 'pipeline_id, lower(name) text_pattern_ops', name: OLD_INDEX_NAME - - remove_concurrent_index_by_name :ci_pipeline_metadata, NEW_INDEX_NAME - end -end diff --git a/db/post_migrate/20230207003812_backfill_note_diff_files_diff_note_id_for_bigint_conversion.rb b/db/post_migrate/20230207003812_backfill_note_diff_files_diff_note_id_for_bigint_conversion.rb deleted file mode 100644 index ce53a855b2a..00000000000 --- a/db/post_migrate/20230207003812_backfill_note_diff_files_diff_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillNoteDiffFilesDiffNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :note_diff_files - COLUMNS = %i[diff_note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, batch_size: 40_000) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230207005701_backfill_snippet_user_mentions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230207005701_backfill_snippet_user_mentions_note_id_for_bigint_conversion.rb deleted file mode 100644 index 4d4c36bf8fc..00000000000 --- a/db/post_migrate/20230207005701_backfill_snippet_user_mentions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillSnippetUserMentionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :snippet_user_mentions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230207011414_backfill_design_user_mentions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230207011414_backfill_design_user_mentions_note_id_for_bigint_conversion.rb deleted file mode 100644 index 6e971bad382..00000000000 --- a/db/post_migrate/20230207011414_backfill_design_user_mentions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillDesignUserMentionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :design_user_mentions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230207012238_backfill_vulnerability_user_mentions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230207012238_backfill_vulnerability_user_mentions_note_id_for_bigint_conversion.rb deleted file mode 100644 index e6d674c09ce..00000000000 --- a/db/post_migrate/20230207012238_backfill_vulnerability_user_mentions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillVulnerabilityUserMentionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :vulnerability_user_mentions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230207015850_backfill_commit_user_mentions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230207015850_backfill_commit_user_mentions_note_id_for_bigint_conversion.rb deleted file mode 100644 index d690c00dc7c..00000000000 --- a/db/post_migrate/20230207015850_backfill_commit_user_mentions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillCommitUserMentionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :commit_user_mentions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230207025315_backfill_merge_request_user_mentions_note_id_for_bigint_conversion.rb b/db/post_migrate/20230207025315_backfill_merge_request_user_mentions_note_id_for_bigint_conversion.rb deleted file mode 100644 index 127c1c17bce..00000000000 --- a/db/post_migrate/20230207025315_backfill_merge_request_user_mentions_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillMergeRequestUserMentionsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :merge_request_user_mentions - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, batch_size: 30_000, sub_batch_size: 500) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230207030259_backfill_timelogs_note_id_for_bigint_conversion.rb b/db/post_migrate/20230207030259_backfill_timelogs_note_id_for_bigint_conversion.rb deleted file mode 100644 index e88b810d813..00000000000 --- a/db/post_migrate/20230207030259_backfill_timelogs_note_id_for_bigint_conversion.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class BackfillTimelogsNoteIdForBigintConversion < Gitlab::Database::Migration[2.1] - TABLE = :timelogs - COLUMNS = %i[note_id] - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end - - def down - revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS) - end -end diff --git a/db/post_migrate/20230207143602_schedule_fk_index_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb b/db/post_migrate/20230207143602_schedule_fk_index_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb deleted file mode 100644 index ae51e312fc4..00000000000 --- a/db/post_migrate/20230207143602_schedule_fk_index_to_ci_build_trace_metadata_on_partition_id_and_build_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ScheduleFkIndexToCiBuildTraceMetadataOnPartitionIdAndBuildId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_build_trace_metadata_on_partition_id_build_id - TABLE_NAME = :ci_build_trace_metadata - COLUMNS = [:partition_id, :build_id] - - def up - prepare_async_index(TABLE_NAME, COLUMNS, name: INDEX_NAME, unique: true) - end - - def down - unprepare_async_index_by_name(TABLE_NAME, INDEX_NAME) - end -end diff --git a/db/post_migrate/20230207143844_schedule_fk_index_to_ci_job_artifacts_on_partition_id_and_job_id.rb b/db/post_migrate/20230207143844_schedule_fk_index_to_ci_job_artifacts_on_partition_id_and_job_id.rb deleted file mode 100644 index c9eda410b34..00000000000 --- a/db/post_migrate/20230207143844_schedule_fk_index_to_ci_job_artifacts_on_partition_id_and_job_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class ScheduleFkIndexToCiJobArtifactsOnPartitionIdAndJobId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - INDEX_NAME = :index_ci_job_artifacts_on_partition_id_job_id - TABLE_NAME = :ci_job_artifacts - COLUMNS = [:partition_id, :job_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/20230208100917_fix_partition_ids_for_ci_pipeline_variable.rb b/db/post_migrate/20230208100917_fix_partition_ids_for_ci_pipeline_variable.rb deleted file mode 100644 index 8bf1239146c..00000000000 --- a/db/post_migrate/20230208100917_fix_partition_ids_for_ci_pipeline_variable.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsForCiPipelineVariable < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230208103009_fix_partition_ids_for_ci_job_artifact.rb b/db/post_migrate/20230208103009_fix_partition_ids_for_ci_job_artifact.rb deleted file mode 100644 index 7c6ff6c3b4f..00000000000 --- a/db/post_migrate/20230208103009_fix_partition_ids_for_ci_job_artifact.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsForCiJobArtifact < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230208110638_cleanup_ci_runner_machines_machine_xid_rename.rb b/db/post_migrate/20230208110638_cleanup_ci_runner_machines_machine_xid_rename.rb deleted file mode 100644 index b596d7773ae..00000000000 --- a/db/post_migrate/20230208110638_cleanup_ci_runner_machines_machine_xid_rename.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class CleanupCiRunnerMachinesMachineXidRename < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - cleanup_concurrent_column_rename :ci_runner_machines, :machine_xid, :system_xid - end - - def down - undo_cleanup_concurrent_column_rename :ci_runner_machines, :machine_xid, :system_xid - end -end diff --git a/db/post_migrate/20230208131808_nullify_last_error_from_project_mirror_data.rb b/db/post_migrate/20230208131808_nullify_last_error_from_project_mirror_data.rb deleted file mode 100644 index 73e6f257498..00000000000 --- a/db/post_migrate/20230208131808_nullify_last_error_from_project_mirror_data.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class NullifyLastErrorFromProjectMirrorData < Gitlab::Database::Migration[2.1] - MIGRATION = 'NullifyLastErrorFromProjectMirrorData' - INTERVAL = 2.minutes - BATCH_SIZE = 10_000 - SUB_BATCH_SIZE = 1_000 - - disable_ddl_transaction! - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - queue_batched_background_migration( - MIGRATION, - :project_mirror_data, - :id, - job_interval: INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :project_mirror_data, :id, []) - end -end diff --git a/db/post_migrate/20230208132608_fix_partition_ids_for_ci_stage.rb b/db/post_migrate/20230208132608_fix_partition_ids_for_ci_stage.rb deleted file mode 100644 index f05a53dda5f..00000000000 --- a/db/post_migrate/20230208132608_fix_partition_ids_for_ci_stage.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsForCiStage < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230209090702_fix_partition_ids_for_ci_build_report_result.rb b/db/post_migrate/20230209090702_fix_partition_ids_for_ci_build_report_result.rb deleted file mode 100644 index 4ff3d1a2789..00000000000 --- a/db/post_migrate/20230209090702_fix_partition_ids_for_ci_build_report_result.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsForCiBuildReportResult < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230209092204_fix_partition_ids_for_ci_build_trace_metadata.rb b/db/post_migrate/20230209092204_fix_partition_ids_for_ci_build_trace_metadata.rb deleted file mode 100644 index f682527a296..00000000000 --- a/db/post_migrate/20230209092204_fix_partition_ids_for_ci_build_trace_metadata.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsForCiBuildTraceMetadata < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230209103650_add_unique_software_license_policies_index_on_project_and_scan_result_policy.rb b/db/post_migrate/20230209103650_add_unique_software_license_policies_index_on_project_and_scan_result_policy.rb deleted file mode 100644 index b3e6c42370a..00000000000 --- a/db/post_migrate/20230209103650_add_unique_software_license_policies_index_on_project_and_scan_result_policy.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class AddUniqueSoftwareLicensePoliciesIndexOnProjectAndScanResultPolicy < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'idx_software_license_policies_unique_on_project_and_scan_policy' - - disable_ddl_transaction! - - def up - add_concurrent_index :software_license_policies, - [:project_id, :software_license_id, :scan_result_policy_id], - unique: true, - name: INDEX_NAME - end - - def down - remove_concurrent_index_by_name :software_license_policies, INDEX_NAME - end -end diff --git a/db/post_migrate/20230209103714_add_fk_to_approval_rules_on_scan_result_policy_id.rb b/db/post_migrate/20230209103714_add_fk_to_approval_rules_on_scan_result_policy_id.rb deleted file mode 100644 index cfc2c33b32a..00000000000 --- a/db/post_migrate/20230209103714_add_fk_to_approval_rules_on_scan_result_policy_id.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -class AddFkToApprovalRulesOnScanResultPolicyId < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - - def up - add_concurrent_foreign_key :approval_project_rules, - :scan_result_policies, - column: :scan_result_policy_id, - on_delete: :cascade, - reverse_lock_order: true - add_concurrent_foreign_key :approval_merge_request_rules, - :scan_result_policies, - column: :scan_result_policy_id, - on_delete: :cascade, - reverse_lock_order: true - end - - def down - remove_foreign_key_if_exists :approval_project_rules, column: :scan_result_policy_id - remove_foreign_key_if_exists :approval_merge_request_rules, column: :scan_result_policy_id - end -end diff --git a/db/post_migrate/20230209123006_remove_unique_software_license_policies_index_on_project.rb b/db/post_migrate/20230209123006_remove_unique_software_license_policies_index_on_project.rb deleted file mode 100644 index 5c69fc6d9fe..00000000000 --- a/db/post_migrate/20230209123006_remove_unique_software_license_policies_index_on_project.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class RemoveUniqueSoftwareLicensePoliciesIndexOnProject < Gitlab::Database::Migration[2.1] - INDEX_NAME = 'index_software_license_policies_unique_per_project' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name :software_license_policies, INDEX_NAME - end - - def down - add_concurrent_index :software_license_policies, [:project_id, :software_license_id], unique: true, name: INDEX_NAME - end -end diff --git a/db/post_migrate/20230209131808_recount_epic_cache_counts_v3.rb b/db/post_migrate/20230209131808_recount_epic_cache_counts_v3.rb deleted file mode 100644 index 6252a300453..00000000000 --- a/db/post_migrate/20230209131808_recount_epic_cache_counts_v3.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -class RecountEpicCacheCountsV3 < Gitlab::Database::Migration[2.1] - MIGRATION = 'ThirdRecountEpicCacheCounts' - 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/20230209140102_fix_partition_ids_for_ci_build_metadata.rb b/db/post_migrate/20230209140102_fix_partition_ids_for_ci_build_metadata.rb deleted file mode 100644 index 785db1be079..00000000000 --- a/db/post_migrate/20230209140102_fix_partition_ids_for_ci_build_metadata.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsForCiBuildMetadata < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230209171547_schedule_vulnerabilities_feedback_migration4.rb b/db/post_migrate/20230209171547_schedule_vulnerabilities_feedback_migration4.rb deleted file mode 100644 index fb2f8fd65cc..00000000000 --- a/db/post_migrate/20230209171547_schedule_vulnerabilities_feedback_migration4.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -class ScheduleVulnerabilitiesFeedbackMigration4 < Gitlab::Database::Migration[2.1] - MIGRATION = 'MigrateVulnerabilitiesFeedbackToVulnerabilitiesStateTransition' - TABLE_NAME = :vulnerability_feedback - BATCH_COLUMN = :id - JOB_INTERVAL = 2.minutes - BATCH_SIZE = 250 - SUB_BATCH_SIZE = 5 - - disable_ddl_transaction! - - restrict_gitlab_migration gitlab_schema: :gitlab_main - - def up - # Delete the previous jobs - delete_batched_background_migration( - MIGRATION, - TABLE_NAME, - BATCH_COLUMN, - [] - ) - - # Reschedule the migration - queue_batched_background_migration( - MIGRATION, - TABLE_NAME, - BATCH_COLUMN, - job_interval: JOB_INTERVAL, - 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/20230210113924_prepare_index_approval_rules_on_scan_result_policy_id.rb b/db/post_migrate/20230210113924_prepare_index_approval_rules_on_scan_result_policy_id.rb deleted file mode 100644 index 5776d6f737e..00000000000 --- a/db/post_migrate/20230210113924_prepare_index_approval_rules_on_scan_result_policy_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class PrepareIndexApprovalRulesOnScanResultPolicyId < Gitlab::Database::Migration[2.1] - PROJECT_INDEX_NAME = 'idx_approval_project_rules_on_scan_result_policy_id' - MERGE_REQUEST_INDEX_NAME = 'idx_approval_merge_request_rules_on_scan_result_policy_id' - - # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/391312 - def up - prepare_async_index :approval_project_rules, :scan_result_policy_id, name: PROJECT_INDEX_NAME - prepare_async_index :approval_merge_request_rules, :scan_result_policy_id, name: MERGE_REQUEST_INDEX_NAME - end - - def down - unprepare_async_index :approval_project_rules, :scan_result_policy_id, name: PROJECT_INDEX_NAME - unprepare_async_index :approval_merge_request_rules, :scan_result_policy_id, name: MERGE_REQUEST_INDEX_NAME - end -end diff --git a/db/post_migrate/20230214122717_fix_partition_ids_for_ci_job_variables.rb b/db/post_migrate/20230214122717_fix_partition_ids_for_ci_job_variables.rb deleted file mode 100644 index 64f5bc4bb5e..00000000000 --- a/db/post_migrate/20230214122717_fix_partition_ids_for_ci_job_variables.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsForCiJobVariables < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230214154101_fix_partition_ids_on_ci_sources_pipelines.rb b/db/post_migrate/20230214154101_fix_partition_ids_on_ci_sources_pipelines.rb deleted file mode 100644 index bbacd13389b..00000000000 --- a/db/post_migrate/20230214154101_fix_partition_ids_on_ci_sources_pipelines.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class FixPartitionIdsOnCiSourcesPipelines < Gitlab::Database::Migration[2.1] - def up - # no-op - end - - def down - # no-op - end -end diff --git a/db/post_migrate/20230214174335_prepare_async_index_web_hook_logs.rb b/db/post_migrate/20230214174335_prepare_async_index_web_hook_logs.rb deleted file mode 100644 index 536f0750b91..00000000000 --- a/db/post_migrate/20230214174335_prepare_async_index_web_hook_logs.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -class PrepareAsyncIndexWebHookLogs < Gitlab::Database::Migration[2.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - - INDEX_NAME = 'index_web_hook_logs_on_web_hook_id_and_created_at' - - def up - # Since web_hook_logs is a partitioned table, we need to prepare the index - # for each partition individually. We can't use the `prepare_async_index` - # method directly because it will try to prepare the index for the whole - # table, which will fail. - - # In a future migration, we will create the index on the parent table itself. - each_partition(:web_hook_logs) do |partition, partition_index_name| - prepare_async_index(partition.identifier, [:web_hook_id, :created_at], - name: partition_index_name) - end - end - - def down - each_partition(:web_hook_logs) do |partition, partition_index_name| - unprepare_async_index_by_name(partition.identifier, partition_index_name) - end - end - - private - - def each_partition(table_name) - partitioned_table = find_partitioned_table(table_name) - partitioned_table.postgres_partitions.order(:name).each do |partition| - partition_index_name = generated_index_name(partition.identifier, INDEX_NAME) - - yield partition, partition_index_name - end - end -end diff --git a/db/post_migrate/20230216035802_prepare_async_foreign_key_validation_for_ci_build_needs.rb b/db/post_migrate/20230216035802_prepare_async_foreign_key_validation_for_ci_build_needs.rb deleted file mode 100644 index 1c3215a6691..00000000000 --- a/db/post_migrate/20230216035802_prepare_async_foreign_key_validation_for_ci_build_needs.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class PrepareAsyncForeignKeyValidationForCiBuildNeeds < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_build_needs - COLUMN_NAMES = [:partition_id, :build_id] - FOREIGN_KEY_NAME = :fk_rails_3cf221d4ed_p - - def up - prepare_async_foreign_key_validation(TABLE_NAME, COLUMN_NAMES, name: FOREIGN_KEY_NAME) - end - - def down - unprepare_async_foreign_key_validation(TABLE_NAME, COLUMN_NAMES, name: FOREIGN_KEY_NAME) - end -end diff --git a/db/post_migrate/20230216052103_prepare_async_foreign_key_validation_for_ci_build_report_results.rb b/db/post_migrate/20230216052103_prepare_async_foreign_key_validation_for_ci_build_report_results.rb deleted file mode 100644 index e9add3fd2ae..00000000000 --- a/db/post_migrate/20230216052103_prepare_async_foreign_key_validation_for_ci_build_report_results.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class PrepareAsyncForeignKeyValidationForCiBuildReportResults < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_build_report_results - COLUMN_NAMES = [:partition_id, :build_id] - FOREIGN_KEY_NAME = :fk_rails_16cb1ff064_p - - def up - prepare_async_foreign_key_validation(TABLE_NAME, COLUMN_NAMES, name: FOREIGN_KEY_NAME) - end - - def down - unprepare_async_foreign_key_validation(TABLE_NAME, COLUMN_NAMES, name: FOREIGN_KEY_NAME) - end -end diff --git a/db/post_migrate/20230216054348_prepare_async_foreign_key_validation_for_ci_job_artifacts.rb b/db/post_migrate/20230216054348_prepare_async_foreign_key_validation_for_ci_job_artifacts.rb deleted file mode 100644 index 6d545361e10..00000000000 --- a/db/post_migrate/20230216054348_prepare_async_foreign_key_validation_for_ci_job_artifacts.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class PrepareAsyncForeignKeyValidationForCiJobArtifacts < Gitlab::Database::Migration[2.1] - TABLE_NAME = :ci_job_artifacts - COLUMN_NAMES = [:partition_id, :job_id] - FOREIGN_KEY_NAME = :fk_rails_c5137cb2c1_p - - def up - prepare_async_foreign_key_validation(TABLE_NAME, COLUMN_NAMES, name: FOREIGN_KEY_NAME) - end - - def down - unprepare_async_foreign_key_validation(TABLE_NAME, COLUMN_NAMES, name: FOREIGN_KEY_NAME) - end -end diff --git a/db/post_migrate/20240117173808_drop_index_on_projects_lower_path.rb b/db/post_migrate/20240117173808_drop_index_on_projects_lower_path.rb new file mode 100644 index 00000000000..a1ecc4786d9 --- /dev/null +++ b/db/post_migrate/20240117173808_drop_index_on_projects_lower_path.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropIndexOnProjectsLowerPath < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.9' + + TABLE_NAME = :projects + INDEX_NAME = :index_on_projects_lower_path + + def up + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end + + def down + add_concurrent_index TABLE_NAME, "(lower((path)::text))", name: INDEX_NAME + end +end |