Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-19 00:08:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-19 00:08:06 +0300
commitaf7558b036a53ebb0484e7978694a0b419c38c70 (patch)
tree198bc423fd5bb7ca04e652f5a0c1d66c7d42d2c4 /spec/migrations
parent055b4c04d5cef7029625c08619df4f3bcdccc6c2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/20221018095434_schedule_disable_legacy_open_source_license_for_projects_less_than_five_mb_spec.rb62
-rw-r--r--spec/migrations/20221102231130_finalize_backfill_user_details_fields_spec.rb113
-rw-r--r--spec/migrations/20221104115712_backfill_project_statistics_storage_size_without_uploads_size_spec.rb43
-rw-r--r--spec/migrations/20221110152133_delete_orphans_approval_rules_spec.rb22
-rw-r--r--spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb106
-rw-r--r--spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb24
-rw-r--r--spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb51
-rw-r--r--spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb24
-rw-r--r--spec/migrations/20221209110934_update_import_sources_on_application_settings_spec.rb21
-rw-r--r--spec/migrations/20221209110935_fix_update_import_sources_on_application_settings_spec.rb34
-rw-r--r--spec/migrations/20221209235940_cleanup_o_auth_access_tokens_with_null_expires_in_spec.rb24
-rw-r--r--spec/migrations/20221210154044_update_active_billable_users_index_spec.rb33
-rw-r--r--spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb59
-rw-r--r--spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb19
-rw-r--r--spec/migrations/20221220131020_bump_default_partition_id_value_for_ci_tables_spec.rb78
-rw-r--r--spec/migrations/20221221110733_remove_temp_index_for_project_statistics_upload_size_migration_spec.rb22
-rw-r--r--spec/migrations/20221222092958_sync_new_amount_used_with_amount_used_spec.rb54
-rw-r--r--spec/migrations/20221223123019_delete_queued_jobs_for_vulnerabilities_feedback_migration_spec.rb33
-rw-r--r--spec/migrations/20221226153252_queue_fix_incoherent_packages_size_on_project_statistics_spec.rb54
-rw-r--r--spec/migrations/20230105172120_sync_new_amount_used_with_amount_used_on_ci_namespace_monthly_usages_table_spec.rb55
-rw-r--r--spec/migrations/20230116111252_finalize_todo_sanitization_spec.rb57
-rw-r--r--spec/migrations/20230117114739_clear_duplicate_jobs_cookies_spec.rb23
-rw-r--r--spec/migrations/20230130073109_nullify_creator_id_of_orphaned_projects_spec.rb32
-rw-r--r--spec/migrations/20230131125844_add_project_id_name_id_version_index_to_installable_npm_packages_spec.rb20
-rw-r--r--spec/migrations/20230201171450_finalize_backfill_environment_tier_migration_spec.rb76
-rw-r--r--spec/migrations/20230202131928_encrypt_ci_trigger_token_spec.rb57
-rw-r--r--spec/migrations/20230203122602_schedule_vulnerabilities_feedback_migration4_spec.rb31
-rw-r--r--spec/migrations/add_namespaces_emails_enabled_column_data_spec.rb63
-rw-r--r--spec/migrations/add_okr_hierarchy_restrictions_spec.rb35
-rw-r--r--spec/migrations/add_projects_emails_enabled_column_data_spec.rb69
-rw-r--r--spec/migrations/finalize_issues_namespace_id_backfilling_spec.rb76
-rw-r--r--spec/migrations/nullify_last_error_from_project_mirror_data_spec.rb37
-rw-r--r--spec/migrations/recount_epic_cache_counts_v3_spec.rb32
-rw-r--r--spec/migrations/remove_flowdock_integration_records_spec.rb23
-rw-r--r--spec/migrations/schedule_fixing_security_scan_statuses_spec.rb78
-rw-r--r--spec/migrations/second_recount_epic_cache_counts_spec.rb32
-rw-r--r--spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb42
37 files changed, 0 insertions, 1714 deletions
diff --git a/spec/migrations/20221018095434_schedule_disable_legacy_open_source_license_for_projects_less_than_five_mb_spec.rb b/spec/migrations/20221018095434_schedule_disable_legacy_open_source_license_for_projects_less_than_five_mb_spec.rb
deleted file mode 100644
index ba341ebe5ca..00000000000
--- a/spec/migrations/20221018095434_schedule_disable_legacy_open_source_license_for_projects_less_than_five_mb_spec.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanFiveMb, feature_category: :groups_and_projects do
- let!(:migration) { described_class.new }
- let!(:post_migration) { described_class::MIGRATION }
-
- context 'when on gitlab.com' do
- before do
- allow(Gitlab).to receive(:com?).and_return(true)
- end
-
- describe '#up' do
- it 'schedules background jobs for each batch of project_settings' do
- migration.up
-
- expect(post_migration).to(
- have_scheduled_batched_migration(
- table_name: :project_settings,
- column_name: :project_id,
- interval: described_class::INTERVAL,
- batch_size: described_class::BATCH_SIZE,
- max_batch_size: described_class::MAX_BATCH_SIZE,
- sub_batch_size: described_class::SUB_BATCH_SIZE
- )
- )
- end
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- migration.down
-
- expect(post_migration).not_to have_scheduled_batched_migration
- end
- end
- end
-
- context 'when on self-managed instance' do
- before do
- allow(Gitlab).to receive(:com?).and_return(false)
- end
-
- describe '#up' do
- it 'does not schedule background job' do
- expect(migration).not_to receive(:queue_batched_background_migration)
-
- migration.up
- end
- end
-
- describe '#down' do
- it 'does not delete background job' do
- expect(migration).not_to receive(:delete_batched_background_migration)
-
- migration.down
- end
- end
- end
-end
diff --git a/spec/migrations/20221102231130_finalize_backfill_user_details_fields_spec.rb b/spec/migrations/20221102231130_finalize_backfill_user_details_fields_spec.rb
deleted file mode 100644
index da2f4364e5c..00000000000
--- a/spec/migrations/20221102231130_finalize_backfill_user_details_fields_spec.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-require_migration!
-
-RSpec.describe FinalizeBackfillUserDetailsFields, :migration, feature_category: :user_management do
- let(:batched_migrations) { table(:batched_background_migrations) }
- let(:batch_failed_status) { 2 }
- let(:batch_finalized_status) { 3 }
-
- let!(:migration) { described_class::BACKFILL_MIGRATION }
-
- describe '#up' do
- shared_examples 'finalizes the migration' do
- it 'finalizes the migration' do
- expect do
- migrate!
-
- migration_record.reload
- failed_job.reload
- end.to change { migration_record.status }.from(migration_record.status).to(3).and(
- change { failed_job.status }.from(batch_failed_status).to(batch_finalized_status)
- )
- end
- end
-
- context 'when migration is missing' do
- before do
- batched_migrations.where(job_class_name: migration).delete_all
- end
-
- it 'warns migration not found' do
- expect(Gitlab::AppLogger)
- .to receive(:warn).with(/Could not find batched background migration for the given configuration:/)
-
- migrate!
- end
- end
-
- context 'with migration present' do
- let!(:migration_record) do
- batched_migrations.create!(
- job_class_name: migration,
- table_name: :users,
- column_name: :id,
- job_arguments: [],
- interval: 2.minutes,
- min_value: 1,
- max_value: 2,
- batch_size: 1000,
- sub_batch_size: 500,
- max_batch_size: 5000,
- gitlab_schema: :gitlab_main,
- status: 3 # finished
- )
- end
-
- context 'when migration finished successfully' do
- it 'does not raise exception' do
- expect { migrate! }.not_to raise_error
- end
- end
-
- context 'when users.linkedin column has already been dropped' do
- before do
- table(:users).create!(id: 1, email: 'author@example.com', username: 'author', projects_limit: 10)
- ActiveRecord::Base.connection.execute("ALTER TABLE users DROP COLUMN linkedin")
- migration_record.update_column(:status, 1)
- end
-
- after do
- ActiveRecord::Base.connection.execute("ALTER TABLE users ADD COLUMN linkedin text DEFAULT '' NOT NULL")
- end
-
- it 'does not raise exception' do
- expect { migrate! }.not_to raise_error
- end
- end
-
- context 'with different migration statuses', :redis do
- using RSpec::Parameterized::TableSyntax
-
- where(:status, :description) do
- 0 | 'paused'
- 1 | 'active'
- 4 | 'failed'
- 5 | 'finalizing'
- end
-
- with_them do
- let!(:failed_job) do
- table(:batched_background_migration_jobs).create!(
- batched_background_migration_id: migration_record.id,
- status: batch_failed_status,
- min_value: 1,
- max_value: 10,
- attempts: 2,
- batch_size: 100,
- sub_batch_size: 10
- )
- end
-
- before do
- migration_record.update!(status: status)
- end
-
- it_behaves_like 'finalizes the migration'
- end
- end
- end
- end
-end
diff --git a/spec/migrations/20221104115712_backfill_project_statistics_storage_size_without_uploads_size_spec.rb b/spec/migrations/20221104115712_backfill_project_statistics_storage_size_without_uploads_size_spec.rb
deleted file mode 100644
index 9658b5a699a..00000000000
--- a/spec/migrations/20221104115712_backfill_project_statistics_storage_size_without_uploads_size_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe BackfillProjectStatisticsStorageSizeWithoutUploadsSize,
- feature_category: :consumables_cost_management do
- let!(:batched_migration) { described_class::MIGRATION_CLASS }
-
- it 'does not schedule background jobs when Gitlab.org_or_com? is false' do
- allow(Gitlab).to receive(:dev_or_test_env?).and_return(false)
- allow(Gitlab).to receive(:org_or_com?).and_return(false)
-
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
- end
- end
-
- it 'schedules background jobs for each batch of project_statistics' do
- allow(Gitlab).to receive(:dev_or_test_env?).and_return(false)
- allow(Gitlab).to receive(:org_or_com?).and_return(true)
-
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).to have_scheduled_batched_migration(
- table_name: :project_statistics,
- column_name: :project_id,
- interval: described_class::DELAY_INTERVAL
- )
- }
- end
- end
-end
diff --git a/spec/migrations/20221110152133_delete_orphans_approval_rules_spec.rb b/spec/migrations/20221110152133_delete_orphans_approval_rules_spec.rb
deleted file mode 100644
index 3efee67f7af..00000000000
--- a/spec/migrations/20221110152133_delete_orphans_approval_rules_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe DeleteOrphansApprovalRules, feature_category: :source_code_management do
- describe '#up' do
- it 'schedules background migration for both levels of approval rules' do
- migrate!
-
- expect(described_class::MERGE_REQUEST_MIGRATION).to have_scheduled_batched_migration(
- table_name: :approval_merge_request_rules,
- column_name: :id,
- interval: described_class::INTERVAL)
-
- expect(described_class::PROJECT_MIGRATION).to have_scheduled_batched_migration(
- table_name: :approval_project_rules,
- column_name: :id,
- interval: described_class::INTERVAL)
- end
- end
-end
diff --git a/spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb b/spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb
deleted file mode 100644
index d560da40c21..00000000000
--- a/spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe EnsureWorkItemTypeBackfillMigrationFinished, :migration, feature_category: :team_planning do
- let(:batched_migrations) { table(:batched_background_migrations) }
- let(:work_item_types) { table(:work_item_types) }
- let(:batch_failed_status) { 2 }
- let(:batch_finalized_status) { 3 }
-
- let!(:migration_class) { described_class::MIGRATION }
-
- describe '#up', :redis do
- context 'when migration is missing' do
- before do
- batched_migrations.where(job_class_name: migration_class).delete_all
- end
-
- it 'warns migration not found' do
- expect(Gitlab::AppLogger)
- .to receive(:warn).with(/Could not find batched background migration for the given configuration:/)
- .exactly(5).times
-
- migrate!
- end
- end
-
- context 'with migration present' do
- let(:relevant_types) do
- {
- issue: 0,
- incident: 1,
- test_case: 2,
- requirement: 3,
- task: 4
- }
- end
-
- let!(:backfill_migrations) do
- relevant_types.map do |_base_type, enum_value|
- type_id = work_item_types.find_by!(namespace_id: nil, base_type: enum_value).id
-
- create_migration_with(status, enum_value, type_id)
- end
- end
-
- context 'when migrations have finished' do
- let(:status) { 3 } # finished enum value
-
- it 'does not raise an error' do
- expect { migrate! }.not_to raise_error
- end
- end
-
- context 'with different migration statuses' do
- using RSpec::Parameterized::TableSyntax
-
- where(:status, :description) do
- 0 | 'paused'
- 1 | 'active'
- 4 | 'failed'
- 5 | 'finalizing'
- end
-
- with_them do
- it 'finalizes the migration' do
- expect do
- migrate!
-
- backfill_migrations.each(&:reload)
- end.to change { backfill_migrations.map(&:status).uniq }.from([status]).to([3])
- end
- end
- end
- end
- end
-
- def create_migration_with(status, base_type, type_id)
- migration = batched_migrations.create!(
- job_class_name: migration_class,
- table_name: :issues,
- column_name: :id,
- job_arguments: [base_type, type_id],
- interval: 2.minutes,
- min_value: 1,
- max_value: 2,
- batch_size: 1000,
- sub_batch_size: 200,
- gitlab_schema: :gitlab_main,
- status: status
- )
-
- table(:batched_background_migration_jobs).create!(
- batched_background_migration_id: migration.id,
- status: batch_failed_status,
- min_value: 1,
- max_value: 10,
- attempts: 2,
- batch_size: 100,
- sub_batch_size: 10
- )
-
- migration
- end
-end
diff --git a/spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb b/spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb
deleted file mode 100644
index 9eaab56de7c..00000000000
--- a/spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe SchedulePruneStaleProjectExportJobs, feature_category: :importers do
- let!(:batched_migration) { described_class::MIGRATION }
-
- it 'schedules a new batched migration' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).to have_scheduled_batched_migration(
- table_name: :project_export_jobs,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL
- )
- }
- end
- end
-end
diff --git a/spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb b/spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb
deleted file mode 100644
index 2951b738243..00000000000
--- a/spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe QueueResetStatusOnContainerRepositories, feature_category: :container_registry do
- let!(:batched_migration) { described_class::MIGRATION }
-
- before do
- stub_container_registry_config(
- enabled: true,
- api_url: 'http://example.com',
- key: 'spec/fixtures/x509_certificate_pk.key'
- )
- end
-
- it 'schedules a new batched migration' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).to have_scheduled_batched_migration(
- table_name: :container_repositories,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL,
- sub_batch_size: described_class::BATCH_SIZE
- )
- }
- end
- end
-
- context 'with the container registry disabled' do
- before do
- allow(::Gitlab.config.registry).to receive(:enabled).and_return(false)
- end
-
- it 'does not schedule a new batched migration' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
- end
- end
- end
-end
diff --git a/spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb b/spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb
deleted file mode 100644
index e03fd9c9daf..00000000000
--- a/spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe ScheduleBackfillEnvironmentTier, feature_category: :continuous_delivery do
- let!(:batched_migration) { described_class::MIGRATION }
-
- it 'schedules a new batched migration' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).to have_scheduled_batched_migration(
- table_name: :environments,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL
- )
- }
- end
- end
-end
diff --git a/spec/migrations/20221209110934_update_import_sources_on_application_settings_spec.rb b/spec/migrations/20221209110934_update_import_sources_on_application_settings_spec.rb
deleted file mode 100644
index d8270816afe..00000000000
--- a/spec/migrations/20221209110934_update_import_sources_on_application_settings_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe UpdateImportSourcesOnApplicationSettings, feature_category: :importers do
- let(:settings) { table(:application_settings) }
- let(:import_sources_with_google) { %w[google_code github git bitbucket bitbucket_server] }
- let(:import_sources_without_google) { %w[github git bitbucket bitbucket_server] }
-
- describe "#up" do
- it 'removes google_code and preserves existing valid import sources' do
- record = settings.create!(import_sources: import_sources_with_google.to_yaml)
-
- migrate!
-
- expect(record.reload.import_sources).to start_with('---')
- expect(ApplicationSetting.last.import_sources).to eq(import_sources_without_google)
- end
- end
-end
diff --git a/spec/migrations/20221209110935_fix_update_import_sources_on_application_settings_spec.rb b/spec/migrations/20221209110935_fix_update_import_sources_on_application_settings_spec.rb
deleted file mode 100644
index 1f276109b24..00000000000
--- a/spec/migrations/20221209110935_fix_update_import_sources_on_application_settings_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe FixUpdateImportSourcesOnApplicationSettings, feature_category: :importers do
- let(:settings) { table(:application_settings) }
- let(:import_sources) { %w[github git bitbucket bitbucket_server] }
-
- describe "#up" do
- shared_examples 'fixes import_sources on application_settings' do
- it 'ensures YAML is stored' do
- record = settings.create!(import_sources: data)
-
- migrate!
-
- expect(record.reload.import_sources).to start_with('---')
- expect(ApplicationSetting.last.import_sources).to eq(import_sources)
- end
- end
-
- context 'when import_sources is a String' do
- let(:data) { import_sources.to_s }
-
- it_behaves_like 'fixes import_sources on application_settings'
- end
-
- context 'when import_sources is already YAML' do
- let(:data) { import_sources.to_yaml }
-
- it_behaves_like 'fixes import_sources on application_settings'
- end
- end
-end
diff --git a/spec/migrations/20221209235940_cleanup_o_auth_access_tokens_with_null_expires_in_spec.rb b/spec/migrations/20221209235940_cleanup_o_auth_access_tokens_with_null_expires_in_spec.rb
deleted file mode 100644
index e5890ffce17..00000000000
--- a/spec/migrations/20221209235940_cleanup_o_auth_access_tokens_with_null_expires_in_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe CleanupOAuthAccessTokensWithNullExpiresIn, feature_category: :system_access do
- let(:batched_migration) { described_class::MIGRATION }
-
- it 'schedules background jobs for each batch of oauth_access_tokens' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).to have_scheduled_batched_migration(
- table_name: :oauth_access_tokens,
- column_name: :id,
- interval: described_class::INTERVAL
- )
- }
- end
- end
-end
diff --git a/spec/migrations/20221210154044_update_active_billable_users_index_spec.rb b/spec/migrations/20221210154044_update_active_billable_users_index_spec.rb
deleted file mode 100644
index 3341df2ce51..00000000000
--- a/spec/migrations/20221210154044_update_active_billable_users_index_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe UpdateActiveBillableUsersIndex, feature_category: :database do
- let(:db) { described_class.new }
- let(:table_name) { described_class::TABLE_NAME }
- let(:old_index_name) { described_class::OLD_INDEX_NAME }
- let(:new_index_name) { described_class::NEW_INDEX_NAME }
- let(:old_filter_condition) { "(user_type <> ALL ('{2,6,1,3,7,8}'::smallint[])))" }
- let(:new_filter_condition) { "(user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[])))" }
-
- it 'correctly migrates up and down' do
- reversible_migration do |migration|
- migration.before -> {
- expect(subject.index_exists_by_name?(table_name, new_index_name)).to be_falsy
- expect(subject.index_exists_by_name?(table_name, old_index_name)).to be_truthy
- expect(db.connection.indexes(table_name).find do |i|
- i.name == old_index_name
- end.where).to include(old_filter_condition)
- }
-
- migration.after -> {
- expect(subject.index_exists_by_name?(table_name, old_index_name)).to be_falsy
- expect(subject.index_exists_by_name?(table_name, new_index_name)).to be_truthy
- expect(db.connection.indexes(table_name).find do |i|
- i.name == new_index_name
- end.where).to include(new_filter_condition)
- }
- end
- end
-end
diff --git a/spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb b/spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb
deleted file mode 100644
index 7cc0bd96a0d..00000000000
--- a/spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe ScheduleBackfillReleasesAuthorId, feature_category: :release_orchestration do
- context 'when there are releases without author' do
- let(:releases_table) { table(:releases) }
- let(:user_table) { table(:users) }
- let(:date_time) { DateTime.now }
- let!(:batched_migration) { described_class::MIGRATION }
- let!(:test_user) do
- user_table.create!(
- name: 'test',
- email: 'test@example.com',
- username: 'test',
- projects_limit: 10
- )
- end
-
- before do
- releases_table.create!(
- tag: 'tag1', name: 'tag1', released_at: (date_time - 1.minute), author_id: test_user.id
- )
- releases_table.create!(
- tag: 'tag2', name: 'tag2', released_at: (date_time - 2.minutes), author_id: test_user.id
- )
- releases_table.new(
- tag: 'tag3', name: 'tag3', released_at: (date_time - 3.minutes), author_id: nil
- ).save!(validate: false)
- releases_table.new(
- tag: 'tag4', name: 'tag4', released_at: (date_time - 4.minutes), author_id: nil
- ).save!(validate: false)
- end
-
- it 'schedules a new batched migration' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).to have_scheduled_batched_migration(
- table_name: :releases,
- column_name: :id,
- interval: described_class::JOB_DELAY_INTERVAL,
- job_arguments: [User.find_by(user_type: :ghost)&.id]
- )
- }
- end
- end
- end
-
- context 'when there are no releases without author' do
- it 'does not schedule batched migration' do
- expect(described_class.new.up).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb b/spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb
deleted file mode 100644
index 48702e866e0..00000000000
--- a/spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe CopyClickhouseConnectionStringToEncryptedVar, feature_category: :product_analytics_data_management do
- let!(:migration) { described_class.new }
- let(:setting) { table(:application_settings).create!(clickhouse_connection_string: 'https://example.com/test') }
-
- it 'copies the clickhouse_connection_string to the encrypted column' do
- expect(setting.clickhouse_connection_string).to eq('https://example.com/test')
-
- migrate!
-
- setting.reload
- expect(setting.clickhouse_connection_string).to eq('https://example.com/test')
- expect(setting.encrypted_product_analytics_clickhouse_connection_string).not_to be_nil
- end
-end
diff --git a/spec/migrations/20221220131020_bump_default_partition_id_value_for_ci_tables_spec.rb b/spec/migrations/20221220131020_bump_default_partition_id_value_for_ci_tables_spec.rb
deleted file mode 100644
index c4bd243e79f..00000000000
--- a/spec/migrations/20221220131020_bump_default_partition_id_value_for_ci_tables_spec.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-require_migration!
-
-RSpec.describe BumpDefaultPartitionIdValueForCiTables, :migration, feature_category: :continuous_integration do
- context 'when on sass' do
- before do
- allow(Gitlab).to receive(:com?).and_return(true)
- end
-
- it 'changes default values' do
- reversible_migration do |migration|
- migration.before -> {
- expect(default_values).not_to include(101)
- }
-
- migration.after -> {
- expect(default_values).to match_array([101])
- }
- end
- end
-
- context 'with tables already changed' do
- before do
- active_record_base.connection.execute(<<~SQL)
- ALTER TABLE ci_builds ALTER COLUMN partition_id SET DEFAULT 101
- SQL
- end
-
- after do
- schema_migrate_down!
- end
-
- let(:alter_query) do
- /ALTER TABLE "ci_builds" ALTER COLUMN "partition_id" SET DEFAULT 101/
- end
-
- it 'skips updating already changed tables' do
- recorder = ActiveRecord::QueryRecorder.new { migrate! }
-
- expect(recorder.log.any?(alter_query)).to be_falsey
- expect(default_values).to match_array([101])
- end
- end
- end
-
- context 'when self-managed' do
- before do
- allow(Gitlab).to receive(:com?).and_return(false)
- end
-
- it 'does not change default values' do
- reversible_migration do |migration|
- migration.before -> {
- expect(default_values).not_to include(101)
- }
-
- migration.after -> {
- expect(default_values).not_to include(101)
- }
- end
- end
- end
-
- def default_values
- values = described_class::TABLES.flat_map do |table_name, columns|
- active_record_base
- .connection
- .columns(table_name)
- .select { |column| columns.include?(column.name.to_sym) }
- .map { |column| column.default&.to_i }
- end
-
- values.uniq
- end
-end
diff --git a/spec/migrations/20221221110733_remove_temp_index_for_project_statistics_upload_size_migration_spec.rb b/spec/migrations/20221221110733_remove_temp_index_for_project_statistics_upload_size_migration_spec.rb
deleted file mode 100644
index 440a932c76b..00000000000
--- a/spec/migrations/20221221110733_remove_temp_index_for_project_statistics_upload_size_migration_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe RemoveTempIndexForProjectStatisticsUploadSizeMigration,
- feature_category: :consumables_cost_management do
- let(:table_name) { 'project_statistics' }
- let(:index_name) { described_class::INDEX_NAME }
-
- it 'correctly migrates up and down' do
- reversible_migration do |migration|
- migration.before -> {
- expect(subject.index_exists_by_name?(table_name, index_name)).to be_truthy
- }
-
- migration.after -> {
- expect(subject.index_exists_by_name?(table_name, index_name)).to be_falsy
- }
- end
- end
-end
diff --git a/spec/migrations/20221222092958_sync_new_amount_used_with_amount_used_spec.rb b/spec/migrations/20221222092958_sync_new_amount_used_with_amount_used_spec.rb
deleted file mode 100644
index 158560a2432..00000000000
--- a/spec/migrations/20221222092958_sync_new_amount_used_with_amount_used_spec.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-require_migration!
-
-RSpec.describe SyncNewAmountUsedWithAmountUsed, migration: :gitlab_ci, feature_category: :continuous_integration do
- let(:project_usages) { table(:ci_project_monthly_usages) }
- let(:migration) { described_class.new }
-
- before do
- # Disabling the trigger temporarily to allow records being created with out-of-sync
- # `new_amount_used` and `amount_used`. This will simulate existing records before
- # we add the trigger.
- ActiveRecord::Base.connection
- .execute("ALTER TABLE ci_project_monthly_usages DISABLE TRIGGER sync_projects_amount_used_columns")
-
- this_month = Time.now.utc.beginning_of_month
- last_month = 1.month.ago.utc.beginning_of_month
- last_year = 1.year.ago.utc.beginning_of_month
-
- project_usages.create!(project_id: 1, date: last_year)
- project_usages.create!(project_id: 1, date: this_month, amount_used: 10, new_amount_used: 0)
- project_usages.create!(project_id: 1, date: last_month, amount_used: 20, new_amount_used: 0)
-
- project_usages.create!(project_id: 2, date: last_year)
- project_usages.create!(project_id: 2, date: this_month, amount_used: 30, new_amount_used: 0)
- project_usages.create!(project_id: 2, date: last_month, amount_used: 40, new_amount_used: 0)
-
- ActiveRecord::Base.connection
- .execute("ALTER TABLE ci_project_monthly_usages ENABLE TRIGGER sync_projects_amount_used_columns")
- end
-
- describe '#up' do
- it "doesnt change new_amount_used values" do
- data = project_usages.all
- data.each do |item|
- expect { migration.up }.to not_change { item.new_amount_used }
- end
- end
- end
-
- describe '#down' do
- it 'updates `new_amount_used` with values from `amount_used`' do
- expect(project_usages.where(new_amount_used: 0).count).to eq(6)
-
- migration.down
-
- expect(project_usages.where(new_amount_used: 0).count).to eq(2)
- expect(project_usages.order(:id).pluck(:new_amount_used))
- .to contain_exactly(0, 0, 10, 20, 30, 40)
- end
- end
-end
diff --git a/spec/migrations/20221223123019_delete_queued_jobs_for_vulnerabilities_feedback_migration_spec.rb b/spec/migrations/20221223123019_delete_queued_jobs_for_vulnerabilities_feedback_migration_spec.rb
deleted file mode 100644
index c5e1a255653..00000000000
--- a/spec/migrations/20221223123019_delete_queued_jobs_for_vulnerabilities_feedback_migration_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe DeleteQueuedJobsForVulnerabilitiesFeedbackMigration, feature_category: :vulnerability_management do
- let!(:migration) { described_class.new }
- let(:batched_background_migrations) { table(:batched_background_migrations) }
-
- before do
- batched_background_migrations.create!(
- max_value: 10,
- batch_size: 250,
- sub_batch_size: 50,
- interval: 300,
- job_class_name: 'MigrateVulnerabilitiesFeedbackToVulnerabilitiesStateTransition',
- table_name: 'vulnerability_feedback',
- column_name: 'id',
- job_arguments: [],
- gitlab_schema: "gitlab_main"
- )
- end
-
- describe "#up" do
- it "deletes all batched migration records" do
- expect(batched_background_migrations.count).to eq(1)
-
- migration.up
-
- expect(batched_background_migrations.count).to eq(0)
- end
- end
-end
diff --git a/spec/migrations/20221226153252_queue_fix_incoherent_packages_size_on_project_statistics_spec.rb b/spec/migrations/20221226153252_queue_fix_incoherent_packages_size_on_project_statistics_spec.rb
deleted file mode 100644
index b375546b90e..00000000000
--- a/spec/migrations/20221226153252_queue_fix_incoherent_packages_size_on_project_statistics_spec.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe QueueFixIncoherentPackagesSizeOnProjectStatistics, feature_category: :package_registry do
- let(:batched_migration) { described_class::MIGRATION }
-
- context 'with no packages' do
- it 'does not schedule a new batched migration' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
- end
- end
- end
-
- context 'with some packages' do
- before do
- namespace = table(:namespaces)
- .create!(name: 'project', path: 'project', type: 'Project')
- project = table(:projects).create!(
- name: 'project',
- path: 'project',
- project_namespace_id: namespace.id,
- namespace_id: namespace.id
- )
- table(:packages_packages)
- .create!(name: 'test', version: '1.2.3', package_type: 2, project_id: project.id)
- end
-
- it 'schedules a new batched migration' do
- reversible_migration do |migration|
- migration.before -> {
- expect(batched_migration).not_to have_scheduled_batched_migration
- }
-
- migration.after -> {
- expect(batched_migration).to have_scheduled_batched_migration(
- table_name: :project_statistics,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL,
- batch_size: described_class::BATCH_SIZE
- )
- }
- end
- end
- end
-end
diff --git a/spec/migrations/20230105172120_sync_new_amount_used_with_amount_used_on_ci_namespace_monthly_usages_table_spec.rb b/spec/migrations/20230105172120_sync_new_amount_used_with_amount_used_on_ci_namespace_monthly_usages_table_spec.rb
deleted file mode 100644
index 70c9c1333b8..00000000000
--- a/spec/migrations/20230105172120_sync_new_amount_used_with_amount_used_on_ci_namespace_monthly_usages_table_spec.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-require_migration!
-
-RSpec.describe SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable, migration: :gitlab_ci,
- feature_category: :continuous_integration do
- let(:namespace_usages) { table(:ci_namespace_monthly_usages) }
- let(:migration) { described_class.new }
-
- before do
- # Disabling the trigger temporarily to allow records being created with out-of-sync
- # `new_amount_used` and `amount_used`. This will simulate existing records before
- # we add the trigger.
- ActiveRecord::Base.connection
- .execute("ALTER TABLE ci_namespace_monthly_usages DISABLE TRIGGER sync_namespaces_amount_used_columns")
-
- this_month = Time.now.utc.beginning_of_month
- last_month = 1.month.ago.utc.beginning_of_month
- last_year = 1.year.ago.utc.beginning_of_month
-
- namespace_usages.create!(namespace_id: 1, date: last_year)
- namespace_usages.create!(namespace_id: 1, date: this_month, amount_used: 10, new_amount_used: 0)
- namespace_usages.create!(namespace_id: 1, date: last_month, amount_used: 20, new_amount_used: 0)
-
- namespace_usages.create!(namespace_id: 2, date: last_year)
- namespace_usages.create!(namespace_id: 2, date: this_month, amount_used: 30, new_amount_used: 0)
- namespace_usages.create!(namespace_id: 2, date: last_month, amount_used: 40, new_amount_used: 0)
-
- ActiveRecord::Base.connection
- .execute("ALTER TABLE ci_namespace_monthly_usages ENABLE TRIGGER sync_namespaces_amount_used_columns")
- end
-
- describe '#up' do
- it "doesnt change new_amount_used values" do
- data = namespace_usages.all
- data.each do |item|
- expect { migration.up }.to not_change { item.new_amount_used }
- end
- end
- end
-
- describe '#down' do
- it 'updates `new_amount_used` with values from `amount_used`' do
- expect(namespace_usages.where(new_amount_used: 0).count).to eq(6)
-
- migration.down
-
- expect(namespace_usages.where(new_amount_used: 0).count).to eq(2)
- expect(namespace_usages.order(:id).pluck(:new_amount_used))
- .to contain_exactly(0, 0, 10, 20, 30, 40)
- end
- end
-end
diff --git a/spec/migrations/20230116111252_finalize_todo_sanitization_spec.rb b/spec/migrations/20230116111252_finalize_todo_sanitization_spec.rb
deleted file mode 100644
index cd7828bbae4..00000000000
--- a/spec/migrations/20230116111252_finalize_todo_sanitization_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe FinalizeTodoSanitization, :migration, feature_category: :portfolio_management do
- let(:batched_migrations) { table(:batched_background_migrations) }
-
- let!(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- let!(:sanitize_todos_migration) do
- batched_migrations.create!(
- job_class_name: 'SanitizeConfidentialTodos',
- table_name: :notes,
- column_name: :id,
- job_arguments: [],
- interval: 2.minutes,
- min_value: 1,
- max_value: 2,
- batch_size: 1000,
- sub_batch_size: 200,
- gitlab_schema: :gitlab_main,
- status: 3 # finished
- )
- end
-
- context 'when migration finished successfully' do
- it 'does not raise exception' do
- expect { migrate! }.not_to raise_error
- end
- end
-
- context 'with different migration statuses' do
- using RSpec::Parameterized::TableSyntax
-
- where(:status, :description) do
- 0 | 'paused'
- 1 | 'active'
- 4 | 'failed'
- 5 | 'finalizing'
- end
-
- with_them do
- before do
- sanitize_todos_migration.update!(status: status)
- end
-
- it 'finalizes the migration' do
- allow_next_instance_of(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner) do |runner|
- expect(runner).to receive(:finalize).with('SanitizeConfidentialTodos', :members, :id, [])
- end
- end
- end
- end
- end
-end
diff --git a/spec/migrations/20230117114739_clear_duplicate_jobs_cookies_spec.rb b/spec/migrations/20230117114739_clear_duplicate_jobs_cookies_spec.rb
deleted file mode 100644
index 5c572b49d3d..00000000000
--- a/spec/migrations/20230117114739_clear_duplicate_jobs_cookies_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe ClearDuplicateJobsCookies, :migration, feature_category: :redis do
- def with_redis(&block)
- Gitlab::Redis::Queues.with(&block)
- end
-
- it 'deletes duplicate jobs cookies' do
- delete = ['resque:gitlab:duplicate:blabla:1:cookie:v2', 'resque:gitlab:duplicate:foobar:2:cookie:v2']
- keep = ['resque:gitlab:duplicate:something', 'something:cookie:v2']
- with_redis { |r| (delete + keep).each { |key| r.set(key, 'value') } }
-
- expect(with_redis { |r| r.exists(delete + keep) }).to eq(4)
-
- migrate!
-
- expect(with_redis { |r| r.exists(delete) }).to eq(0)
- expect(with_redis { |r| r.exists(keep) }).to eq(2)
- end
-end
diff --git a/spec/migrations/20230130073109_nullify_creator_id_of_orphaned_projects_spec.rb b/spec/migrations/20230130073109_nullify_creator_id_of_orphaned_projects_spec.rb
deleted file mode 100644
index 196bacd99ba..00000000000
--- a/spec/migrations/20230130073109_nullify_creator_id_of_orphaned_projects_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe NullifyCreatorIdOfOrphanedProjects, feature_category: :groups_and_projects do
- let!(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- it 'schedules background migration' do
- migrate!
-
- expect(migration).to have_scheduled_batched_migration(
- table_name: :projects,
- column_name: :id,
- interval: described_class::INTERVAL,
- batch_size: described_class::BATCH_SIZE,
- max_batch_size: described_class::MAX_BATCH_SIZE,
- sub_batch_size: described_class::SUB_BATCH_SIZE
- )
- end
- end
-
- describe '#down' do
- it 'removes scheduled background migrations' do
- migrate!
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/20230131125844_add_project_id_name_id_version_index_to_installable_npm_packages_spec.rb b/spec/migrations/20230131125844_add_project_id_name_id_version_index_to_installable_npm_packages_spec.rb
deleted file mode 100644
index 5d8c7ab4745..00000000000
--- a/spec/migrations/20230131125844_add_project_id_name_id_version_index_to_installable_npm_packages_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe AddProjectIdNameIdVersionIndexToInstallableNpmPackages, feature_category: :package_registry do
- it 'schedules an index creation' do
- reversible_migration do |migration|
- migration.before -> {
- expect(ActiveRecord::Base.connection.indexes('packages_packages').map(&:name))
- .not_to include('idx_packages_on_project_id_name_id_version_when_installable_npm')
- }
-
- migration.after -> {
- expect(ActiveRecord::Base.connection.indexes('packages_packages').map(&:name))
- .to include('idx_packages_on_project_id_name_id_version_when_installable_npm')
- }
- end
- end
-end
diff --git a/spec/migrations/20230201171450_finalize_backfill_environment_tier_migration_spec.rb b/spec/migrations/20230201171450_finalize_backfill_environment_tier_migration_spec.rb
deleted file mode 100644
index e7a78f11f16..00000000000
--- a/spec/migrations/20230201171450_finalize_backfill_environment_tier_migration_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe FinalizeBackfillEnvironmentTierMigration, :migration, feature_category: :continuous_delivery do
- let(:batched_migrations) { table(:batched_background_migrations) }
-
- let!(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- shared_examples 'finalizes the migration' do
- it 'finalizes the migration' do
- allow_next_instance_of(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner) do |runner|
- expect(runner).to receive(:finalize).with('BackfillEnvironmentTiers', :environments, :id, [])
- end
- end
- end
-
- context 'when migration is missing' do
- before do
- batched_migrations.where(job_class_name: migration).delete_all
- end
-
- it 'warns migration not found' do
- expect(Gitlab::AppLogger)
- .to receive(:warn).with(/Could not find batched background migration for the given configuration:/)
-
- migrate!
- end
- end
-
- context 'with migration present' do
- let!(:group_member_namespace_id_backfill) do
- batched_migrations.create!(
- job_class_name: migration,
- table_name: :environments,
- column_name: :id,
- job_arguments: [],
- interval: 2.minutes,
- min_value: 1,
- max_value: 2,
- batch_size: 1000,
- sub_batch_size: 200,
- gitlab_schema: :gitlab_main,
- status: 3 # finished
- )
- end
-
- context 'when migration finished successfully' do
- it 'does not raise exception' do
- expect { migrate! }.not_to raise_error
- end
- end
-
- context 'with different migration statuses' do
- using RSpec::Parameterized::TableSyntax
-
- where(:status, :description) do
- 0 | 'paused'
- 1 | 'active'
- 4 | 'failed'
- 5 | 'finalizing'
- end
-
- with_them do
- before do
- group_member_namespace_id_backfill.update!(status: status)
- end
-
- it_behaves_like 'finalizes the migration'
- end
- end
- end
- end
-end
diff --git a/spec/migrations/20230202131928_encrypt_ci_trigger_token_spec.rb b/spec/migrations/20230202131928_encrypt_ci_trigger_token_spec.rb
deleted file mode 100644
index 597cd7c1581..00000000000
--- a/spec/migrations/20230202131928_encrypt_ci_trigger_token_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe EncryptCiTriggerToken, migration: :gitlab_ci, feature_category: :continuous_integration do
- let(:batched_migrations) { table(:batched_background_migrations) }
-
- let!(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- context 'with migration present' do
- let!(:ci_trigger_token_encryption_migration) do
- batched_migrations.create!(
- job_class_name: 'EncryptCiTriggerToken',
- table_name: :ci_triggers,
- column_name: :token,
- job_arguments: [],
- interval: 2.minutes,
- min_value: 1,
- max_value: 2,
- batch_size: 1000,
- sub_batch_size: 100,
- gitlab_schema: :gitlab_ci,
- status: 3 # finished
- )
- end
-
- context 'when migration finished successfully' do
- it 'does not raise exception' do
- expect { migrate! }.not_to raise_error
- end
-
- it 'schedules background jobs for each batch of ci_triggers' do
- migrate!
-
- expect(migration).to have_scheduled_batched_migration(
- gitlab_schema: :gitlab_ci,
- table_name: :ci_triggers,
- column_name: :token,
- batch_size: described_class::BATCH_SIZE,
- sub_batch_size: described_class::SUB_BATCH_SIZE
- )
- end
- end
- end
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- migrate!
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/20230203122602_schedule_vulnerabilities_feedback_migration4_spec.rb b/spec/migrations/20230203122602_schedule_vulnerabilities_feedback_migration4_spec.rb
deleted file mode 100644
index 26c63e6deb2..00000000000
--- a/spec/migrations/20230203122602_schedule_vulnerabilities_feedback_migration4_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe ScheduleVulnerabilitiesFeedbackMigration4, feature_category: :vulnerability_management do
- let(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- it 'schedules background jobs for each batch of Vulnerabilities::Feedback' do
- migrate!
-
- expect(migration).to have_scheduled_batched_migration(
- table_name: :vulnerability_feedback,
- column_name: :id,
- interval: described_class::JOB_INTERVAL,
- batch_size: described_class::BATCH_SIZE,
- sub_batch_size: described_class::SUB_BATCH_SIZE
- )
- end
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- migrate!
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/add_namespaces_emails_enabled_column_data_spec.rb b/spec/migrations/add_namespaces_emails_enabled_column_data_spec.rb
deleted file mode 100644
index c63724497c2..00000000000
--- a/spec/migrations/add_namespaces_emails_enabled_column_data_spec.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe AddNamespacesEmailsEnabledColumnData, :migration, feature_category: :database do
- let(:migration) { described_class::MIGRATION }
- let(:projects) { table(:projects) }
- let(:namespace_settings_table) { table(:namespace_settings) }
- let(:namespaces) { table(:namespaces) }
-
- before do
- stub_const("#{described_class.name}::SUB_BATCH_SIZE", 2)
- end
-
- it 'schedules background migrations', :aggregate_failures do
- migrate!
-
- expect(migration).to have_scheduled_batched_migration(
- table_name: :namespaces,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL
- )
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- migrate!
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-
- it 'sets emails_enabled to be the opposite of emails_disabled', type: :task do
- Rake.application.rake_require 'active_record/railties/databases'
- Rake.application.rake_require 'tasks/gitlab/db'
-
- disabled_records_to_migrate = 6
- enabled_records_to_migrate = 4
-
- disabled_records_to_migrate.times do |i|
- namespace = namespaces.create!(name: 'namespace',
- path: "namespace#{i}",
- emails_disabled: true)
- namespace_settings_table.create!(namespace_id: namespace.id)
- end
-
- enabled_records_to_migrate.times do |i|
- namespace = namespaces.create!(name: 'namespace',
- path: "namespace#{i}",
- emails_disabled: false)
- namespace_settings_table.create!(namespace_id: namespace.id)
- end
-
- migrate!
- run_rake_task('gitlab:db:execute_batched_migrations')
- # rubocop: disable CodeReuse/ActiveRecord
- expect(namespace_settings_table.where(emails_enabled: true).count).to eq(enabled_records_to_migrate)
- expect(namespace_settings_table.where(emails_enabled: false).count).to eq(disabled_records_to_migrate)
- # rubocop: enable CodeReuse/ActiveRecord
- end
-end
diff --git a/spec/migrations/add_okr_hierarchy_restrictions_spec.rb b/spec/migrations/add_okr_hierarchy_restrictions_spec.rb
deleted file mode 100644
index ace581c7e3c..00000000000
--- a/spec/migrations/add_okr_hierarchy_restrictions_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe AddOkrHierarchyRestrictions, :migration, feature_category: :portfolio_management do
- include MigrationHelpers::WorkItemTypesHelper
-
- let!(:restrictions) { table(:work_item_hierarchy_restrictions) }
- let!(:work_item_types) { table(:work_item_types) }
-
- it 'creates default restrictions' do
- restrictions.delete_all
-
- reversible_migration do |migration|
- migration.before -> {
- expect(restrictions.count).to eq(0)
- }
-
- migration.after -> {
- expect(restrictions.count).to eq(4)
- }
- end
- end
-
- context 'when work items are missing' do
- before do
- work_item_types.delete_all
- end
-
- it 'does nothing' do
- expect { migrate! }.not_to change { restrictions.count }
- end
- end
-end
diff --git a/spec/migrations/add_projects_emails_enabled_column_data_spec.rb b/spec/migrations/add_projects_emails_enabled_column_data_spec.rb
deleted file mode 100644
index d10fa78f846..00000000000
--- a/spec/migrations/add_projects_emails_enabled_column_data_spec.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe AddProjectsEmailsEnabledColumnData, :migration, feature_category: :database do
- let(:migration) { described_class::MIGRATION }
- let(:project_settings) { table(:project_settings) }
- let(:projects) { table(:projects) }
- let(:namespaces) { table(:namespaces) }
-
- before do
- stub_const("#{described_class.name}::SUB_BATCH_SIZE", 2)
- end
-
- it 'schedules background migrations', :aggregate_failures do
- migrate!
-
- expect(migration).to have_scheduled_batched_migration(
- table_name: :projects,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL
- )
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- migrate!
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-
- it 'sets emails_enabled to be the opposite of emails_disabled', type: :task do
- Rake.application.rake_require 'active_record/railties/databases'
- Rake.application.rake_require 'tasks/gitlab/db'
-
- disabled_records_to_migrate = 4
- enabled_records_to_migrate = 2
-
- disabled_records_to_migrate.times do |i|
- namespace = namespaces.create!(name: 'namespace', path: "namespace#{i}")
- project = projects.create!(name: "Project Disabled #{i}",
- path: "projectDisabled#{i}",
- namespace_id: namespace.id,
- project_namespace_id: namespace.id,
- emails_disabled: true)
- project_settings.create!(project_id: project.id)
- end
-
- enabled_records_to_migrate.times do |i|
- namespace = namespaces.create!(name: 'namespace', path: "namespace#{i}")
- project = projects.create!(name: "Project Enabled #{i}",
- path: "projectEnabled#{i}",
- namespace_id: namespace.id,
- project_namespace_id: namespace.id,
- emails_disabled: false)
- project_settings.create!(project_id: project.id)
- end
-
- migrate!
- run_rake_task('gitlab:db:execute_batched_migrations')
- # rubocop: disable CodeReuse/ActiveRecord
- expect(project_settings.where(emails_enabled: true).count).to eq(enabled_records_to_migrate)
- expect(project_settings.where(emails_enabled: false).count).to eq(disabled_records_to_migrate)
- # rubocop: enable CodeReuse/ActiveRecord
- end
-end
diff --git a/spec/migrations/finalize_issues_namespace_id_backfilling_spec.rb b/spec/migrations/finalize_issues_namespace_id_backfilling_spec.rb
deleted file mode 100644
index 0800a049767..00000000000
--- a/spec/migrations/finalize_issues_namespace_id_backfilling_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe FinalizeIssuesNamespaceIdBackfilling, :migration, feature_category: :team_planning do
- let(:batched_migrations) { table(:batched_background_migrations) }
-
- let!(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- shared_examples 'finalizes the migration' do
- it 'finalizes the migration' do
- allow_next_instance_of(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner) do |runner|
- expect(runner).to receive(:finalize).with(migration, :projects, :id, [])
- end
- end
- end
-
- context 'when routes backfilling migration is missing' do
- before do
- batched_migrations.where(job_class_name: migration).delete_all
- end
-
- it 'warns migration not found' do
- expect(Gitlab::AppLogger)
- .to receive(:warn).with(/Could not find batched background migration for the given configuration:/)
-
- migrate!
- end
- end
-
- context 'with backfilling migration present' do
- let!(:project_namespace_backfill) do
- batched_migrations.create!(
- job_class_name: migration,
- table_name: :routes,
- column_name: :id,
- job_arguments: [],
- interval: 2.minutes,
- min_value: 1,
- max_value: 2,
- batch_size: 1000,
- sub_batch_size: 200,
- gitlab_schema: :gitlab_main,
- status: 3 # finished
- )
- end
-
- context 'when backfilling migration finished successfully' do
- it 'does not raise exception' do
- expect { migrate! }.not_to raise_error
- end
- end
-
- context 'with different backfilling migration statuses' do
- using RSpec::Parameterized::TableSyntax
-
- where(:status, :description) do
- 0 | 'paused'
- 1 | 'active'
- 4 | 'failed'
- 5 | 'finalizing'
- end
-
- with_them do
- before do
- project_namespace_backfill.update!(status: status)
- end
-
- it_behaves_like 'finalizes the migration'
- end
- end
- end
- end
-end
diff --git a/spec/migrations/nullify_last_error_from_project_mirror_data_spec.rb b/spec/migrations/nullify_last_error_from_project_mirror_data_spec.rb
deleted file mode 100644
index 6c5679b674e..00000000000
--- a/spec/migrations/nullify_last_error_from_project_mirror_data_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-require_migration!
-
-RSpec.describe NullifyLastErrorFromProjectMirrorData, feature_category: :source_code_management do
- let(:migration) { described_class::MIGRATION }
-
- before do
- migrate!
- end
-
- describe '#up' do
- it 'schedules background jobs for each batch of projects' do
- expect(migration).to(
- have_scheduled_batched_migration(
- table_name: :project_mirror_data,
- column_name: :id,
- interval: described_class::INTERVAL,
- batch_size: described_class::BATCH_SIZE,
- sub_batch_size: described_class::SUB_BATCH_SIZE
- )
- )
- end
- end
-
- describe '#down' do
- before do
- schema_migrate_down!
- end
-
- it 'deletes all batched migration records' do
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/recount_epic_cache_counts_v3_spec.rb b/spec/migrations/recount_epic_cache_counts_v3_spec.rb
deleted file mode 100644
index 24b89ab30ca..00000000000
--- a/spec/migrations/recount_epic_cache_counts_v3_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe RecountEpicCacheCountsV3, :migration, feature_category: :portfolio_management do
- let(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- it 'schedules a batched background migration' do
- migrate!
-
- expect(migration).to have_scheduled_batched_migration(
- table_name: :epics,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL,
- batch_size: described_class::BATCH_SIZE,
- max_batch_size: described_class::MAX_BATCH_SIZE,
- sub_batch_size: described_class::SUB_BATCH_SIZE
- )
- end
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- migrate!
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/remove_flowdock_integration_records_spec.rb b/spec/migrations/remove_flowdock_integration_records_spec.rb
deleted file mode 100644
index 3f57515d18b..00000000000
--- a/spec/migrations/remove_flowdock_integration_records_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require Rails.root.join('db/post_migrate/20221129124240_remove_flowdock_integration_records.rb')
-
-RSpec.describe RemoveFlowdockIntegrationRecords, feature_category: :integrations do
- let(:integrations) { table(:integrations) }
-
- before do
- integrations.create!(type_new: 'Integrations::Flowdock')
- integrations.create!(type_new: 'SomeOtherType')
- end
-
- it 'removes integrations records of type_new Integrations::Flowdock' do
- expect(integrations.count).to eq(2)
-
- migrate!
-
- expect(integrations.count).to eq(1)
- expect(integrations.first.type_new).to eq('SomeOtherType')
- expect(integrations.where(type_new: 'Integrations::Flowdock')).to be_empty
- end
-end
diff --git a/spec/migrations/schedule_fixing_security_scan_statuses_spec.rb b/spec/migrations/schedule_fixing_security_scan_statuses_spec.rb
deleted file mode 100644
index f43f58d3be2..00000000000
--- a/spec/migrations/schedule_fixing_security_scan_statuses_spec.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe ScheduleFixingSecurityScanStatuses,
- :suppress_gitlab_schemas_validate_connection, :suppress_partitioning_routing_analyzer,
- feature_category: :vulnerability_management do
- let!(:namespaces) { table(:namespaces) }
- let!(:projects) { table(:projects) }
- let!(:pipelines) { table(:ci_pipelines, database: :ci) }
- let!(:builds) { table(:ci_builds, database: :ci) { |model| model.primary_key = :id } }
- let!(:security_scans) { table(:security_scans) }
-
- let!(:namespace) { namespaces.create!(name: "foo", path: "bar") }
- let!(:project) { projects.create!(namespace_id: namespace.id, project_namespace_id: namespace.id) }
- let!(:pipeline) do
- pipelines.create!(project_id: project.id, ref: 'master', sha: 'adf43c3a', status: 'success', partition_id: 100)
- end
-
- let!(:ci_build) { builds.create!(commit_id: pipeline.id, retried: false, type: 'Ci::Build', partition_id: 100) }
-
- let!(:security_scan_1) { security_scans.create!(build_id: ci_build.id, scan_type: 1, created_at: 91.days.ago) }
- let!(:security_scan_2) { security_scans.create!(build_id: ci_build.id, scan_type: 2) }
-
- let(:com?) { false }
- let(:dev_or_test_env?) { false }
- let(:migration) { described_class::MIGRATION }
-
- before do
- allow(::Gitlab).to receive(:com?).and_return(com?)
- allow(::Gitlab).to receive(:dev_or_test_env?).and_return(dev_or_test_env?)
-
- migrate!
- end
-
- describe '#up' do
- shared_examples_for 'scheduler for fixing the security scans status' do
- it 'schedules background job' do
- expect(migration).to have_scheduled_batched_migration(
- table_name: :security_scans,
- column_name: :id,
- interval: 2.minutes,
- batch_size: 10_000,
- max_batch_size: 50_000,
- sub_batch_size: 100,
- batch_min_value: security_scan_2.id
- )
- end
- end
-
- context 'when the migration does not run on GitLab.com or development environment' do
- it 'does not schedule the migration' do
- expect('FixSecurityScanStatuses').not_to have_scheduled_batched_migration
- end
- end
-
- context 'when the migration runs on GitLab.com' do
- let(:com?) { true }
-
- it_behaves_like 'scheduler for fixing the security scans status'
- end
-
- context 'when the migration runs on dev environment' do
- let(:dev_or_test_env?) { true }
-
- it_behaves_like 'scheduler for fixing the security scans status'
- end
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/second_recount_epic_cache_counts_spec.rb b/spec/migrations/second_recount_epic_cache_counts_spec.rb
deleted file mode 100644
index ab4357264be..00000000000
--- a/spec/migrations/second_recount_epic_cache_counts_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe SecondRecountEpicCacheCounts, :migration, feature_category: :portfolio_management do
- let(:migration) { described_class::MIGRATION }
-
- describe '#up' do
- it 'schedules a batched background migration' do
- migrate!
-
- expect(migration).to have_scheduled_batched_migration(
- table_name: :epics,
- column_name: :id,
- interval: described_class::DELAY_INTERVAL,
- batch_size: described_class::BATCH_SIZE,
- max_batch_size: described_class::MAX_BATCH_SIZE,
- sub_batch_size: described_class::SUB_BATCH_SIZE
- )
- end
- end
-
- describe '#down' do
- it 'deletes all batched migration records' do
- migrate!
- schema_migrate_down!
-
- expect(migration).not_to have_scheduled_batched_migration
- end
- end
-end
diff --git a/spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb b/spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb
deleted file mode 100644
index 02ecbe90ee0..00000000000
--- a/spec/migrations/set_email_confirmation_setting_before_removing_send_user_confirmation_email_column_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_migration!
-
-RSpec.describe SetEmailConfirmationSettingBeforeRemovingSendUserConfirmationEmailColumn,
- feature_category: :user_profile do
- let(:migration) { described_class.new }
- let(:application_settings_table) { table(:application_settings) }
-
- describe '#up' do
- context "when 'send_user_confirmation_email' is set to 'true'" do
- it "updates 'email_confirmation_setting' to '2' (hard)" do
- application_settings_table.create!(send_user_confirmation_email: true, email_confirmation_setting: 0)
-
- migration.up
-
- expect(application_settings_table.last.email_confirmation_setting).to eq 2
- end
- end
-
- context "when 'send_user_confirmation_email' is set to 'false'" do
- it "updates 'email_confirmation_setting' to '0' (off)" do
- application_settings_table.create!(send_user_confirmation_email: false, email_confirmation_setting: 0)
-
- migration.up
-
- expect(application_settings_table.last.email_confirmation_setting).to eq 0
- end
- end
- end
-
- describe '#down' do
- it "updates 'email_confirmation_setting' to default value: '0' (off)" do
- application_settings_table.create!(send_user_confirmation_email: true, email_confirmation_setting: 2)
-
- migration.down
-
- expect(application_settings_table.last.email_confirmation_setting).to eq 0
- end
- end
-end