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:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20210830085837_add_throttle_authenticated_git_lfs_columns.rb23
-rw-r--r--db/migrate/20210830140524_add_state_to_member.rb21
-rw-r--r--db/migrate/20210830154358_add_yaml_limit_constraints.rb25
-rw-r--r--db/migrate/20210831134840_add_package_file_id_channel_idx_to_packages_helm_file_metadata.rb17
-rw-r--r--db/migrate/20210831135249_add_installable_helm_pkgs_idx_to_packages.rb17
-rw-r--r--db/migrate/20210831203408_upsert_base_work_item_types.rb31
-rw-r--r--db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb18
-rw-r--r--db/migrate/20210902171406_add_latest_column_into_the_security_scans_table.rb13
-rw-r--r--db/migrate/20210902171808_set_default_job_token_scope_false.rb17
-rw-r--r--db/migrate/20210902184334_add_expire_access_tokens_to_doorkeeper_application.rb7
-rw-r--r--db/migrate/20210903054158_recreate_stage_issue_events_table_with_bigints.rb45
-rw-r--r--db/migrate/20210906100021_delete_project_namespace_trigger.rb31
-rw-r--r--db/migrate/20210907182337_add_group_id_fkey_for_user_group_callout.rb15
-rw-r--r--db/migrate/20210907182359_add_user_id_fkey_for_user_group_callout.rb15
-rw-r--r--db/migrate/20210908060951_add_dast_schedules_to_plan_limits.rb7
-rw-r--r--db/migrate/20210908061132_insert_dast_profile_schedules_plan_limits.rb27
-rw-r--r--db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb7
-rw-r--r--db/migrate/20210908140437_add_sidekiq_limits_to_application_settings.rb21
-rw-r--r--db/migrate/20210908185736_add_status_to_dependency_proxy_manifests.rb7
-rw-r--r--db/migrate/20210908185754_add_status_to_dependency_proxy_blobs.rb7
-rw-r--r--db/migrate/20210908195506_add_data_to_vulnerability_finding_evidence.rb7
-rw-r--r--db/migrate/20210909184349_add_index_package_id_id_on_package_files.rb17
-rw-r--r--db/migrate/20210910014741_add_dependency_proxy_ttl_group_policy_worker_capacity_to_application_settings.rb11
-rw-r--r--db/migrate/20210910015047_add_app_settings_dep_proxy_ttl_worker_capacity_check_constraint.rb15
-rw-r--r--db/migrate/20210910141043_change_ci_minutes_additional_pack_text_limit.rb15
-rw-r--r--db/migrate/20210910192921_add_report_type_into_approval_project_rules.rb11
-rw-r--r--db/migrate/20210912034903_add_runner_features_to_ci_builds_metadata.rb9
-rw-r--r--db/migrate/20210913010411_create_agent_project_authorizations.rb14
-rw-r--r--db/migrate/20210913010432_add_agent_project_authorizations_foreign_keys.rb20
-rw-r--r--db/migrate/20210913122457_add_namespace_traversal_ids_to_ci_pending_builds.rb9
-rw-r--r--db/migrate/20210913224558_update_dependency_proxy_manifests_uniqueness_constraint.rb18
-rw-r--r--db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb13
-rw-r--r--db/migrate/20210914172202_add_status_index_to_dependency_proxy_tables.rb18
-rw-r--r--db/migrate/20210915000453_add_index_on_clusters_integration_prometheus_enabled.rb15
-rw-r--r--db/migrate/20210915001242_add_index_on_clusters_integration_elastic_stack_enabled.rb15
-rw-r--r--db/migrate/20210915070423_add_avatar_and_description_to_topic.rb15
-rw-r--r--db/migrate/20210916132547_add_process_mode_to_resource_groups.rb15
-rw-r--r--db/migrate/20210917134321_remove_temporary_index_for_project_topics_on_taggings.rb20
-rw-r--r--db/migrate/20210917153645_remove_pipeline_fk_from_packages_build_infos.rb15
-rw-r--r--db/migrate/20210917153905_remove_pipeline_fk_from_packages_package_file_build_infos.rb15
-rw-r--r--db/migrate/20210917224419_add_registration_objective_to_user_detail.rb7
-rw-r--r--db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb15
-rw-r--r--db/migrate/20210921032008_add_suggest_pipeline_enabled_to_application_settings.rb7
-rw-r--r--db/migrate/20210921063924_index_labels_using_varchar_pattern_ops.rb39
-rw-r--r--db/migrate/20210921191010_add_report_type_index_into_approval_project_rules.rb15
-rw-r--r--db/migrate/20210922172056_add_unique_namespaces_index_on_name_parent_id_and_type.rb15
-rw-r--r--db/migrate/20210922172156_drop_unique_namespaces_index_on_name_and_parent_id.rb15
-rw-r--r--db/migrate/20210922215740_create_issue_customer_relations_contacts.rb14
-rw-r--r--db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb20
-rw-r--r--db/migrate/20210923042323_add_meta_data_to_user_credit_card_validations.rb13
-rw-r--r--db/migrate/20210923042324_limit_holder_name_on_user_credit_card_validations.rb23
-rw-r--r--db/migrate/20210923042325_index_meta_data_on_user_credit_card_validations.rb19
-rw-r--r--db/migrate/20210923151641_change_default_for_integrated_error_tracking.rb11
-rw-r--r--db/migrate/20210928155022_improve_index_for_error_tracking.rb33
-rw-r--r--db/migrate/20210928171122_add_group_id_status_id_index_to_dependency_proxy_tables.rb18
-rw-r--r--db/migrate/20210929025600_add_phone_to_user_details.rb15
-rw-r--r--db/migrate/20210929030834_add_text_limit_to_user_details_phone.rb13
-rw-r--r--db/migrate/20210929031049_add_unique_index_phone_on_user_details.rb15
-rw-r--r--db/migrate/20210929032555_create_verification_codes.rb36
-rw-r--r--db/migrate/20210929115340_add_security_policy_configurations_management_project_id_foreign_key.rb18
-rw-r--r--db/migrate/20210929121516_add_releases_author_id_id_created_at_index.rb14
-rw-r--r--db/migrate/20210929144453_add_warn_about_potentially_unwanted_characters_to_project_settings.rb16
-rw-r--r--db/migrate/20210930081208_fix_deprecated_api_throttle_defaults.rb8
-rw-r--r--db/migrate/20211001001222_add_source_version_to_bulk_imports.rb7
-rw-r--r--db/migrate/20211004062942_create_coverage_fuzzing_corpuses.rb18
-rw-r--r--db/migrate/20211004075629_add_topics_name_gin_index.rb15
-rw-r--r--db/migrate/20211004081911_add_external_event_destination_limit_to_plan_limits.rb7
-rw-r--r--db/migrate/20211004122540_create_member_tasks.rb13
-rw-r--r--db/migrate/20211005063519_add_foreign_key_to_corpuses_on_project.rb15
-rw-r--r--db/migrate/20211005063616_add_foreign_key_to_corpuses_on_user.rb15
-rw-r--r--db/migrate/20211005063723_add_foreign_key_to_corpuses_on_package.rb15
-rw-r--r--db/migrate/20211005092428_drop_time_range_partitioned_loose_fk.rb27
-rw-r--r--db/migrate/20211005093558_add_range_partitioned_loose_fk_table.rb29
-rw-r--r--db/migrate/20211005100112_recreate_loose_fk_insert_function.rb40
-rw-r--r--db/migrate/20211005112404_add_member_id_foreign_key_to_member_tasks.rb15
-rw-r--r--db/migrate/20211005112645_add_project_id_foreign_key_to_member_tasks.rb15
-rw-r--r--db/migrate/20211006060254_add_topics_total_projects_count_cache.rb11
-rw-r--r--db/migrate/20211006103122_change_helm_channel_length.rb14
-rw-r--r--db/migrate/20211006122010_add_topics_total_projects_count_index.rb15
-rw-r--r--db/migrate/20211007090229_create_issue_search_table.rb29
-rw-r--r--db/migrate/20211007113136_add_status_column_to_security_scans_table.rb7
-rw-r--r--db/migrate/20211008043855_remove_notes_trigram_index.rb15
-rw-r--r--db/migrate/20211008181451_add_shared_runners_duration_to_ci_namespace_monthly_usages.rb9
-rw-r--r--db/migrate/20211008182954_add_shared_runners_duration_to_ci_project_monthly_usages.rb9
-rw-r--r--db/migrate/20211008193137_add_health_status_column_on_clusters_integration_prometheus.rb8
-rw-r--r--db/migrate/20211011004242_create_content_blocked_states.rb15
-rw-r--r--db/migrate/20211011140930_create_ci_namespace_mirrors.rb15
-rw-r--r--db/migrate/20211011140931_create_ci_project_mirrors.rb12
-rw-r--r--db/migrate/20211011140932_create_namespaces_sync_events.rb9
-rw-r--r--db/migrate/20211011141239_create_projects_sync_events.rb9
-rw-r--r--db/migrate/20211011141242_create_namespaces_sync_trigger.rb37
-rw-r--r--db/migrate/20211011141243_create_projects_sync_trigger.rb37
-rw-r--r--db/migrate/20211012015903_next_traversal_ids_sibling_function.rb30
-rw-r--r--db/migrate/20211012091822_add_text_limit_to_bulk_imports_source_version.rb13
-rw-r--r--db/migrate/20211012134316_clean_up_migrate_merge_request_diff_commit_users.rb35
-rw-r--r--db/migrate/20211013014228_add_content_validation_endpoint_to_application_settings.rb20
-rw-r--r--db/migrate/20211013080714_add_network_to_user_credit_card_validations.rb9
-rw-r--r--db/migrate/20211013080715_limit_network_on_user_credit_card_validations.rb13
-rw-r--r--db/migrate/20211013080716_index_include_network_on_user_credit_card_validations.rb17
-rw-r--r--db/migrate/20211013192749_add_states_into_approval_project_rules.rb11
-rw-r--r--db/migrate/20211015021114_add_merge_commit_template_to_project_settings.rb9
-rw-r--r--db/migrate/20211015024135_add_merge_commit_template_limit_to_project_settings.rb13
-rw-r--r--db/migrate/20211018101034_add_tmp_project_id_column_to_namespaces.rb11
-rw-r--r--db/migrate/20211018161447_fix_double_entries_in_postgres_index_view.rb59
-rw-r--r--db/migrate/20211019153615_add_state_to_merge_request_assignees.rb8
-rw-r--r--db/migrate/20211020030948_add_runtime_runner_features_to_ci_builds_metadata.rb9
-rw-r--r--db/migrate/20211020095357_add_group_traversal_id_index.rb15
-rw-r--r--db/migrate/20211021115409_add_color_to_epics.rb10
-rw-r--r--db/migrate/20211021124715_add_text_limit_to_epics_color.rb13
-rw-r--r--db/migrate/20211021125908_add_sentry_settings_to_application_settings.rb12
-rw-r--r--db/migrate/20211021134458_add_limits_to_sentry_settings_on_application_settings.rb17
-rw-r--r--db/migrate/20211025103744_add_state_id_to_vsa_issue_stage_events.rb7
-rw-r--r--db/migrate/20211025103758_add_state_id_to_vsa_merge_request_stage_events.rb7
-rw-r--r--db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb7
-rw-r--r--db/migrate/20211026143238_remove_index_releases_on_author_id.rb15
-rw-r--r--db/migrate/20211027203950_add_updated_index_for_dormant_users.rb17
-rw-r--r--db/migrate/20211028132247_create_packages_npm_metadata.rb22
-rw-r--r--db/migrate/20211028212259_add_default_to_personal_access_tokens_prefix.rb7
-rw-r--r--db/migrate/20211101132310_add_reindexing_queue.rb16
-rw-r--r--db/migrate/20211101165656_create_upload_states.rb32
-rw-r--r--db/migrate/20211103062728_add_with_highest_role_minimal_access_to_users_statistics.rb7
-rw-r--r--db/migrate/20211104012209_add_text_limit_to_application_settings_content_validation_endpoint_url.rb13
-rw-r--r--db/migrate/20211105010101_add_archived_column_to_deployments.rb9
-rw-r--r--db/migrate/20211105125756_add_read_at_to_dependency_proxy_manifests.rb7
-rw-r--r--db/migrate/20211105125813_add_read_at_to_dependency_proxy_blobs.rb7
-rw-r--r--db/migrate/20211105160316_create_dotenv_application_limits.rb8
-rw-r--r--db/migrate/20211105161404_insert_dotenv_application_limits.rb27
-rw-r--r--db/migrate/20211108154510_create_pipeline_triggers_application_limits.rb7
-rw-r--r--db/migrate/20211108154841_insert_pipeline_triggers_application_limits.rb23
-rw-r--r--db/migrate/20211108203248_update_dependency_proxy_indexes_with_read_at.rb27
-rw-r--r--db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb9
-rw-r--r--db/migrate/20211108211434_remove_index_for_resource_group.rb17
-rw-r--r--db/migrate/20211109100050_add_consume_after_to_loose_fk_deleted_records.rb13
-rw-r--r--db/migrate/20211109101010_support_partition_query_in_loose_fk_table.rb20
-rw-r--r--db/migrate/20211110010101_add_index_on_unarchived_deployments.rb15
-rw-r--r--db/migrate/20211110014701_create_agent_activity_events.rb22
-rw-r--r--db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb35
-rw-r--r--db/migrate/20211110092710_create_issue_emails.rb21
-rw-r--r--db/migrate/20211110100050_add_has_shimo_to_project_settings.rb9
-rw-r--r--db/migrate/20211111112425_create_merge_requests_compliance_violations.rb13
-rw-r--r--db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb18
-rw-r--r--db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb18
-rw-r--r--db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb9
-rw-r--r--db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb13
-rw-r--r--db/migrate/20211112073413_change_package_index_on_corpus.rb19
-rw-r--r--db/migrate/20211112155416_populate_default_value_for_personal_access_tokens_prefix.rb20
-rw-r--r--db/migrate/20211115132613_create_incident_management_timeline_events.rb30
-rw-r--r--db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb15
-rw-r--r--db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb15
-rw-r--r--db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb15
-rw-r--r--db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb17
-rw-r--r--db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb17
-rw-r--r--db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb15
-rw-r--r--db/migrate/20211117174209_create_vulnerability_reads.rb24
-rw-r--r--db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb9
-rw-r--r--db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb40
-rw-r--r--db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb7
-rw-r--r--db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb15
-rw-r--r--db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb15
-rw-r--r--db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb15
-rw-r--r--db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb16
-rw-r--r--db/migrate/20211119111006_create_job_artifact_states.rb32
-rw-r--r--db/migrate/20211119154221_create_pages_deployment_states.rb38
-rw-r--r--db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb16
-rw-r--r--db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb7
-rw-r--r--db/migrate/20211119195201_create_deployment_approvals.rb13
-rw-r--r--db/migrate/20211122103051_add_line_code_to_draft_notes.rb10
-rw-r--r--db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb9
-rw-r--r--db/migrate/20211123135255_create_batched_background_migration_job_transition_logs.rb38
-rw-r--r--db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb15
-rw-r--r--db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb7
-rw-r--r--db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb13
-rw-r--r--db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb14
-rw-r--r--db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb14
-rw-r--r--db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb12
-rw-r--r--db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb31
-rw-r--r--db/migrate/20211126142200_add_encrypted_static_object_token.rb16
-rw-r--r--db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb13
-rw-r--r--db/migrate/20211126204445_add_task_to_work_item_types.rb31
-rw-r--r--db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb7
-rw-r--r--db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb15
-rw-r--r--db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb15
-rw-r--r--db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb18
-rw-r--r--db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb7
-rw-r--r--db/migrate/20211201143042_create_lfs_object_states.rb32
-rw-r--r--db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb15
-rw-r--r--db/migrate/20211202041233_init_schema.rb (renamed from db/migrate/20210826171758_init_schema.rb)2
-rw-r--r--db/migrate/20221225010101_create_workspaces_table.rb44
-rw-r--r--db/migrate/20221225010102_create_workspaces_user_foreign_key.rb18
-rw-r--r--db/migrate/20221225010103_create_workspaces_project_foreign_key.rb18
-rw-r--r--db/migrate/20221225010104_create_workspaces_cluster_agent_foreign_key.rb18
-rw-r--r--db/migrate/20221225010105_create_remote_development_agent_configs_table.rb16
-rw-r--r--db/migrate/20221225010106_create_remote_development_agent_config_agent_foreign_key.rb16
-rw-r--r--db/migrate/20221229172604_add_runner_registration_enabled_to_project_settings.rb9
-rw-r--r--db/migrate/20230113164245_create_namespace_ldap_settings.rb16
-rw-r--r--db/migrate/20230118135145_add_service_desk_custom_email_verifications.rb24
-rw-r--r--db/migrate/20230127024835_add_database_apdex_settings_to_application_settings.rb7
-rw-r--r--db/migrate/20230127030015_add_deny_all_outgoing_requests_to_application_settings.rb9
-rw-r--r--db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb56
-rw-r--r--db/migrate/20230201165656_create_container_repository_states.rb44
-rw-r--r--db/migrate/20230202094723_add_default_syntax_highlighting_theme_to_application_settings.rb7
-rw-r--r--db/migrate/20230207002330_add_project_group_link_on_delete_cascade_fk.rb21
-rw-r--r--db/migrate/20230210152109_add_bulk_import_export_batches.rb21
-rw-r--r--db/migrate/20230210153420_add_batched_column_to_bulk_import_exports.rb9
-rw-r--r--db/migrate/20230210155715_add_batch_id_to_bulk_import_export_uploads.rb7
-rw-r--r--db/migrate/20230210160037_add_batch_foreign_key_to_bulk_import_export_uploads.rb15
-rw-r--r--db/migrate/20230210160351_add_bulk_import_batch_trackers.rb22
-rw-r--r--db/migrate/20230210161002_add_batched_column_to_bulk_import_trackers.rb7
-rw-r--r--db/migrate/20230210171012_add_batch_id_index_to_bulk_import_export_uploads.rb15
-rw-r--r--db/migrate/20230213213559_add_index_on_project_id_and_scanner_id_and_vulnerability_id_on_vulnerability_reads.rb15
-rw-r--r--db/migrate/20230215074223_add_ci_runner_machine_builds_partitioned_table.rb30
-rw-r--r--db/migrate/20230215124011_add_provisioned_by_group_at_to_user_details.rb9
-rw-r--r--db/migrate/20230215131026_add_has_failures_column_to_bulk_imports.rb7
-rw-r--r--db/migrate/20230215180605_index_sbom_occurrences_on_project_id_and_id.rb15
-rw-r--r--db/migrate/20230216040505_add_status_and_resolved_at_to_abuse_reports.rb8
-rw-r--r--db/migrate/20230216071312_add_status_category_and_id_index_to_abuse_reports.rb15
-rw-r--r--db/migrate/20230216142836_update_vulnerability_reads_trigger_to_set_has_issue.rb185
-rw-r--r--db/migrate/20230216144719_drop_table_airflow_dags.rb22
-rw-r--r--db/migrate/20230216152912_add_has_failures_column_to_bulk_import_entities.rb7
-rw-r--r--db/migrate/20230216171309_create_ci_runner_cost_settings.rb17
-rw-r--r--db/migrate/20230217065736_add_projects_api_rate_limit_unauthenticated_to_application_settings.rb7
-rw-r--r--db/migrate/20230217144421_add_check_type_to_pre_scan_step.rb11
-rw-r--r--db/migrate/20230217232554_add_state_changed_in_to_vulnerability_state_transitions.rb11
-rw-r--r--db/migrate/20230220035034_add_status_and_id_index_to_abuse_reports.rb15
-rw-r--r--db/migrate/20230220163141_create_catalog_resources_table.rb11
-rw-r--r--db/migrate/20230221110256_create_initial_partition_for_ci_runner_machine_builds.rb49
-rw-r--r--db/migrate/20230222153048_add_registry_size_estimated_to_namespace_root_storage_statistics.rb21
-rw-r--r--db/migrate/20230222161226_add_custom_jira_regex_to_jira_tracker_data.rb12
-rw-r--r--db/migrate/20230222161954_add_text_limit_to_custom_jira_regex_fields.rb15
-rw-r--r--db/migrate/20230222193845_change_public_projects_minutes_cost_factor_default_to_1.rb17
-rw-r--r--db/migrate/20230224130315_add_constraint_type_to_postgres_async_constraint_validation.rb7
-rw-r--r--db/migrate/20230224161346_add_saml_group_lock_to_application_settings.rb7
-rw-r--r--db/migrate/20230228092612_add_index_next_over_limit_check_at_asc_order_synchronously.rb17
-rw-r--r--db/migrate/20230228133011_add_design_description.rb18
-rw-r--r--db/migrate/20230228135034_add_design_description_limit.rb13
-rw-r--r--db/migrate/20230228142350_add_notifications_work_item_widget.rb57
-rw-r--r--db/migrate/20230228183644_add_partitioning_info_to_postgres_foreign_keys.rb90
-rw-r--r--db/migrate/20230228212427_add_index_user_details_on_user_id_for_enterprise_users_without_date.rb19
-rw-r--r--db/migrate/20230228212905_add_index_user_details_on_user_id_for_enterprise_users_with_date.rb19
-rw-r--r--db/migrate/20230303144424_unique_index_on_catalog_resources_project.rb17
-rw-r--r--db/migrate/20230303232426_add_role_approvers_to_scan_result_policies.rb9
-rw-r--r--db/migrate/20230306145230_add_product_analytics_data_collector_host_to_application_settings.rb9
-rw-r--r--db/migrate/20230307000000_create_design_management_repository.rb11
-rw-r--r--db/migrate/20230307091216_add_status_reporter_id_and_id_index_to_abuse_reports.rb15
-rw-r--r--db/migrate/20230307122838_add_text_limit_to_application_settings_product_analytics_data_collector_host.rb13
-rw-r--r--db/migrate/20230307132729_create_schema_inconsistencies.rb15
-rw-r--r--db/migrate/20230307212637_remove_create_learn_gitlab_worker_job_instances.rb11
-rw-r--r--db/migrate/20230307233631_add_public_runner_release_version_fetch_setting.rb14
-rw-r--r--db/migrate/20230308154243_add_package_id_to_ml_candidates.rb7
-rw-r--r--db/migrate/20230308154244_add_package_id_foreign_key_to_ml_candidates.rb15
-rw-r--r--db/migrate/20230308154245_add_index_on_package_id_for_ml_candidates.rb15
-rw-r--r--db/migrate/20230308163018_create_container_registry_data_repair_details.rb17
-rw-r--r--db/migrate/20230309000957_add_external_identifiers_to_import_failures.rb9
-rw-r--r--db/migrate/20230313012226_create_search_indices.rb18
-rw-r--r--db/migrate/20230313012609_create_search_namespace_index_assignments.rb26
-rw-r--r--db/migrate/20230313014038_add_search_index_foreign_key_to_search_namespace_index_assignments.rb18
-rw-r--r--db/migrate/20230313031351_create_resource_link_events.rb15
-rw-r--r--db/migrate/20230313054226_add_status_created_at_and_updated_at_indexes_to_abuse_reports.rb18
-rw-r--r--db/migrate/20230313092109_add_start_end_and_current_values_to_wi_progressess.rb11
-rw-r--r--db/migrate/20230313100920_add_gitlab_dedicated_instance_to_application_settings.rb9
-rw-r--r--db/migrate/20230313181536_create_packages_npm_metadata_caches.rb26
-rw-r--r--db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb16
-rw-r--r--db/migrate/20230315053635_add_screenshot_to_abuse_reports.rb10
-rw-r--r--db/migrate/20230316093433_insert_daily_invites_trial_plan_limits.rb19
-rw-r--r--db/migrate/20230316095948_create_service_desk_custom_email_credentials.rb22
-rw-r--r--db/migrate/20230317162059_add_current_user_todos_work_item_widget.rb57
-rw-r--r--db/migrate/20230321085011_add_column_to_users_statistisc.rb7
-rw-r--r--db/migrate/20230321113956_add_indexes_to_merge_request_compliance_violations.rb29
-rw-r--r--db/migrate/20230321153304_rename_ml_candidates_iid_to_eid.rb13
-rw-r--r--db/migrate/20230321161218_add_project_access_token_limit_to_plan_limits.rb7
-rw-r--r--db/migrate/20230321161441_insert_project_access_token_limit.rb15
-rw-r--r--db/migrate/20230321162810_add_project_id_to_ml_candidates.rb9
-rw-r--r--db/migrate/20230321162902_add_index_on_project_id_on_ml_candidates.rb15
-rw-r--r--db/migrate/20230321163051_add_project_id_foreign_key_to_ml_candidates.rb15
-rw-r--r--db/migrate/20230321170734_add_internal_id_to_ml_candidates.rb7
-rw-r--r--db/migrate/20230321170803_add_index_on_project_id_on_internal_id_to_ml_candidates.rb15
-rw-r--r--db/migrate/20230322145403_add_project_id_foreign_key_to_packages_npm_metadata_caches.rb19
-rw-r--r--db/migrate/20230322151605_rerun_remove_invalid_deploy_access_level.rb26
-rw-r--r--db/migrate/20230322162512_add_valid_deploy_access_level_constraint.rb16
-rw-r--r--db/migrate/20230322164031_create_design_management_repository_states.rb41
-rw-r--r--db/migrate/20230323021618_add_silent_mode_enabled_to_application_settings.rb7
-rw-r--r--db/migrate/20230323101138_add_award_emoji_work_item_widget.rb57
-rw-r--r--db/migrate/20230323120601_create_dora_performance_scores.rb16
-rw-r--r--db/migrate/20230323140745_add_root_directory_to_pages_deployment.rb10
-rw-r--r--db/migrate/20230323140746_add_text_limit_to_pages_deployment_root_directory.rb13
-rw-r--r--db/migrate/20230323153042_track_push_rules_deletions.rb15
-rw-r--r--db/migrate/20230323153328_track_tags_deletions.rb15
-rw-r--r--db/migrate/20230323191750_add_shard_settings_to_search_indices.rb8
-rw-r--r--db/migrate/20230327074932_add_text_limit_to_abuse_reports_screenshot.rb13
-rw-r--r--db/migrate/20230327123333_backfill_product_analytics_data_collector_host.rb20
-rw-r--r--db/migrate/20230328020316_delete_unused_index_on_merge_requests_on_state_id_and_merge_status.rb17
-rw-r--r--db/migrate/20230328023535_initialize_conversion_of_award_emoji_awardable_id_to_bigint.rb16
-rw-r--r--db/migrate/20230328031720_initialize_conversion_of_events_target_id_to_bigint.rb16
-rw-r--r--db/migrate/20230328165313_add_disabled_following_to_user_preferences.rb9
-rw-r--r--db/migrate/20230329032129_add_lock_version_to_terraform_state.rb9
-rw-r--r--db/migrate/20230329085754_add_foreign_key_to_resource_link_events_on_user.rb15
-rw-r--r--db/migrate/20230329152410_add_achievements_enabled_to_user_preferences.rb9
-rw-r--r--db/migrate/20230329194244_add_index_packages_debian_file_metadata_when_unknown.rb17
-rw-r--r--db/migrate/20230330101438_create_fk_ml_candidate_params_on_candidate_id.rb29
-rw-r--r--db/migrate/20230330101439_validate_fk_ml_candidate_params_on_candidate_id.rb13
-rw-r--r--db/migrate/20230330101440_remove_old_fk_ml_candidate_params_on_candidate_id.rb21
-rw-r--r--db/migrate/20230330101441_create_fk_ml_candidate_metrics_on_candidate_id.rb29
-rw-r--r--db/migrate/20230330101442_validate_fk_ml_candidate_metrics_on_candidate_id.rb13
-rw-r--r--db/migrate/20230330101443_remove_old_fk_ml_candidate_metrics_on_candidate_id.rb21
-rw-r--r--db/migrate/20230330215636_remove_unused_project_jira_indexes.rb34
-rw-r--r--db/migrate/20230331142006_add_open_ai_api_key_application_setting.rb8
-rw-r--r--db/migrate/20230403023440_add_database_max_running_batched_background_migrations_to_application_settings.rb8
-rw-r--r--db/migrate/20230403023441_set_max_running_batched_background_migrations_for_gitlab_com.rb17
-rw-r--r--db/migrate/20230403093349_ensure_packages_npm_metadata_caches_is_empty.rb13
-rw-r--r--db/migrate/20230403113620_add_pinned_nav_items_to_user_preference.rb9
-rw-r--r--db/migrate/20230403145705_add_purl_sync_to_settings.rb7
-rw-r--r--db/migrate/20230403164454_add_fork_storage_size_columns_to_root_storage_statistics.rb11
-rw-r--r--db/migrate/20230404111427_add_first_contribution_to_merge_request_metrics.rb9
-rw-r--r--db/migrate/20230404160131_add_status_to_data_repair_details.rb20
-rw-r--r--db/migrate/20230405071033_add_object_storage_key_to_packages_npm_metadata_caches.rb25
-rw-r--r--db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb25
-rw-r--r--db/migrate/20230406040908_add_system_note_metadata_id__to_resource_link_events.rb7
-rw-r--r--db/migrate/20230406042906_add_unique_index_to_resource_link_events_on_system_note_metadata_id.rb15
-rw-r--r--db/migrate/20230406043900_add_system_note_metadata_foreign_key_to_resource_link_events.rb16
-rw-r--r--db/migrate/20230406060452_create_instance_external_audit_event_destinations.rb14
-rw-r--r--db/migrate/20230406073847_validate_foreign_key_for_resource_link_events_on_system_note_metadata_id.rb11
-rw-r--r--db/migrate/20230406095544_add_pa_configurator_base_to_app_settings.rb13
-rw-r--r--db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb9
-rw-r--r--db/migrate/20230406150254_create_agent_user_access_project_authorizations_table.rb17
-rw-r--r--db/migrate/20230406150354_create_agent_user_access_group_authorizations_table.rb17
-rw-r--r--db/migrate/20230406150454_add_fks_to_agent_user_access_authorizations.rb34
-rw-r--r--db/migrate/20230407164616_add_code_suggestions_to_namespace_settings.rb9
-rw-r--r--db/migrate/20230410092450_add_product_analytics_instrumentation_key_to_project_settings.rb21
-rw-r--r--db/migrate/20230411171001_create_abuse_trust_scores.rb16
-rw-r--r--db/migrate/20230411205121_create_package_metadata_advisory_info.rb39
-rw-r--r--db/migrate/20230412073614_create_issue_assignment_events.rb14
-rw-r--r--db/migrate/20230412080242_add_concurrent_fk_to_issue_assignment_events.rb16
-rw-r--r--db/migrate/20230412151659_add_ci_job_artifacts_file_final_path.rb12
-rw-r--r--db/migrate/20230412185920_validate_ci_job_artifacts_file_final_path.rb11
-rw-r--r--db/migrate/20230413080906_create_merge_request_assignment_events.rb15
-rw-r--r--db/migrate/20230413080918_add_concurrent_fk_to_merge_request_assignment_events.rb16
-rw-r--r--db/migrate/20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb13
-rw-r--r--db/migrate/20230414190012_add_product_analytics_to_project_settings.rb45
-rw-r--r--db/migrate/20230414230535_add_external_identifiers_index_to_import_failures.rb.rb16
-rw-r--r--db/migrate/20230417145900_add_visibility_pipeline_id_type_to_user_preferences.rb7
-rw-r--r--db/migrate/20230418183540_create_project_states.rb44
-rw-r--r--db/migrate/20230418215853_add_assignee_widget_to_incidents.rb48
-rw-r--r--db/migrate/20230419105225_remove_phabricator_from_application_settings.rb29
-rw-r--r--db/migrate/20230419130952_remove_github_import_job_instances.rb11
-rw-r--r--db/migrate/20230419192748_add_bot_user_id_to_security_orchestration_policy_configurations.rb7
-rw-r--r--db/migrate/20230419193807_add_foreign_key_for_bot_user_id_to_security_orchestration_policy_configurations.rb24
-rw-r--r--db/migrate/20230420012220_create_organizations.rb9
-rw-r--r--db/migrate/20230420040912_initialize_conversion_of_ci_pipelines.rb16
-rw-r--r--db/migrate/20230420115733_add_ai_settings_to_namespace_settings.rb10
-rw-r--r--db/migrate/20230420131608_add_partitioned_vsd_counts_table.rb26
-rw-r--r--db/migrate/20230420132910_create_ci_ai_conversation.rb31
-rw-r--r--db/migrate/20230421035557_create_note_metadata.rb18
-rw-r--r--db/migrate/20230421081907_add_auth_type_to_jira_tracker_data.rb9
-rw-r--r--db/migrate/20230421124302_epic_boards_show_colors.rb7
-rw-r--r--db/migrate/20230421165020_add_ci_max_includes_to_application_settings.rb7
-rw-r--r--db/migrate/20230424094117_add_read_vulnerability_to_member_roles.rb7
-rw-r--r--db/migrate/20230424122236_add_ci_build_id_to_ml_candidate.rb7
-rw-r--r--db/migrate/20230424131551_add_index_on_ci_build_id_to_ml_candidates.rb15
-rw-r--r--db/migrate/20230424155321_add_licenses_field_to_package_metadata_packages.rb9
-rw-r--r--db/migrate/20230424194721_add_tofa_application_settings.rb30
-rw-r--r--db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb11
-rw-r--r--db/migrate/20230425173111_create_merge_request_diff_llm_summary.rb16
-rw-r--r--db/migrate/20230426102200_fix_import_sources_on_application_settings_after_phabricator_removal.rb26
-rw-r--r--db/migrate/20230426161259_add_user_foreign_key_to_merge_request_diff_llm_summary.rb18
-rw-r--r--db/migrate/20230426161341_add_merge_request_diff_foreign_key_to_merge_request_diff_llm_summary.rb19
-rw-r--r--db/migrate/20230427065641_initialize_conversion_of_ci_pipeline_variables.rb16
-rw-r--r--db/migrate/20230427094534_create_analytics_value_stream_dashboard_aggregations.rb14
-rw-r--r--db/migrate/20230428101217_create_abuse_report_events.rb14
-rw-r--r--db/migrate/20230428134334_delete_create_cross_project_pipeline_worker_job_instances.rb16
-rw-r--r--db/migrate/20230501111636_add_users_fk_to_abuse_report_events.rb18
-rw-r--r--db/migrate/20230501163253_add_remember_me_enabled_to_application_settings.rb7
-rw-r--r--db/migrate/20230502083003_add_abuse_reports_fk_to_abuse_report_events.rb18
-rw-r--r--db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb19
-rw-r--r--db/migrate/20230503191056_add_text_limit_to_packages_npm_metadata_caches_object_storage_key.rb13
-rw-r--r--db/migrate/20230504084524_remove_gitlab_import_source.rb32
-rw-r--r--db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb8
-rw-r--r--db/migrate/20230505122015_add_lock_version_to_milestones.rb9
-rw-r--r--db/migrate/20230507192028_create_audit_events_google_cloud_logging_configurations.rb23
-rw-r--r--db/migrate/20230508074515_add_google_cloud_logging_configuration_limit_to_plan_limits.rb7
-rw-r--r--db/migrate/20230509072635_drop_unused_sequence_by_recreating_vsa_table.rb24
-rw-r--r--db/migrate/20230509085428_change_organizations_sequence.rb12
-rw-r--r--db/migrate/20230509115525_add_name_to_organization.rb20
-rw-r--r--db/migrate/20230509131736_add_default_organization.rb16
-rw-r--r--db/migrate/20230509144234_delete_drop_older_deployments_worker_queues.rb16
-rw-r--r--db/migrate/20230515111314_add_text_limit_on_organization_name.rb13
385 files changed, 3608 insertions, 3103 deletions
diff --git a/db/migrate/20210830085837_add_throttle_authenticated_git_lfs_columns.rb b/db/migrate/20210830085837_add_throttle_authenticated_git_lfs_columns.rb
deleted file mode 100644
index bc515bc061c..00000000000
--- a/db/migrate/20210830085837_add_throttle_authenticated_git_lfs_columns.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-class AddThrottleAuthenticatedGitLfsColumns < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- disable_ddl_transaction!
-
- def up
- with_lock_retries do
- add_column :application_settings, :throttle_authenticated_git_lfs_requests_per_period, :integer, default: 1000, null: false
- add_column :application_settings, :throttle_authenticated_git_lfs_period_in_seconds, :integer, default: 60, null: false
- add_column :application_settings, :throttle_authenticated_git_lfs_enabled, :boolean, default: false, null: false
- end
- end
-
- def down
- with_lock_retries do
- remove_column :application_settings, :throttle_authenticated_git_lfs_requests_per_period
- remove_column :application_settings, :throttle_authenticated_git_lfs_period_in_seconds
- remove_column :application_settings, :throttle_authenticated_git_lfs_enabled, :boolean
- end
- end
-end
diff --git a/db/migrate/20210830140524_add_state_to_member.rb b/db/migrate/20210830140524_add_state_to_member.rb
deleted file mode 100644
index 6009376badb..00000000000
--- a/db/migrate/20210830140524_add_state_to_member.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-class AddStateToMember < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- def up
- unless column_exists?(:members, :state)
- with_lock_retries do
- add_column :members, :state, :integer, limit: 2, default: 0
- end
- end
- end
-
- def down
- if column_exists?(:members, :state)
- with_lock_retries do
- remove_column :members, :state
- end
- end
- end
-end
diff --git a/db/migrate/20210830154358_add_yaml_limit_constraints.rb b/db/migrate/20210830154358_add_yaml_limit_constraints.rb
deleted file mode 100644
index 74236993fff..00000000000
--- a/db/migrate/20210830154358_add_yaml_limit_constraints.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-# See https://docs.gitlab.com/ee/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class AddYamlLimitConstraints < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- SIZE_CONSTRAINT_NAME = 'app_settings_yaml_max_size_positive'
- DEPTH_CONSTRAINT_NAME = 'app_settings_yaml_max_depth_positive'
-
- disable_ddl_transaction!
-
- def up
- add_check_constraint :application_settings, 'max_yaml_size_bytes > 0', SIZE_CONSTRAINT_NAME
- add_check_constraint :application_settings, 'max_yaml_depth > 0', DEPTH_CONSTRAINT_NAME
- end
-
- def down
- remove_check_constraint :application_settings, SIZE_CONSTRAINT_NAME
- remove_check_constraint :application_settings, DEPTH_CONSTRAINT_NAME
- end
-end
diff --git a/db/migrate/20210831134840_add_package_file_id_channel_idx_to_packages_helm_file_metadata.rb b/db/migrate/20210831134840_add_package_file_id_channel_idx_to_packages_helm_file_metadata.rb
deleted file mode 100644
index a3366bd9ddb..00000000000
--- a/db/migrate/20210831134840_add_package_file_id_channel_idx_to_packages_helm_file_metadata.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class AddPackageFileIdChannelIdxToPackagesHelmFileMetadata < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_packages_helm_file_metadata_on_pf_id_and_channel'
-
- def up
- add_concurrent_index :packages_helm_file_metadata, [:package_file_id, :channel], name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index :packages_helm_file_metadata, [:package_file_id, :channel], name: INDEX_NAME
- end
-end
diff --git a/db/migrate/20210831135249_add_installable_helm_pkgs_idx_to_packages.rb b/db/migrate/20210831135249_add_installable_helm_pkgs_idx_to_packages.rb
deleted file mode 100644
index 5e65b5c0fe1..00000000000
--- a/db/migrate/20210831135249_add_installable_helm_pkgs_idx_to_packages.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class AddInstallableHelmPkgsIdxToPackages < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- disable_ddl_transaction!
-
- INDEX_NAME = 'idx_installable_helm_pkgs_on_project_id_id'
-
- def up
- add_concurrent_index :packages_packages, [:project_id, :id], name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index :packages_packages, [:project_id, :id], name: INDEX_NAME
- end
-end
diff --git a/db/migrate/20210831203408_upsert_base_work_item_types.rb b/db/migrate/20210831203408_upsert_base_work_item_types.rb
deleted file mode 100644
index 9a556bd6c2c..00000000000
--- a/db/migrate/20210831203408_upsert_base_work_item_types.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-class UpsertBaseWorkItemTypes < ActiveRecord::Migration[6.1]
- module WorkItem
- class Type < ActiveRecord::Base
- self.table_name = 'work_item_types'
-
- enum base_type: {
- issue: 0,
- incident: 1,
- test_case: 2,
- requirement: 3
- }
- end
- end
-
- def up
- # upsert default types
- WorkItem::Type.find_or_create_by(name: 'Issue', namespace_id: nil, base_type: :issue, icon_name: 'issue-type-issue')
- WorkItem::Type.find_or_create_by(name: 'Incident', namespace_id: nil, base_type: :incident, icon_name: 'issue-type-incident')
- WorkItem::Type.find_or_create_by(name: 'Test Case', namespace_id: nil, base_type: :test_case, icon_name: 'issue-type-test-case')
- WorkItem::Type.find_or_create_by(name: 'Requirement', namespace_id: nil, base_type: :requirement, icon_name: 'issue-type-requirements')
- end
-
- def down
- # We expect this table to be empty at the point of the up migration,
- # however there is a remote possibility that issues could already be
- # using one of these types, with a tight foreign constraint.
- # Therefore we will not attempt to remove any data.
- end
-end
diff --git a/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb b/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb
deleted file mode 100644
index e0c9d932b38..00000000000
--- a/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AddIndexOnNameAndIdToPublicGroups < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_namespaces_public_groups_name_id'
- PUBLIC_VISIBILITY_LEVEL = 20
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :namespaces, [:name, :id],
- name: INDEX_NAME,
- where: "type = 'Group' AND visibility_level = #{PUBLIC_VISIBILITY_LEVEL}"
- end
-
- def down
- remove_concurrent_index_by_name :namespaces, INDEX_NAME
- end
-end
diff --git a/db/migrate/20210902171406_add_latest_column_into_the_security_scans_table.rb b/db/migrate/20210902171406_add_latest_column_into_the_security_scans_table.rb
deleted file mode 100644
index 3c022cbaf5e..00000000000
--- a/db/migrate/20210902171406_add_latest_column_into_the_security_scans_table.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddLatestColumnIntoTheSecurityScansTable < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def up
- add_column :security_scans, :latest, :boolean, default: true, null: false
- end
-
- def down
- remove_column :security_scans, :latest
- end
-end
diff --git a/db/migrate/20210902171808_set_default_job_token_scope_false.rb b/db/migrate/20210902171808_set_default_job_token_scope_false.rb
deleted file mode 100644
index 0680382094f..00000000000
--- a/db/migrate/20210902171808_set_default_job_token_scope_false.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class SetDefaultJobTokenScopeFalse < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- with_lock_retries do
- change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: true, to: false
- end
- end
-
- def down
- with_lock_retries do
- change_column_default :project_ci_cd_settings, :job_token_scope_enabled, from: false, to: true
- end
- end
-end
diff --git a/db/migrate/20210902184334_add_expire_access_tokens_to_doorkeeper_application.rb b/db/migrate/20210902184334_add_expire_access_tokens_to_doorkeeper_application.rb
deleted file mode 100644
index 4638637331d..00000000000
--- a/db/migrate/20210902184334_add_expire_access_tokens_to_doorkeeper_application.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddExpireAccessTokensToDoorkeeperApplication < Gitlab::Database::Migration[1.0]
- def change
- add_column :oauth_applications, :expire_access_tokens, :boolean, default: false, null: false
- end
-end
diff --git a/db/migrate/20210903054158_recreate_stage_issue_events_table_with_bigints.rb b/db/migrate/20210903054158_recreate_stage_issue_events_table_with_bigints.rb
deleted file mode 100644
index 6c5d23d8703..00000000000
--- a/db/migrate/20210903054158_recreate_stage_issue_events_table_with_bigints.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: true
-
-class RecreateStageIssueEventsTableWithBigints < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
-
- def up
- drop_table :analytics_cycle_analytics_issue_stage_events # rubocop:disable Migration/DropTable
-
- execute <<~SQL
- CREATE TABLE analytics_cycle_analytics_issue_stage_events (
- stage_event_hash_id bigint NOT NULL,
- issue_id bigint NOT NULL,
- group_id bigint NOT NULL,
- project_id bigint NOT NULL,
- milestone_id bigint,
- author_id bigint,
- start_event_timestamp timestamp with time zone NOT NULL,
- end_event_timestamp timestamp with time zone,
- PRIMARY KEY (stage_event_hash_id, issue_id)
- ) PARTITION BY HASH (stage_event_hash_id)
- SQL
-
- create_hash_partitions :analytics_cycle_analytics_issue_stage_events, 32
- end
-
- def down
- drop_table :analytics_cycle_analytics_issue_stage_events
-
- execute <<~SQL
- CREATE TABLE analytics_cycle_analytics_issue_stage_events (
- stage_event_hash_id integer NOT NULL,
- issue_id integer NOT NULL,
- group_id integer NOT NULL,
- project_id integer NOT NULL,
- milestone_id integer,
- author_id integer,
- start_event_timestamp timestamp with time zone NOT NULL,
- end_event_timestamp timestamp with time zone,
- PRIMARY KEY (stage_event_hash_id, issue_id)
- ) PARTITION BY HASH (stage_event_hash_id)
- SQL
-
- create_hash_partitions :analytics_cycle_analytics_issue_stage_events, 32
- end
-end
diff --git a/db/migrate/20210906100021_delete_project_namespace_trigger.rb b/db/migrate/20210906100021_delete_project_namespace_trigger.rb
deleted file mode 100644
index ce68cf7d6d4..00000000000
--- a/db/migrate/20210906100021_delete_project_namespace_trigger.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-class DeleteProjectNamespaceTrigger < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::SchemaHelpers
-
- TRIGGER_NAME = "trigger_delete_project_namespace_on_project_delete"
- FUNCTION_NAME = 'delete_associated_project_namespace'
-
- def up
- create_trigger_function(FUNCTION_NAME, replace: true) do
- <<~SQL
- DELETE FROM namespaces
- WHERE namespaces.id = OLD.project_namespace_id AND
- namespaces.type = 'Project';
- RETURN NULL;
- SQL
- end
-
- execute(<<~SQL.squish)
- CREATE TRIGGER #{TRIGGER_NAME}
- AFTER DELETE ON projects FOR EACH ROW
- WHEN (OLD.project_namespace_id IS NOT NULL)
- EXECUTE FUNCTION #{FUNCTION_NAME}();
- SQL
- end
-
- def down
- drop_trigger(:projects, TRIGGER_NAME)
- drop_function(FUNCTION_NAME)
- end
-end
diff --git a/db/migrate/20210907182337_add_group_id_fkey_for_user_group_callout.rb b/db/migrate/20210907182337_add_group_id_fkey_for_user_group_callout.rb
deleted file mode 100644
index 540344bd761..00000000000
--- a/db/migrate/20210907182337_add_group_id_fkey_for_user_group_callout.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddGroupIdFkeyForUserGroupCallout < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :user_group_callouts, :namespaces, column: :group_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :user_group_callouts, column: :group_id
- end
- end
-end
diff --git a/db/migrate/20210907182359_add_user_id_fkey_for_user_group_callout.rb b/db/migrate/20210907182359_add_user_id_fkey_for_user_group_callout.rb
deleted file mode 100644
index 37b73335933..00000000000
--- a/db/migrate/20210907182359_add_user_id_fkey_for_user_group_callout.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddUserIdFkeyForUserGroupCallout < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :user_group_callouts, :users, column: :user_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :user_group_callouts, column: :user_id
- end
- end
-end
diff --git a/db/migrate/20210908060951_add_dast_schedules_to_plan_limits.rb b/db/migrate/20210908060951_add_dast_schedules_to_plan_limits.rb
deleted file mode 100644
index 85c7522d006..00000000000
--- a/db/migrate/20210908060951_add_dast_schedules_to_plan_limits.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddDastSchedulesToPlanLimits < Gitlab::Database::Migration[1.0]
- def change
- add_column(:plan_limits, :dast_profile_schedules, :integer, default: 1, null: false)
- end
-end
diff --git a/db/migrate/20210908061132_insert_dast_profile_schedules_plan_limits.rb b/db/migrate/20210908061132_insert_dast_profile_schedules_plan_limits.rb
deleted file mode 100644
index b9980f65c98..00000000000
--- a/db/migrate/20210908061132_insert_dast_profile_schedules_plan_limits.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-class InsertDastProfileSchedulesPlanLimits < Gitlab::Database::Migration[1.0]
- def up
- create_or_update_plan_limit('dast_profile_schedules', 'default', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'free', 1)
- create_or_update_plan_limit('dast_profile_schedules', 'bronze', 1)
- create_or_update_plan_limit('dast_profile_schedules', 'silver', 1)
- create_or_update_plan_limit('dast_profile_schedules', 'premium', 1)
- create_or_update_plan_limit('dast_profile_schedules', 'premium_trial', 1)
- create_or_update_plan_limit('dast_profile_schedules', 'gold', 20)
- create_or_update_plan_limit('dast_profile_schedules', 'ultimate', 20)
- create_or_update_plan_limit('dast_profile_schedules', 'ultimate_trial', 20)
- end
-
- def down
- create_or_update_plan_limit('dast_profile_schedules', 'default', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'free', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'bronze', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'silver', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'premium', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'premium_trial', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'gold', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'ultimate', 0)
- create_or_update_plan_limit('dast_profile_schedules', 'ultimate_trial', 0)
- end
-end
diff --git a/db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb b/db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb
deleted file mode 100644
index 81a76ecb10a..00000000000
--- a/db/migrate/20210908100810_add_jobs_per_stage_page_size_to_application_settings.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddJobsPerStagePageSizeToApplicationSettings < Gitlab::Database::Migration[1.0]
- def change
- add_column :application_settings, :jobs_per_stage_page_size, :integer, default: 200, null: false
- end
-end
diff --git a/db/migrate/20210908140437_add_sidekiq_limits_to_application_settings.rb b/db/migrate/20210908140437_add_sidekiq_limits_to_application_settings.rb
deleted file mode 100644
index dd0796a1c86..00000000000
--- a/db/migrate/20210908140437_add_sidekiq_limits_to_application_settings.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-class AddSidekiqLimitsToApplicationSettings < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction! # needed for now to avoid subtransactions
-
- def up
- with_lock_retries do
- add_column :application_settings, :sidekiq_job_limiter_mode, :smallint, default: 1, null: false
- add_column :application_settings, :sidekiq_job_limiter_compression_threshold_bytes, :integer, default: 100_000, null: false
- add_column :application_settings, :sidekiq_job_limiter_limit_bytes, :integer, default: 0, null: false
- end
- end
-
- def down
- with_lock_retries do
- remove_column :application_settings, :sidekiq_job_limiter_mode
- remove_column :application_settings, :sidekiq_job_limiter_compression_threshold_bytes
- remove_column :application_settings, :sidekiq_job_limiter_limit_bytes
- end
- end
-end
diff --git a/db/migrate/20210908185736_add_status_to_dependency_proxy_manifests.rb b/db/migrate/20210908185736_add_status_to_dependency_proxy_manifests.rb
deleted file mode 100644
index b8e7c7af144..00000000000
--- a/db/migrate/20210908185736_add_status_to_dependency_proxy_manifests.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddStatusToDependencyProxyManifests < Gitlab::Database::Migration[1.0]
- def change
- add_column :dependency_proxy_manifests, :status, :smallint, default: 0, null: false
- end
-end
diff --git a/db/migrate/20210908185754_add_status_to_dependency_proxy_blobs.rb b/db/migrate/20210908185754_add_status_to_dependency_proxy_blobs.rb
deleted file mode 100644
index 4fbdcad33cd..00000000000
--- a/db/migrate/20210908185754_add_status_to_dependency_proxy_blobs.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddStatusToDependencyProxyBlobs < Gitlab::Database::Migration[1.0]
- def change
- add_column :dependency_proxy_blobs, :status, :smallint, default: 0, null: false
- end
-end
diff --git a/db/migrate/20210908195506_add_data_to_vulnerability_finding_evidence.rb b/db/migrate/20210908195506_add_data_to_vulnerability_finding_evidence.rb
deleted file mode 100644
index 447508d3d5b..00000000000
--- a/db/migrate/20210908195506_add_data_to_vulnerability_finding_evidence.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddDataToVulnerabilityFindingEvidence < Gitlab::Database::Migration[1.0]
- def change
- add_column :vulnerability_finding_evidences, :data, :jsonb, default: {}, null: false
- end
-end
diff --git a/db/migrate/20210909184349_add_index_package_id_id_on_package_files.rb b/db/migrate/20210909184349_add_index_package_id_id_on_package_files.rb
deleted file mode 100644
index 38d9c4b5dd9..00000000000
--- a/db/migrate/20210909184349_add_index_package_id_id_on_package_files.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class AddIndexPackageIdIdOnPackageFiles < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_packages_package_files_on_package_id_id'
-
- def up
- disable_statement_timeout do
- execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON packages_package_files (package_id, id)" unless index_exists_by_name?(:package_package_files, INDEX_NAME)
- end
- end
-
- def down
- remove_concurrent_index_by_name :packages_package_files, INDEX_NAME
- end
-end
diff --git a/db/migrate/20210910014741_add_dependency_proxy_ttl_group_policy_worker_capacity_to_application_settings.rb b/db/migrate/20210910014741_add_dependency_proxy_ttl_group_policy_worker_capacity_to_application_settings.rb
deleted file mode 100644
index 52fab5a63ee..00000000000
--- a/db/migrate/20210910014741_add_dependency_proxy_ttl_group_policy_worker_capacity_to_application_settings.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class AddDependencyProxyTtlGroupPolicyWorkerCapacityToApplicationSettings < Gitlab::Database::Migration[1.0]
- def change
- add_column :application_settings,
- :dependency_proxy_ttl_group_policy_worker_capacity,
- :smallint,
- default: 2,
- null: false
- end
-end
diff --git a/db/migrate/20210910015047_add_app_settings_dep_proxy_ttl_worker_capacity_check_constraint.rb b/db/migrate/20210910015047_add_app_settings_dep_proxy_ttl_worker_capacity_check_constraint.rb
deleted file mode 100644
index 9b522f2874f..00000000000
--- a/db/migrate/20210910015047_add_app_settings_dep_proxy_ttl_worker_capacity_check_constraint.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddAppSettingsDepProxyTtlWorkerCapacityCheckConstraint < Gitlab::Database::Migration[1.0]
- CONSTRAINT_NAME = 'app_settings_dep_proxy_ttl_policies_worker_capacity_positive'
-
- disable_ddl_transaction!
-
- def up
- add_check_constraint :application_settings, 'dependency_proxy_ttl_group_policy_worker_capacity >= 0', CONSTRAINT_NAME
- end
-
- def down
- remove_check_constraint :application_settings, CONSTRAINT_NAME
- end
-end
diff --git a/db/migrate/20210910141043_change_ci_minutes_additional_pack_text_limit.rb b/db/migrate/20210910141043_change_ci_minutes_additional_pack_text_limit.rb
deleted file mode 100644
index ebb0de53d6a..00000000000
--- a/db/migrate/20210910141043_change_ci_minutes_additional_pack_text_limit.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class ChangeCiMinutesAdditionalPackTextLimit < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- remove_text_limit :ci_minutes_additional_packs, :purchase_xid
- add_text_limit :ci_minutes_additional_packs, :purchase_xid, 50
- end
-
- def down
- remove_text_limit :ci_minutes_additional_packs, :purchase_xid
- add_text_limit :ci_minutes_additional_packs, :purchase_xid, 32, validate: false
- end
-end
diff --git a/db/migrate/20210910192921_add_report_type_into_approval_project_rules.rb b/db/migrate/20210910192921_add_report_type_into_approval_project_rules.rb
deleted file mode 100644
index 4b147034657..00000000000
--- a/db/migrate/20210910192921_add_report_type_into_approval_project_rules.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class AddReportTypeIntoApprovalProjectRules < Gitlab::Database::Migration[1.0]
- def up
- add_column :approval_project_rules, :report_type, :integer, limit: 2
- end
-
- def down
- remove_column :approval_project_rules, :report_type
- end
-end
diff --git a/db/migrate/20210912034903_add_runner_features_to_ci_builds_metadata.rb b/db/migrate/20210912034903_add_runner_features_to_ci_builds_metadata.rb
deleted file mode 100644
index 83eddf2fb0d..00000000000
--- a/db/migrate/20210912034903_add_runner_features_to_ci_builds_metadata.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddRunnerFeaturesToCiBuildsMetadata < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :ci_builds_metadata, :runner_features, :jsonb, default: {}, null: false
- end
-end
diff --git a/db/migrate/20210913010411_create_agent_project_authorizations.rb b/db/migrate/20210913010411_create_agent_project_authorizations.rb
deleted file mode 100644
index 02b6ac677e0..00000000000
--- a/db/migrate/20210913010411_create_agent_project_authorizations.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-class CreateAgentProjectAuthorizations < Gitlab::Database::Migration[1.0]
- def change
- create_table :agent_project_authorizations do |t|
- t.bigint :project_id, null: false
- t.bigint :agent_id, null: false
- t.jsonb :config, null: false
-
- t.index :project_id
- t.index [:agent_id, :project_id], unique: true
- end
- end
-end
diff --git a/db/migrate/20210913010432_add_agent_project_authorizations_foreign_keys.rb b/db/migrate/20210913010432_add_agent_project_authorizations_foreign_keys.rb
deleted file mode 100644
index 545fc125950..00000000000
--- a/db/migrate/20210913010432_add_agent_project_authorizations_foreign_keys.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class AddAgentProjectAuthorizationsForeignKeys < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :agent_project_authorizations, :projects, column: :project_id
- add_concurrent_foreign_key :agent_project_authorizations, :cluster_agents, column: :agent_id
- end
-
- def down
- with_lock_retries do
- remove_foreign_key_if_exists :agent_project_authorizations, column: :project_id
- end
-
- with_lock_retries do
- remove_foreign_key_if_exists :agent_project_authorizations, column: :agent_id
- end
- end
-end
diff --git a/db/migrate/20210913122457_add_namespace_traversal_ids_to_ci_pending_builds.rb b/db/migrate/20210913122457_add_namespace_traversal_ids_to_ci_pending_builds.rb
deleted file mode 100644
index 9dd420604f4..00000000000
--- a/db/migrate/20210913122457_add_namespace_traversal_ids_to_ci_pending_builds.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddNamespaceTraversalIdsToCiPendingBuilds < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :ci_pending_builds, :namespace_traversal_ids, :integer, array: true, default: []
- end
-end
diff --git a/db/migrate/20210913224558_update_dependency_proxy_manifests_uniqueness_constraint.rb b/db/migrate/20210913224558_update_dependency_proxy_manifests_uniqueness_constraint.rb
deleted file mode 100644
index 845697c28b5..00000000000
--- a/db/migrate/20210913224558_update_dependency_proxy_manifests_uniqueness_constraint.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class UpdateDependencyProxyManifestsUniquenessConstraint < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- NEW_INDEX_NAME = 'index_dep_prox_manifests_on_group_id_file_name_and_status'
- OLD_INDEX_NAME = 'index_dependency_proxy_manifests_on_group_id_and_file_name'
-
- def up
- add_concurrent_index :dependency_proxy_manifests, [:group_id, :file_name, :status], unique: true, name: NEW_INDEX_NAME
- remove_concurrent_index_by_name :dependency_proxy_manifests, OLD_INDEX_NAME
- end
-
- def down
- add_concurrent_index :dependency_proxy_manifests, [:group_id, :file_name], unique: true, name: OLD_INDEX_NAME
- remove_concurrent_index_by_name :dependency_proxy_manifests, NEW_INDEX_NAME
- end
-end
diff --git a/db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb b/db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb
deleted file mode 100644
index 6e57429bca8..00000000000
--- a/db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddThrottleDeprecatedApiColumns < Gitlab::Database::Migration[1.0]
- def change
- add_column :application_settings, :throttle_unauthenticated_deprecated_api_requests_per_period, :integer, default: 3600, null: false
- add_column :application_settings, :throttle_unauthenticated_deprecated_api_period_in_seconds, :integer, default: 3600, null: false
- add_column :application_settings, :throttle_unauthenticated_deprecated_api_enabled, :boolean, default: false, null: false
-
- add_column :application_settings, :throttle_authenticated_deprecated_api_requests_per_period, :integer, default: 3600, null: false
- add_column :application_settings, :throttle_authenticated_deprecated_api_period_in_seconds, :integer, default: 1800, null: false
- add_column :application_settings, :throttle_authenticated_deprecated_api_enabled, :boolean, default: false, null: false
- end
-end
diff --git a/db/migrate/20210914172202_add_status_index_to_dependency_proxy_tables.rb b/db/migrate/20210914172202_add_status_index_to_dependency_proxy_tables.rb
deleted file mode 100644
index 9b593fbe540..00000000000
--- a/db/migrate/20210914172202_add_status_index_to_dependency_proxy_tables.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AddStatusIndexToDependencyProxyTables < Gitlab::Database::Migration[1.0]
- MANIFEST_INDEX_NAME = 'index_dependency_proxy_manifests_on_status'
- BLOB_INDEX_NAME = 'index_dependency_proxy_blobs_on_status'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :dependency_proxy_manifests, :status, name: MANIFEST_INDEX_NAME
- add_concurrent_index :dependency_proxy_blobs, :status, name: BLOB_INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :dependency_proxy_manifests, MANIFEST_INDEX_NAME
- remove_concurrent_index_by_name :dependency_proxy_blobs, BLOB_INDEX_NAME
- end
-end
diff --git a/db/migrate/20210915000453_add_index_on_clusters_integration_prometheus_enabled.rb b/db/migrate/20210915000453_add_index_on_clusters_integration_prometheus_enabled.rb
deleted file mode 100644
index 35cd18c1da9..00000000000
--- a/db/migrate/20210915000453_add_index_on_clusters_integration_prometheus_enabled.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddIndexOnClustersIntegrationPrometheusEnabled < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_clusters_integration_prometheus_enabled'
-
- def up
- add_concurrent_index(:clusters_integration_prometheus, [:enabled, :created_at, :cluster_id], name: INDEX_NAME)
- end
-
- def down
- remove_concurrent_index_by_name(:clusters_integration_prometheus, INDEX_NAME)
- end
-end
diff --git a/db/migrate/20210915001242_add_index_on_clusters_integration_elastic_stack_enabled.rb b/db/migrate/20210915001242_add_index_on_clusters_integration_elastic_stack_enabled.rb
deleted file mode 100644
index bdaa84f27fe..00000000000
--- a/db/migrate/20210915001242_add_index_on_clusters_integration_elastic_stack_enabled.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddIndexOnClustersIntegrationElasticStackEnabled < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_clusters_integration_elasticstack_enabled'
-
- def up
- add_concurrent_index(:clusters_integration_elasticstack, [:enabled, :created_at, :cluster_id], name: INDEX_NAME)
- end
-
- def down
- remove_concurrent_index_by_name(:clusters_integration_elasticstack, INDEX_NAME)
- end
-end
diff --git a/db/migrate/20210915070423_add_avatar_and_description_to_topic.rb b/db/migrate/20210915070423_add_avatar_and_description_to_topic.rb
deleted file mode 100644
index 2ceeb53cd1e..00000000000
--- a/db/migrate/20210915070423_add_avatar_and_description_to_topic.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddAvatarAndDescriptionToTopic < Gitlab::Database::Migration[1.0]
- # rubocop:disable Migration/AddLimitToTextColumns
- def up
- add_column :topics, :avatar, :text
- add_column :topics, :description, :text
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-
- def down
- remove_column :topics, :avatar
- remove_column :topics, :description
- end
-end
diff --git a/db/migrate/20210916132547_add_process_mode_to_resource_groups.rb b/db/migrate/20210916132547_add_process_mode_to_resource_groups.rb
deleted file mode 100644
index 6bac264fcf4..00000000000
--- a/db/migrate/20210916132547_add_process_mode_to_resource_groups.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddProcessModeToResourceGroups < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- PROCESS_MODE_UNORDERED = 0
-
- def up
- add_column :ci_resource_groups, :process_mode, :integer, default: PROCESS_MODE_UNORDERED, null: false, limit: 2
- end
-
- def down
- remove_column :ci_resource_groups, :process_mode
- end
-end
diff --git a/db/migrate/20210917134321_remove_temporary_index_for_project_topics_on_taggings.rb b/db/migrate/20210917134321_remove_temporary_index_for_project_topics_on_taggings.rb
deleted file mode 100644
index ac4821b8007..00000000000
--- a/db/migrate/20210917134321_remove_temporary_index_for_project_topics_on_taggings.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveTemporaryIndexForProjectTopicsOnTaggings < Gitlab::Database::Migration[1.0]
- MIGRATION = 'ExtractProjectTopicsIntoSeparateTable'
- INDEX_NAME = 'tmp_index_taggings_on_id_where_taggable_type_project'
- INDEX_CONDITION = "taggable_type = 'Project'"
-
- disable_ddl_transaction!
-
- def up
- # Ensure that no background jobs of 20210730104800_schedule_extract_project_topics_into_separate_table remain
- finalize_background_migration MIGRATION
- # this index was used in 20210730104800_schedule_extract_project_topics_into_separate_table
- remove_concurrent_index_by_name :taggings, INDEX_NAME
- end
-
- def down
- add_concurrent_index :taggings, :id, where: INDEX_CONDITION, name: INDEX_NAME # rubocop:disable Migration/PreventIndexCreation
- end
-end
diff --git a/db/migrate/20210917153645_remove_pipeline_fk_from_packages_build_infos.rb b/db/migrate/20210917153645_remove_pipeline_fk_from_packages_build_infos.rb
deleted file mode 100644
index 456788de521..00000000000
--- a/db/migrate/20210917153645_remove_pipeline_fk_from_packages_build_infos.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class RemovePipelineFkFromPackagesBuildInfos < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- with_lock_retries do
- remove_foreign_key_if_exists(:packages_build_infos, :ci_pipelines)
- end
- end
-
- def down
- add_concurrent_foreign_key(:packages_build_infos, :ci_pipelines, column: :pipeline_id, on_delete: :nullify)
- end
-end
diff --git a/db/migrate/20210917153905_remove_pipeline_fk_from_packages_package_file_build_infos.rb b/db/migrate/20210917153905_remove_pipeline_fk_from_packages_package_file_build_infos.rb
deleted file mode 100644
index 187ddc8a088..00000000000
--- a/db/migrate/20210917153905_remove_pipeline_fk_from_packages_package_file_build_infos.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class RemovePipelineFkFromPackagesPackageFileBuildInfos < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- with_lock_retries do
- remove_foreign_key_if_exists(:packages_package_file_build_infos, :ci_pipelines)
- end
- end
-
- def down
- add_concurrent_foreign_key(:packages_package_file_build_infos, :ci_pipelines, column: :pipeline_id, on_delete: :nullify)
- end
-end
diff --git a/db/migrate/20210917224419_add_registration_objective_to_user_detail.rb b/db/migrate/20210917224419_add_registration_objective_to_user_detail.rb
deleted file mode 100644
index ee7a474928e..00000000000
--- a/db/migrate/20210917224419_add_registration_objective_to_user_detail.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddRegistrationObjectiveToUserDetail < Gitlab::Database::Migration[1.0]
- def change
- add_column :user_details, :registration_objective, :smallint
- end
-end
diff --git a/db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb b/db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb
deleted file mode 100644
index 83ceaa58ff4..00000000000
--- a/db/migrate/20210920104446_add_text_limit_to_topics_description_and_avatar.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddTextLimitToTopicsDescriptionAndAvatar < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :topics, :description, 1024
- add_text_limit :topics, :avatar, 255
- end
-
- def down
- remove_text_limit :topics, :avatar
- remove_text_limit :topics, :description
- end
-end
diff --git a/db/migrate/20210921032008_add_suggest_pipeline_enabled_to_application_settings.rb b/db/migrate/20210921032008_add_suggest_pipeline_enabled_to_application_settings.rb
deleted file mode 100644
index 5ac12eccc7d..00000000000
--- a/db/migrate/20210921032008_add_suggest_pipeline_enabled_to_application_settings.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddSuggestPipelineEnabledToApplicationSettings < Gitlab::Database::Migration[1.0]
- def change
- add_column :application_settings, :suggest_pipeline_enabled, :boolean, default: true, null: false
- end
-end
diff --git a/db/migrate/20210921063924_index_labels_using_varchar_pattern_ops.rb b/db/migrate/20210921063924_index_labels_using_varchar_pattern_ops.rb
deleted file mode 100644
index 67975636488..00000000000
--- a/db/migrate/20210921063924_index_labels_using_varchar_pattern_ops.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-class IndexLabelsUsingVarcharPatternOps < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- NEW_TITLE_INDEX_NAME = 'index_labels_on_title_varchar'
- NEW_PROJECT_ID_TITLE_INDEX_NAME = 'index_labels_on_project_id_and_title_varchar_unique'
- NEW_GROUP_ID_TITLE_INDEX_NAME = 'index_labels_on_group_id_and_title_varchar_unique'
- NEW_GROUP_ID_INDEX_NAME = 'index_labels_on_group_id'
-
- OLD_TITLE_INDEX_NAME = 'index_labels_on_title'
- OLD_PROJECT_ID_TITLE_INDEX_NAME = 'index_labels_on_project_id_and_title_unique'
- OLD_GROUP_ID_TITLE_INDEX_NAME = 'index_labels_on_group_id_and_title_unique'
- OLD_GROUP_ID_PROJECT_ID_TITLE_INDEX_NAME = 'index_labels_on_group_id_and_project_id_and_title'
-
- def up
- add_concurrent_index :labels, :title, order: { title: :varchar_pattern_ops }, name: NEW_TITLE_INDEX_NAME
- add_concurrent_index :labels, [:project_id, :title], where: "labels.group_id IS NULL", unique: true, order: { title: :varchar_pattern_ops }, name: NEW_PROJECT_ID_TITLE_INDEX_NAME
- add_concurrent_index :labels, [:group_id, :title], where: "labels.project_id IS NULL", unique: true, order: { title: :varchar_pattern_ops }, name: NEW_GROUP_ID_TITLE_INDEX_NAME
- add_concurrent_index :labels, :group_id, name: NEW_GROUP_ID_INDEX_NAME
-
- remove_concurrent_index_by_name :labels, OLD_TITLE_INDEX_NAME
- remove_concurrent_index_by_name :labels, OLD_PROJECT_ID_TITLE_INDEX_NAME
- remove_concurrent_index_by_name :labels, OLD_GROUP_ID_TITLE_INDEX_NAME
- remove_concurrent_index_by_name :labels, OLD_GROUP_ID_PROJECT_ID_TITLE_INDEX_NAME
- end
-
- def down
- add_concurrent_index :labels, :title, name: OLD_TITLE_INDEX_NAME
- add_concurrent_index :labels, [:project_id, :title], where: "labels.group_id IS NULL", unique: true, name: OLD_PROJECT_ID_TITLE_INDEX_NAME
- add_concurrent_index :labels, [:group_id, :title], where: "labels.project_id IS NULL", unique: true, name: OLD_GROUP_ID_TITLE_INDEX_NAME
- add_concurrent_index :labels, [:group_id, :project_id, :title], unique: true, name: OLD_GROUP_ID_PROJECT_ID_TITLE_INDEX_NAME
-
- remove_concurrent_index_by_name :labels, NEW_TITLE_INDEX_NAME
- remove_concurrent_index_by_name :labels, NEW_PROJECT_ID_TITLE_INDEX_NAME
- remove_concurrent_index_by_name :labels, NEW_GROUP_ID_TITLE_INDEX_NAME
- remove_concurrent_index_by_name :labels, NEW_GROUP_ID_INDEX_NAME
- end
-end
diff --git a/db/migrate/20210921191010_add_report_type_index_into_approval_project_rules.rb b/db/migrate/20210921191010_add_report_type_index_into_approval_project_rules.rb
deleted file mode 100644
index c03c463b9bb..00000000000
--- a/db/migrate/20210921191010_add_report_type_index_into_approval_project_rules.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddReportTypeIndexIntoApprovalProjectRules < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_approval_project_rules_report_type'
-
- def up
- add_concurrent_index :approval_project_rules, :report_type, name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :approval_project_rules, name: INDEX_NAME
- end
-end
diff --git a/db/migrate/20210922172056_add_unique_namespaces_index_on_name_parent_id_and_type.rb b/db/migrate/20210922172056_add_unique_namespaces_index_on_name_parent_id_and_type.rb
deleted file mode 100644
index 6cbbe582ff6..00000000000
--- a/db/migrate/20210922172056_add_unique_namespaces_index_on_name_parent_id_and_type.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddUniqueNamespacesIndexOnNameParentIdAndType < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_namespaces_name_parent_id_type'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :namespaces, [:name, :parent_id, :type], unique: true, name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :namespaces, INDEX_NAME
- end
-end
diff --git a/db/migrate/20210922172156_drop_unique_namespaces_index_on_name_and_parent_id.rb b/db/migrate/20210922172156_drop_unique_namespaces_index_on_name_and_parent_id.rb
deleted file mode 100644
index 001f3a6964b..00000000000
--- a/db/migrate/20210922172156_drop_unique_namespaces_index_on_name_and_parent_id.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class DropUniqueNamespacesIndexOnNameAndParentId < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_namespaces_on_name_and_parent_id'
-
- disable_ddl_transaction!
-
- def up
- remove_concurrent_index_by_name :namespaces, INDEX_NAME
- end
-
- def down
- add_concurrent_index :namespaces, [:name, :parent_id], unique: true, name: INDEX_NAME
- end
-end
diff --git a/db/migrate/20210922215740_create_issue_customer_relations_contacts.rb b/db/migrate/20210922215740_create_issue_customer_relations_contacts.rb
deleted file mode 100644
index 2d89d295608..00000000000
--- a/db/migrate/20210922215740_create_issue_customer_relations_contacts.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-class CreateIssueCustomerRelationsContacts < Gitlab::Database::Migration[1.0]
- def change
- create_table :issue_customer_relations_contacts do |t|
- t.bigint :issue_id, null: false
- t.bigint :contact_id, null: false
- t.timestamps_with_timezone null: false
-
- t.index :contact_id
- t.index [:issue_id, :contact_id], unique: true, name: :index_issue_crm_contacts_on_issue_id_and_contact_id
- end
- end
-end
diff --git a/db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb b/db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb
deleted file mode 100644
index 7be465ca31a..00000000000
--- a/db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class AddIssueCustomerRelationsContactsForeignKeys < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :issue_customer_relations_contacts, :issues, column: :issue_id
- add_concurrent_foreign_key :issue_customer_relations_contacts, :customer_relations_contacts, column: :contact_id
- end
-
- def down
- with_lock_retries do
- remove_foreign_key_if_exists :issue_customer_relations_contacts, column: :issue_id
- end
-
- with_lock_retries do
- remove_foreign_key_if_exists :issue_customer_relations_contacts, column: :contact_id
- end
- end
-end
diff --git a/db/migrate/20210923042323_add_meta_data_to_user_credit_card_validations.rb b/db/migrate/20210923042323_add_meta_data_to_user_credit_card_validations.rb
deleted file mode 100644
index 2958285e7a5..00000000000
--- a/db/migrate/20210923042323_add_meta_data_to_user_credit_card_validations.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddMetaDataToUserCreditCardValidations < Gitlab::Database::Migration[1.0]
- # rubocop:disable Migration/AddLimitToTextColumns
- def change
- change_table :user_credit_card_validations do |t|
- t.date :expiration_date
- t.integer :last_digits, limit: 2 # last 4 digits
- t.text :holder_name
- end
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-end
diff --git a/db/migrate/20210923042324_limit_holder_name_on_user_credit_card_validations.rb b/db/migrate/20210923042324_limit_holder_name_on_user_credit_card_validations.rb
deleted file mode 100644
index 11d436093b7..00000000000
--- a/db/migrate/20210923042324_limit_holder_name_on_user_credit_card_validations.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-class LimitHolderNameOnUserCreditCardValidations < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :user_credit_card_validations, :holder_name, 26 # ISO IEC 7813
-
- add_check_constraint(:user_credit_card_validations, 'last_digits BETWEEN 0 AND 9999', constraint_name)
- end
-
- def down
- remove_text_limit :user_credit_card_validations, :holder_name
-
- remove_check_constraint(:user_credit_card_validations, constraint_name)
- end
-
- private
-
- def constraint_name
- check_constraint_name(:user_credit_card_validations, :last_digits, 'range')
- end
-end
diff --git a/db/migrate/20210923042325_index_meta_data_on_user_credit_card_validations.rb b/db/migrate/20210923042325_index_meta_data_on_user_credit_card_validations.rb
deleted file mode 100644
index cc4f4d35f09..00000000000
--- a/db/migrate/20210923042325_index_meta_data_on_user_credit_card_validations.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-class IndexMetaDataOnUserCreditCardValidations < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_user_credit_card_validations_meta_data_full_match'
-
- def up
- add_concurrent_index :user_credit_card_validations,
- [:holder_name, :expiration_date, :last_digits, :credit_card_validated_at],
- name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index :user_credit_card_validations,
- [:holder_name, :expiration_date, :last_digits, :credit_card_validated_at],
- name: INDEX_NAME
- end
-end
diff --git a/db/migrate/20210923151641_change_default_for_integrated_error_tracking.rb b/db/migrate/20210923151641_change_default_for_integrated_error_tracking.rb
deleted file mode 100644
index fc4cc1945f3..00000000000
--- a/db/migrate/20210923151641_change_default_for_integrated_error_tracking.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class ChangeDefaultForIntegratedErrorTracking < Gitlab::Database::Migration[1.0]
- def up
- change_column_default :project_error_tracking_settings, :integrated, from: false, to: true
- end
-
- def down
- change_column_default :project_error_tracking_settings, :integrated, from: true, to: false
- end
-end
diff --git a/db/migrate/20210928155022_improve_index_for_error_tracking.rb b/db/migrate/20210928155022_improve_index_for_error_tracking.rb
deleted file mode 100644
index ec8427670d7..00000000000
--- a/db/migrate/20210928155022_improve_index_for_error_tracking.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-class ImproveIndexForErrorTracking < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :error_tracking_errors, %i(project_id status last_seen_at id),
- order: { last_seen_at: :desc, id: :desc },
- name: 'index_et_errors_on_project_id_and_status_last_seen_at_id_desc'
-
- add_concurrent_index :error_tracking_errors, %i(project_id status first_seen_at id),
- order: { first_seen_at: :desc, id: :desc },
- name: 'index_et_errors_on_project_id_and_status_first_seen_at_id_desc'
-
- add_concurrent_index :error_tracking_errors, %i(project_id status events_count id),
- order: { events_count: :desc, id: :desc },
- name: 'index_et_errors_on_project_id_and_status_events_count_id_desc'
-
- remove_concurrent_index :error_tracking_errors, [:project_id, :status, :last_seen_at], name: 'index_et_errors_on_project_id_and_status_and_last_seen_at'
- remove_concurrent_index :error_tracking_errors, [:project_id, :status, :first_seen_at], name: 'index_et_errors_on_project_id_and_status_and_first_seen_at'
- remove_concurrent_index :error_tracking_errors, [:project_id, :status, :events_count], name: 'index_et_errors_on_project_id_and_status_and_events_count'
- end
-
- def down
- add_concurrent_index :error_tracking_errors, [:project_id, :status, :last_seen_at], name: 'index_et_errors_on_project_id_and_status_and_last_seen_at'
- add_concurrent_index :error_tracking_errors, [:project_id, :status, :first_seen_at], name: 'index_et_errors_on_project_id_and_status_and_first_seen_at'
- add_concurrent_index :error_tracking_errors, [:project_id, :status, :events_count], name: 'index_et_errors_on_project_id_and_status_and_events_count'
-
- remove_concurrent_index :error_tracking_errors, [:project_id, :status, :last_seen_at, :id], name: 'index_et_errors_on_project_id_and_status_last_seen_at_id_desc'
- remove_concurrent_index :error_tracking_errors, [:project_id, :status, :first_seen_at, :id], name: 'index_et_errors_on_project_id_and_status_first_seen_at_id_desc'
- remove_concurrent_index :error_tracking_errors, [:project_id, :status, :events_count, :id], name: 'index_et_errors_on_project_id_and_status_events_count_id_desc'
- end
-end
diff --git a/db/migrate/20210928171122_add_group_id_status_id_index_to_dependency_proxy_tables.rb b/db/migrate/20210928171122_add_group_id_status_id_index_to_dependency_proxy_tables.rb
deleted file mode 100644
index ef437641f2c..00000000000
--- a/db/migrate/20210928171122_add_group_id_status_id_index_to_dependency_proxy_tables.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AddGroupIdStatusIdIndexToDependencyProxyTables < Gitlab::Database::Migration[1.0]
- MANIFEST_INDEX_NAME = 'index_dependency_proxy_manifests_on_group_id_status_and_id'
- BLOB_INDEX_NAME = 'index_dependency_proxy_blobs_on_group_id_status_and_id'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :dependency_proxy_manifests, [:group_id, :status, :id], name: MANIFEST_INDEX_NAME
- add_concurrent_index :dependency_proxy_blobs, [:group_id, :status, :id], name: BLOB_INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :dependency_proxy_manifests, MANIFEST_INDEX_NAME
- remove_concurrent_index_by_name :dependency_proxy_blobs, BLOB_INDEX_NAME
- end
-end
diff --git a/db/migrate/20210929025600_add_phone_to_user_details.rb b/db/migrate/20210929025600_add_phone_to_user_details.rb
deleted file mode 100644
index 9bcfd4ab7e3..00000000000
--- a/db/migrate/20210929025600_add_phone_to_user_details.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddPhoneToUserDetails < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- # rubocop:disable Migration/AddLimitToTextColumns
- def up
- add_column :user_details, :phone, :text, comment: 'JiHu-specific column'
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-
- def down
- remove_column :user_details, :phone
- end
-end
diff --git a/db/migrate/20210929030834_add_text_limit_to_user_details_phone.rb b/db/migrate/20210929030834_add_text_limit_to_user_details_phone.rb
deleted file mode 100644
index f250aad3253..00000000000
--- a/db/migrate/20210929030834_add_text_limit_to_user_details_phone.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddTextLimitToUserDetailsPhone < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :user_details, :phone, 32
- end
-
- def down
- remove_text_limit :user_details, :phone
- end
-end
diff --git a/db/migrate/20210929031049_add_unique_index_phone_on_user_details.rb b/db/migrate/20210929031049_add_unique_index_phone_on_user_details.rb
deleted file mode 100644
index e0cf7aa8a44..00000000000
--- a/db/migrate/20210929031049_add_unique_index_phone_on_user_details.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddUniqueIndexPhoneOnUserDetails < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_user_details_on_phone'
-
- def up
- add_concurrent_index :user_details, :phone, unique: true, where: 'phone IS NOT NULL', name: INDEX_NAME, comment: 'JiHu-specific index'
- end
-
- def down
- remove_concurrent_index_by_name :user_details, INDEX_NAME
- end
-end
diff --git a/db/migrate/20210929032555_create_verification_codes.rb b/db/migrate/20210929032555_create_verification_codes.rb
deleted file mode 100644
index ad743641b9c..00000000000
--- a/db/migrate/20210929032555_create_verification_codes.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-class CreateVerificationCodes < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
-
- def up
- constraint_visitor_id_code = check_constraint_name('verification_codes', 'visitor_id_code', 'max_length')
- constraint_code = check_constraint_name('verification_codes', 'code', 'max_length')
- constraint_phone = check_constraint_name('verification_codes', 'phone', 'max_length')
-
- execute(<<~SQL)
- CREATE TABLE verification_codes (
- created_at timestamp with time zone NOT NULL DEFAULT NOW(),
- visitor_id_code text,
- code text,
- phone text,
- PRIMARY KEY (created_at, visitor_id_code, code, phone),
- CONSTRAINT #{constraint_visitor_id_code} CHECK ((char_length(visitor_id_code) <= 64)),
- CONSTRAINT #{constraint_code} CHECK ((char_length(code) <= 8)),
- CONSTRAINT #{constraint_phone} CHECK ((char_length(phone) <= 32))
- ) PARTITION BY RANGE (created_at);
- COMMENT ON TABLE verification_codes IS 'JiHu-specific table';
-
- CREATE UNIQUE INDEX index_verification_codes_on_phone_and_visitor_id_code ON verification_codes (visitor_id_code, phone, created_at);
- COMMENT ON INDEX index_verification_codes_on_phone_and_visitor_id_code IS 'JiHu-specific index';
- SQL
-
- min_date = Date.today - 1.month
- max_date = Date.today + 1.month
- create_daterange_partitions('verification_codes', 'created_at', min_date, max_date)
- end
-
- def down
- drop_table :verification_codes
- end
-end
diff --git a/db/migrate/20210929115340_add_security_policy_configurations_management_project_id_foreign_key.rb b/db/migrate/20210929115340_add_security_policy_configurations_management_project_id_foreign_key.rb
deleted file mode 100644
index 1335c06cf1f..00000000000
--- a/db/migrate/20210929115340_add_security_policy_configurations_management_project_id_foreign_key.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AddSecurityPolicyConfigurationsManagementProjectIdForeignKey < Gitlab::Database::Migration[1.0]
- CONSTRAINT_NAME = 'fk_security_policy_configurations_management_project_id'
- OLD_CONSTRAINT_NAME = 'fk_rails_42ed6c25ec'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key(:security_orchestration_policy_configurations, :projects, column: :security_policy_management_project_id, on_delete: :cascade, name: CONSTRAINT_NAME)
- remove_foreign_key_if_exists(:security_orchestration_policy_configurations, column: :security_policy_management_project_id, on_delete: :restrict, name: OLD_CONSTRAINT_NAME)
- end
-
- def down
- add_concurrent_foreign_key(:security_orchestration_policy_configurations, :projects, column: :security_policy_management_project_id, on_delete: :restrict, name: OLD_CONSTRAINT_NAME)
- remove_foreign_key_if_exists(:security_orchestration_policy_configurations, column: :security_policy_management_project_id, on_delete: :cascade, name: CONSTRAINT_NAME)
- end
-end
diff --git a/db/migrate/20210929121516_add_releases_author_id_id_created_at_index.rb b/db/migrate/20210929121516_add_releases_author_id_id_created_at_index.rb
deleted file mode 100644
index 60ca3040d70..00000000000
--- a/db/migrate/20210929121516_add_releases_author_id_id_created_at_index.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-class AddReleasesAuthorIdIdCreatedAtIndex < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_releases_on_author_id_id_created_at'
-
- def up
- add_concurrent_index :releases, [:author_id, :id, :created_at], name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :releases, INDEX_NAME
- end
-end
diff --git a/db/migrate/20210929144453_add_warn_about_potentially_unwanted_characters_to_project_settings.rb b/db/migrate/20210929144453_add_warn_about_potentially_unwanted_characters_to_project_settings.rb
deleted file mode 100644
index 166afa13371..00000000000
--- a/db/migrate/20210929144453_add_warn_about_potentially_unwanted_characters_to_project_settings.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-# See https://docs.gitlab.com/ee/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class AddWarnAboutPotentiallyUnwantedCharactersToProjectSettings < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def up
- add_column :project_settings, :warn_about_potentially_unwanted_characters, :boolean, null: false, default: true
- end
-
- def down
- remove_column :project_settings, :warn_about_potentially_unwanted_characters
- end
-end
diff --git a/db/migrate/20210930081208_fix_deprecated_api_throttle_defaults.rb b/db/migrate/20210930081208_fix_deprecated_api_throttle_defaults.rb
deleted file mode 100644
index be82b16ee8c..00000000000
--- a/db/migrate/20210930081208_fix_deprecated_api_throttle_defaults.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class FixDeprecatedApiThrottleDefaults < Gitlab::Database::Migration[1.0]
- def change
- change_column_default :application_settings, :throttle_unauthenticated_deprecated_api_requests_per_period, from: 3600, to: 1800
- change_column_default :application_settings, :throttle_authenticated_deprecated_api_period_in_seconds, from: 1800, to: 3600
- end
-end
diff --git a/db/migrate/20211001001222_add_source_version_to_bulk_imports.rb b/db/migrate/20211001001222_add_source_version_to_bulk_imports.rb
deleted file mode 100644
index d0eb4a32cac..00000000000
--- a/db/migrate/20211001001222_add_source_version_to_bulk_imports.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddSourceVersionToBulkImports < Gitlab::Database::Migration[1.0]
- def change
- add_column :bulk_imports, :source_version, :text # rubocop:disable Migration/AddLimitToTextColumns
- end
-end
diff --git a/db/migrate/20211004062942_create_coverage_fuzzing_corpuses.rb b/db/migrate/20211004062942_create_coverage_fuzzing_corpuses.rb
deleted file mode 100644
index c24883b626d..00000000000
--- a/db/migrate/20211004062942_create_coverage_fuzzing_corpuses.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class CreateCoverageFuzzingCorpuses < Gitlab::Database::Migration[1.0]
- def change
- create_table :coverage_fuzzing_corpuses do |t|
- t.bigint :project_id, null: false
- t.bigint :user_id
- t.bigint :package_id, null: false
-
- t.datetime_with_timezone :file_updated_at, null: false, default: -> { 'NOW()' }
- t.timestamps_with_timezone null: false
-
- t.index :project_id
- t.index :user_id
- t.index :package_id
- end
- end
-end
diff --git a/db/migrate/20211004075629_add_topics_name_gin_index.rb b/db/migrate/20211004075629_add_topics_name_gin_index.rb
deleted file mode 100644
index 94634a4cb2f..00000000000
--- a/db/migrate/20211004075629_add_topics_name_gin_index.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddTopicsNameGinIndex < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_topics_on_name_trigram'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :topics, :name, name: INDEX_NAME, using: :gin, opclass: { name: :gin_trgm_ops }
- end
-
- def down
- remove_concurrent_index_by_name :topics, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211004081911_add_external_event_destination_limit_to_plan_limits.rb b/db/migrate/20211004081911_add_external_event_destination_limit_to_plan_limits.rb
deleted file mode 100644
index 3e44c388617..00000000000
--- a/db/migrate/20211004081911_add_external_event_destination_limit_to_plan_limits.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddExternalEventDestinationLimitToPlanLimits < Gitlab::Database::Migration[1.0]
- def change
- add_column(:plan_limits, :external_audit_event_destinations, :integer, default: 5, null: false)
- end
-end
diff --git a/db/migrate/20211004122540_create_member_tasks.rb b/db/migrate/20211004122540_create_member_tasks.rb
deleted file mode 100644
index e1141873bcb..00000000000
--- a/db/migrate/20211004122540_create_member_tasks.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class CreateMemberTasks < Gitlab::Database::Migration[1.0]
- def change
- create_table :member_tasks do |t|
- t.references :member, index: true, null: false
- t.references :project, index: true, null: false
- t.timestamps_with_timezone null: false
- t.integer :tasks, limit: 2, array: true, null: false, default: []
- t.index [:member_id, :project_id], unique: true
- end
- end
-end
diff --git a/db/migrate/20211005063519_add_foreign_key_to_corpuses_on_project.rb b/db/migrate/20211005063519_add_foreign_key_to_corpuses_on_project.rb
deleted file mode 100644
index ba1fb443343..00000000000
--- a/db/migrate/20211005063519_add_foreign_key_to_corpuses_on_project.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToCorpusesOnProject < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :coverage_fuzzing_corpuses, :projects, column: :project_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :coverage_fuzzing_corpuses, column: :project_id
- end
- end
-end
diff --git a/db/migrate/20211005063616_add_foreign_key_to_corpuses_on_user.rb b/db/migrate/20211005063616_add_foreign_key_to_corpuses_on_user.rb
deleted file mode 100644
index da08ab97acf..00000000000
--- a/db/migrate/20211005063616_add_foreign_key_to_corpuses_on_user.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToCorpusesOnUser < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :coverage_fuzzing_corpuses, :users, column: :user_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :coverage_fuzzing_corpuses, column: :user_id
- end
- end
-end
diff --git a/db/migrate/20211005063723_add_foreign_key_to_corpuses_on_package.rb b/db/migrate/20211005063723_add_foreign_key_to_corpuses_on_package.rb
deleted file mode 100644
index 74ba7b070d0..00000000000
--- a/db/migrate/20211005063723_add_foreign_key_to_corpuses_on_package.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToCorpusesOnPackage < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :coverage_fuzzing_corpuses, :packages_packages, column: :package_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :coverage_fuzzing_corpuses, column: :package_id
- end
- end
-end
diff --git a/db/migrate/20211005092428_drop_time_range_partitioned_loose_fk.rb b/db/migrate/20211005092428_drop_time_range_partitioned_loose_fk.rb
deleted file mode 100644
index 2aaf5e4cf87..00000000000
--- a/db/migrate/20211005092428_drop_time_range_partitioned_loose_fk.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-class DropTimeRangePartitionedLooseFk < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::PartitioningMigrationHelpers
-
- def up
- # the table is not in use
- drop_table :loose_foreign_keys_deleted_records # rubocop: disable Migration/DropTable
- end
-
- def down
- constraint_name = check_constraint_name('loose_foreign_keys_deleted_records', 'deleted_table_name', 'max_length')
- execute(<<~SQL)
- CREATE TABLE loose_foreign_keys_deleted_records (
- created_at timestamp with time zone NOT NULL DEFAULT NOW(),
- deleted_table_name text NOT NULL,
- deleted_table_primary_key_value bigint NOT NULL,
- PRIMARY KEY (created_at, deleted_table_name, deleted_table_primary_key_value),
- CONSTRAINT #{constraint_name} CHECK ((char_length(deleted_table_name) <= 63))
- ) PARTITION BY RANGE (created_at);
- SQL
-
- min_date = Date.today - 1.month
- max_date = Date.today + 3.months
- create_daterange_partitions('loose_foreign_keys_deleted_records', 'created_at', min_date, max_date)
- end
-end
diff --git a/db/migrate/20211005093558_add_range_partitioned_loose_fk_table.rb b/db/migrate/20211005093558_add_range_partitioned_loose_fk_table.rb
deleted file mode 100644
index 6f52b6ec63b..00000000000
--- a/db/migrate/20211005093558_add_range_partitioned_loose_fk_table.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-class AddRangePartitionedLooseFkTable < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
-
- def up
- constraint_name = check_constraint_name('loose_foreign_keys_deleted_records', 'fully_qualified_table_name', 'max_length')
- execute(<<~SQL)
- CREATE TABLE loose_foreign_keys_deleted_records (
- id BIGSERIAL NOT NULL,
- partition bigint NOT NULL,
- primary_key_value bigint NOT NULL,
- status smallint NOT NULL DEFAULT 1,
- created_at timestamp with time zone NOT NULL DEFAULT NOW(),
- fully_qualified_table_name text NOT NULL,
- PRIMARY KEY (partition, id),
- CONSTRAINT #{constraint_name} CHECK ((char_length(fully_qualified_table_name) <= 150))
- ) PARTITION BY LIST (partition);
-
- CREATE TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1
- PARTITION OF loose_foreign_keys_deleted_records
- FOR VALUES IN (1);
- SQL
- end
-
- def down
- drop_table :loose_foreign_keys_deleted_records
- end
-end
diff --git a/db/migrate/20211005100112_recreate_loose_fk_insert_function.rb b/db/migrate/20211005100112_recreate_loose_fk_insert_function.rb
deleted file mode 100644
index b03ad069eba..00000000000
--- a/db/migrate/20211005100112_recreate_loose_fk_insert_function.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: true
-
-class RecreateLooseFkInsertFunction < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
-
- def up
- execute(<<~SQL)
- CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}()
- RETURNS TRIGGER AS
- $$
- BEGIN
- INSERT INTO loose_foreign_keys_deleted_records
- (partition, fully_qualified_table_name, primary_key_value)
- SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table
- ON CONFLICT DO NOTHING;
-
- RETURN NULL;
- END
- $$ LANGUAGE PLPGSQL
- SQL
- end
-
- def down
- # old function
- execute(<<~SQL)
- CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}()
- RETURNS TRIGGER AS
- $$
- BEGIN
- INSERT INTO loose_foreign_keys_deleted_records
- (deleted_table_name, deleted_table_primary_key_value)
- SELECT TG_TABLE_NAME, old_table.id FROM old_table
- ON CONFLICT DO NOTHING;
-
- RETURN NULL;
- END
- $$ LANGUAGE PLPGSQL
- SQL
- end
-end
diff --git a/db/migrate/20211005112404_add_member_id_foreign_key_to_member_tasks.rb b/db/migrate/20211005112404_add_member_id_foreign_key_to_member_tasks.rb
deleted file mode 100644
index f3447918ad3..00000000000
--- a/db/migrate/20211005112404_add_member_id_foreign_key_to_member_tasks.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddMemberIdForeignKeyToMemberTasks < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :member_tasks, :members, column: :member_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :member_tasks, column: :member_id
- end
- end
-end
diff --git a/db/migrate/20211005112645_add_project_id_foreign_key_to_member_tasks.rb b/db/migrate/20211005112645_add_project_id_foreign_key_to_member_tasks.rb
deleted file mode 100644
index ead6bb88e60..00000000000
--- a/db/migrate/20211005112645_add_project_id_foreign_key_to_member_tasks.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddProjectIdForeignKeyToMemberTasks < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :member_tasks, :projects, column: :project_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :member_tasks, column: :project_id
- end
- end
-end
diff --git a/db/migrate/20211006060254_add_topics_total_projects_count_cache.rb b/db/migrate/20211006060254_add_topics_total_projects_count_cache.rb
deleted file mode 100644
index ebca4c70879..00000000000
--- a/db/migrate/20211006060254_add_topics_total_projects_count_cache.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class AddTopicsTotalProjectsCountCache < Gitlab::Database::Migration[1.0]
- def up
- add_column :topics, :total_projects_count, :bigint, null: false, default: 0
- end
-
- def down
- remove_column :topics, :total_projects_count
- end
-end
diff --git a/db/migrate/20211006103122_change_helm_channel_length.rb b/db/migrate/20211006103122_change_helm_channel_length.rb
deleted file mode 100644
index 6579ca4053b..00000000000
--- a/db/migrate/20211006103122_change_helm_channel_length.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-class ChangeHelmChannelLength < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :packages_helm_file_metadata, :channel, 255, constraint_name: check_constraint_name(:packages_helm_file_metadata, :channel, 'max_length_v2')
- remove_text_limit :packages_helm_file_metadata, :channel, constraint_name: check_constraint_name(:packages_helm_file_metadata, :channel, 'max_length')
- end
-
- def down
- # no-op: Danger of failing if there are records with length(channel) > 63
- end
-end
diff --git a/db/migrate/20211006122010_add_topics_total_projects_count_index.rb b/db/migrate/20211006122010_add_topics_total_projects_count_index.rb
deleted file mode 100644
index bd969a9ff0a..00000000000
--- a/db/migrate/20211006122010_add_topics_total_projects_count_index.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddTopicsTotalProjectsCountIndex < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_topics_total_projects_count'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :topics, [:total_projects_count, :id], order: { total_projects_count: :desc }, name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :topics, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211007090229_create_issue_search_table.rb b/db/migrate/20211007090229_create_issue_search_table.rb
deleted file mode 100644
index 1fc15d20bd0..00000000000
--- a/db/migrate/20211007090229_create_issue_search_table.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-class CreateIssueSearchTable < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
-
- def up
- execute <<~SQL
- CREATE TABLE issue_search_data (
- project_id bigint NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
- issue_id bigint NOT NULL REFERENCES issues(id) ON DELETE CASCADE,
- created_at timestamp with time zone DEFAULT NOW() NOT NULL,
- updated_at timestamp with time zone DEFAULT NOW() NOT NULL,
- search_vector tsvector,
- PRIMARY KEY (project_id, issue_id)
- ) PARTITION BY HASH (project_id)
- SQL
-
- # rubocop: disable Migration/AddIndex
- add_index :issue_search_data, :issue_id
- add_index :issue_search_data, :search_vector, using: :gin, name: 'index_issue_search_data_on_search_vector'
- # rubocop: enable Migration/AddIndex
-
- create_hash_partitions :issue_search_data, 64
- end
-
- def down
- drop_table :issue_search_data
- end
-end
diff --git a/db/migrate/20211007113136_add_status_column_to_security_scans_table.rb b/db/migrate/20211007113136_add_status_column_to_security_scans_table.rb
deleted file mode 100644
index d60171dead7..00000000000
--- a/db/migrate/20211007113136_add_status_column_to_security_scans_table.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddStatusColumnToSecurityScansTable < Gitlab::Database::Migration[1.0]
- def change
- add_column :security_scans, :status, :integer, limit: 1, default: 0, null: false
- end
-end
diff --git a/db/migrate/20211008043855_remove_notes_trigram_index.rb b/db/migrate/20211008043855_remove_notes_trigram_index.rb
deleted file mode 100644
index a20ef1852e2..00000000000
--- a/db/migrate/20211008043855_remove_notes_trigram_index.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveNotesTrigramIndex < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- NOTES_TRIGRAM_INDEX_NAME = 'index_notes_on_note_trigram'
-
- def up
- remove_concurrent_index_by_name(:notes, NOTES_TRIGRAM_INDEX_NAME)
- end
-
- def down
- add_concurrent_index :notes, :note, name: NOTES_TRIGRAM_INDEX_NAME, using: :gin, opclass: { content: :gin_trgm_ops }
- end
-end
diff --git a/db/migrate/20211008181451_add_shared_runners_duration_to_ci_namespace_monthly_usages.rb b/db/migrate/20211008181451_add_shared_runners_duration_to_ci_namespace_monthly_usages.rb
deleted file mode 100644
index 862d1a26867..00000000000
--- a/db/migrate/20211008181451_add_shared_runners_duration_to_ci_namespace_monthly_usages.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddSharedRunnersDurationToCiNamespaceMonthlyUsages < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :ci_namespace_monthly_usages, :shared_runners_duration, :integer, default: 0, null: false
- end
-end
diff --git a/db/migrate/20211008182954_add_shared_runners_duration_to_ci_project_monthly_usages.rb b/db/migrate/20211008182954_add_shared_runners_duration_to_ci_project_monthly_usages.rb
deleted file mode 100644
index 76bb7356f0f..00000000000
--- a/db/migrate/20211008182954_add_shared_runners_duration_to_ci_project_monthly_usages.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddSharedRunnersDurationToCiProjectMonthlyUsages < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :ci_project_monthly_usages, :shared_runners_duration, :integer, default: 0, null: false
- end
-end
diff --git a/db/migrate/20211008193137_add_health_status_column_on_clusters_integration_prometheus.rb b/db/migrate/20211008193137_add_health_status_column_on_clusters_integration_prometheus.rb
deleted file mode 100644
index a69d12d4e52..00000000000
--- a/db/migrate/20211008193137_add_health_status_column_on_clusters_integration_prometheus.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class AddHealthStatusColumnOnClustersIntegrationPrometheus < Gitlab::Database::Migration[1.0]
- def change
- # For now, health checks will only run on monitor demo projects
- add_column :clusters_integration_prometheus, :health_status, :smallint, limit: 2, default: 0, null: false
- end
-end
diff --git a/db/migrate/20211011004242_create_content_blocked_states.rb b/db/migrate/20211011004242_create_content_blocked_states.rb
deleted file mode 100644
index d70717f9786..00000000000
--- a/db/migrate/20211011004242_create_content_blocked_states.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class CreateContentBlockedStates < Gitlab::Database::Migration[1.0]
- def change
- create_table :content_blocked_states, comment: 'JiHu-specific table' do |t|
- t.timestamps_with_timezone null: false
- t.binary :commit_sha, null: false
- t.binary :blob_sha, null: false
- t.text :path, null: false, limit: 2048
- t.text :container_identifier, null: false, limit: 255
-
- t.index [:container_identifier, :commit_sha, :path], name: 'index_content_blocked_states_on_container_id_commit_sha_path', unique: true
- end
- end
-end
diff --git a/db/migrate/20211011140930_create_ci_namespace_mirrors.rb b/db/migrate/20211011140930_create_ci_namespace_mirrors.rb
deleted file mode 100644
index b9a708c5d7b..00000000000
--- a/db/migrate/20211011140930_create_ci_namespace_mirrors.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class CreateCiNamespaceMirrors < Gitlab::Database::Migration[1.0]
- TABLE_NAME = :ci_namespace_mirrors
- INDEX_NAME = "index_gin_#{TABLE_NAME}_on_traversal_ids"
-
- def change
- create_table TABLE_NAME do |t|
- t.integer :namespace_id, null: false, index: { unique: true }
- t.integer :traversal_ids, array: true, default: [], null: false
-
- t.index :traversal_ids, name: INDEX_NAME, using: :gin
- end
- end
-end
diff --git a/db/migrate/20211011140931_create_ci_project_mirrors.rb b/db/migrate/20211011140931_create_ci_project_mirrors.rb
deleted file mode 100644
index 2407b7e0b84..00000000000
--- a/db/migrate/20211011140931_create_ci_project_mirrors.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-class CreateCiProjectMirrors < Gitlab::Database::Migration[1.0]
- TABLE_NAME = :ci_project_mirrors
-
- def change
- create_table TABLE_NAME do |t|
- t.integer :project_id, null: false, index: { unique: true }
- t.integer :namespace_id, null: false, index: true
- end
- end
-end
diff --git a/db/migrate/20211011140932_create_namespaces_sync_events.rb b/db/migrate/20211011140932_create_namespaces_sync_events.rb
deleted file mode 100644
index 06831423343..00000000000
--- a/db/migrate/20211011140932_create_namespaces_sync_events.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class CreateNamespacesSyncEvents < Gitlab::Database::Migration[1.0]
- def change
- create_table :namespaces_sync_events do |t|
- t.references :namespace, null: false, index: true, foreign_key: { on_delete: :cascade }
- end
- end
-end
diff --git a/db/migrate/20211011141239_create_projects_sync_events.rb b/db/migrate/20211011141239_create_projects_sync_events.rb
deleted file mode 100644
index 50fe988ac1b..00000000000
--- a/db/migrate/20211011141239_create_projects_sync_events.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class CreateProjectsSyncEvents < Gitlab::Database::Migration[1.0]
- def change
- create_table :projects_sync_events do |t|
- t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }
- end
- end
-end
diff --git a/db/migrate/20211011141242_create_namespaces_sync_trigger.rb b/db/migrate/20211011141242_create_namespaces_sync_trigger.rb
deleted file mode 100644
index 91f64709f28..00000000000
--- a/db/migrate/20211011141242_create_namespaces_sync_trigger.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-class CreateNamespacesSyncTrigger < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::SchemaHelpers
-
- enable_lock_retries!
-
- TABLE_NAME = 'namespaces'
- EVENT_TABLE_NAME = 'namespaces_sync_events'
- FUNCTION_NAME = 'insert_namespaces_sync_event'
- TRIGGER_ON_INSERT = 'trigger_namespaces_parent_id_on_insert'
- TRIGGER_ON_UPDATE = 'trigger_namespaces_parent_id_on_update'
-
- def up
- create_trigger_function(FUNCTION_NAME) do
- <<~SQL
- INSERT INTO #{EVENT_TABLE_NAME} (namespace_id)
- VALUES(COALESCE(NEW.id, OLD.id));
- RETURN NULL;
- SQL
- end
-
- create_trigger(TABLE_NAME, TRIGGER_ON_INSERT, FUNCTION_NAME, fires: 'AFTER INSERT')
-
- create_trigger(TABLE_NAME, TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do
- <<~SQL
- WHEN (OLD.parent_id IS DISTINCT FROM NEW.parent_id)
- SQL
- end
- end
-
- def down
- drop_trigger(TABLE_NAME, TRIGGER_ON_INSERT)
- drop_trigger(TABLE_NAME, TRIGGER_ON_UPDATE)
- drop_function(FUNCTION_NAME)
- end
-end
diff --git a/db/migrate/20211011141243_create_projects_sync_trigger.rb b/db/migrate/20211011141243_create_projects_sync_trigger.rb
deleted file mode 100644
index 03b31c35a3a..00000000000
--- a/db/migrate/20211011141243_create_projects_sync_trigger.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-class CreateProjectsSyncTrigger < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::SchemaHelpers
-
- enable_lock_retries!
-
- TABLE_NAME = 'projects'
- EVENT_TABLE_NAME = 'projects_sync_events'
- FUNCTION_NAME = 'insert_projects_sync_event'
- TRIGGER_ON_INSERT = 'trigger_projects_parent_id_on_insert'
- TRIGGER_ON_UPDATE = 'trigger_projects_parent_id_on_update'
-
- def up
- create_trigger_function(FUNCTION_NAME) do
- <<~SQL
- INSERT INTO #{EVENT_TABLE_NAME} (project_id)
- VALUES(COALESCE(NEW.id, OLD.id));
- RETURN NULL;
- SQL
- end
-
- create_trigger(TABLE_NAME, TRIGGER_ON_INSERT, FUNCTION_NAME, fires: 'AFTER INSERT')
-
- create_trigger(TABLE_NAME, TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do
- <<~SQL
- WHEN (OLD.namespace_id IS DISTINCT FROM NEW.namespace_id)
- SQL
- end
- end
-
- def down
- drop_trigger(TABLE_NAME, TRIGGER_ON_INSERT)
- drop_trigger(TABLE_NAME, TRIGGER_ON_UPDATE)
- drop_function(FUNCTION_NAME)
- end
-end
diff --git a/db/migrate/20211012015903_next_traversal_ids_sibling_function.rb b/db/migrate/20211012015903_next_traversal_ids_sibling_function.rb
deleted file mode 100644
index f32b8fc5a65..00000000000
--- a/db/migrate/20211012015903_next_traversal_ids_sibling_function.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-class NextTraversalIdsSiblingFunction < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::SchemaHelpers
-
- FUNCTION_NAME = 'next_traversal_ids_sibling'
-
- def up
- # Given array [1,2,3,4,5], concatenate the first part of the array [1,2,3,4]
- # with the last element in the array (5) after being incremented ([6]).
- #
- # [1,2,3,4,5] => [1,2,3,4,6]
- execute(<<~SQL)
- CREATE OR REPLACE FUNCTION #{FUNCTION_NAME}(traversal_ids INT[]) RETURNS INT[]
- AS $$
- BEGIN
- return traversal_ids[1:array_length(traversal_ids, 1)-1] ||
- ARRAY[traversal_ids[array_length(traversal_ids, 1)]+1];
- END;
- $$
- LANGUAGE plpgsql
- IMMUTABLE
- RETURNS NULL ON NULL INPUT;
- SQL
- end
-
- def down
- execute("DROP FUNCTION #{FUNCTION_NAME}(traversal_ids INT[])")
- end
-end
diff --git a/db/migrate/20211012091822_add_text_limit_to_bulk_imports_source_version.rb b/db/migrate/20211012091822_add_text_limit_to_bulk_imports_source_version.rb
deleted file mode 100644
index 9b4fca9a98c..00000000000
--- a/db/migrate/20211012091822_add_text_limit_to_bulk_imports_source_version.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddTextLimitToBulkImportsSourceVersion < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :bulk_imports, :source_version, 63
- end
-
- def down
- remove_text_limit :bulk_imports, :source_version
- end
-end
diff --git a/db/migrate/20211012134316_clean_up_migrate_merge_request_diff_commit_users.rb b/db/migrate/20211012134316_clean_up_migrate_merge_request_diff_commit_users.rb
deleted file mode 100644
index 443dbe37c0b..00000000000
--- a/db/migrate/20211012134316_clean_up_migrate_merge_request_diff_commit_users.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-class CleanUpMigrateMergeRequestDiffCommitUsers < Gitlab::Database::Migration[1.0]
- def up
- jobs = Gitlab::Database::BackgroundMigrationJob
- .for_migration_class('MigrateMergeRequestDiffCommitUsers')
- .pending
- .to_a
-
- return if jobs.empty?
-
- say("#{jobs.length} MigrateMergeRequestDiffCommitUsers are still pending")
-
- # Normally we don't process background migrations in a regular migration, as
- # this could take a while to complete and thus block a deployment.
- #
- # In this case the jobs have all been processed for GitLab.com at the time
- # of writing. In addition, it's been a few releases since this migration was
- # introduced. As a result, self-hosted instances should have their
- # migrations finished a long time ago.
- #
- # For these reasons we clean up any pending jobs (just in case) before
- # deploying the code. This also allows us to immediately start using the new
- # setup only, instead of having to support both the old and new approach for
- # at least one more release.
- jobs.each do |job|
- Gitlab::BackgroundMigration::MigrateMergeRequestDiffCommitUsers
- .new
- .perform(*job.arguments)
- end
- end
-
- def down
- end
-end
diff --git a/db/migrate/20211013014228_add_content_validation_endpoint_to_application_settings.rb b/db/migrate/20211013014228_add_content_validation_endpoint_to_application_settings.rb
deleted file mode 100644
index 9a79fdca192..00000000000
--- a/db/migrate/20211013014228_add_content_validation_endpoint_to_application_settings.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class AddContentValidationEndpointToApplicationSettings < Gitlab::Database::Migration[1.0]
- def up
- # rubocop:disable Migration/AddLimitToTextColumns
- add_column :application_settings, :content_validation_endpoint_url, :text, comment: 'JiHu-specific column'
- # rubocop:disable Migration/AddLimitToTextColumns
-
- add_column :application_settings, :encrypted_content_validation_api_key, :binary, comment: 'JiHu-specific column'
- add_column :application_settings, :encrypted_content_validation_api_key_iv, :binary, comment: 'JiHu-specific column'
- add_column :application_settings, :content_validation_endpoint_enabled, :boolean, null: false, default: false, comment: 'JiHu-specific column'
- end
-
- def down
- remove_column :application_settings, :content_validation_endpoint_url
- remove_column :application_settings, :encrypted_content_validation_api_key
- remove_column :application_settings, :encrypted_content_validation_api_key_iv
- remove_column :application_settings, :content_validation_endpoint_enabled
- end
-end
diff --git a/db/migrate/20211013080714_add_network_to_user_credit_card_validations.rb b/db/migrate/20211013080714_add_network_to_user_credit_card_validations.rb
deleted file mode 100644
index eee4cbad796..00000000000
--- a/db/migrate/20211013080714_add_network_to_user_credit_card_validations.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddNetworkToUserCreditCardValidations < Gitlab::Database::Migration[1.0]
- # rubocop:disable Migration/AddLimitToTextColumns
- def change
- add_column :user_credit_card_validations, :network, :text
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-end
diff --git a/db/migrate/20211013080715_limit_network_on_user_credit_card_validations.rb b/db/migrate/20211013080715_limit_network_on_user_credit_card_validations.rb
deleted file mode 100644
index 38a019e718d..00000000000
--- a/db/migrate/20211013080715_limit_network_on_user_credit_card_validations.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class LimitNetworkOnUserCreditCardValidations < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :user_credit_card_validations, :network, 32
- end
-
- def down
- remove_text_limit :user_credit_card_validations, :network
- end
-end
diff --git a/db/migrate/20211013080716_index_include_network_on_user_credit_card_validations.rb b/db/migrate/20211013080716_index_include_network_on_user_credit_card_validations.rb
deleted file mode 100644
index 849dbab77db..00000000000
--- a/db/migrate/20211013080716_index_include_network_on_user_credit_card_validations.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class IndexIncludeNetworkOnUserCreditCardValidations < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_user_credit_card_validations_meta_data_partial_match'
-
- def up
- add_concurrent_index :user_credit_card_validations,
- [:expiration_date, :last_digits, :network, :credit_card_validated_at],
- name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :user_credit_card_validations, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211013192749_add_states_into_approval_project_rules.rb b/db/migrate/20211013192749_add_states_into_approval_project_rules.rb
deleted file mode 100644
index 98fefbab12c..00000000000
--- a/db/migrate/20211013192749_add_states_into_approval_project_rules.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class AddStatesIntoApprovalProjectRules < Gitlab::Database::Migration[1.0]
- def up
- add_column :approval_project_rules, :vulnerability_states, :text, array: true, null: false, default: ['newly_detected']
- end
-
- def down
- remove_column :approval_project_rules, :vulnerability_states
- end
-end
diff --git a/db/migrate/20211015021114_add_merge_commit_template_to_project_settings.rb b/db/migrate/20211015021114_add_merge_commit_template_to_project_settings.rb
deleted file mode 100644
index adf2fdb2da7..00000000000
--- a/db/migrate/20211015021114_add_merge_commit_template_to_project_settings.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddMergeCommitTemplateToProjectSettings < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :project_settings, :merge_commit_template, :text # rubocop:disable Migration/AddLimitToTextColumns
- end
-end
diff --git a/db/migrate/20211015024135_add_merge_commit_template_limit_to_project_settings.rb b/db/migrate/20211015024135_add_merge_commit_template_limit_to_project_settings.rb
deleted file mode 100644
index 972872b8d2a..00000000000
--- a/db/migrate/20211015024135_add_merge_commit_template_limit_to_project_settings.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddMergeCommitTemplateLimitToProjectSettings < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :project_settings, :merge_commit_template, 500
- end
-
- def down
- remove_text_limit :project_settings, :merge_commit_template
- end
-end
diff --git a/db/migrate/20211018101034_add_tmp_project_id_column_to_namespaces.rb b/db/migrate/20211018101034_add_tmp_project_id_column_to_namespaces.rb
deleted file mode 100644
index cc73cb5047b..00000000000
--- a/db/migrate/20211018101034_add_tmp_project_id_column_to_namespaces.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class AddTmpProjectIdColumnToNamespaces < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- # this is a temporary column to be able to batch insert records into namespaces table and then be able to link these
- # to projects table.
- add_column :namespaces, :tmp_project_id, :integer # rubocop: disable Migration/AddColumnsToWideTables
- end
-end
diff --git a/db/migrate/20211018161447_fix_double_entries_in_postgres_index_view.rb b/db/migrate/20211018161447_fix_double_entries_in_postgres_index_view.rb
deleted file mode 100644
index 574f54bc60e..00000000000
--- a/db/migrate/20211018161447_fix_double_entries_in_postgres_index_view.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: true
-
-class FixDoubleEntriesInPostgresIndexView < Gitlab::Database::Migration[1.0]
- def up
- execute(<<~SQL)
- DROP VIEW IF EXISTS postgres_indexes;
-
- CREATE VIEW postgres_indexes AS
- SELECT (pg_namespace.nspname::text || '.'::text) || i.relname::text AS identifier,
- pg_index.indexrelid,
- pg_namespace.nspname AS schema,
- i.relname AS name,
- pg_indexes.tablename,
- a.amname AS type,
- pg_index.indisunique AS "unique",
- pg_index.indisvalid AS valid_index,
- i.relispartition AS partitioned,
- pg_index.indisexclusion AS exclusion,
- pg_index.indexprs IS NOT NULL AS expression,
- pg_index.indpred IS NOT NULL AS partial,
- pg_indexes.indexdef AS definition,
- pg_relation_size(i.oid::regclass) AS ondisk_size_bytes
- FROM pg_index
- JOIN pg_class i ON i.oid = pg_index.indexrelid
- JOIN pg_namespace ON i.relnamespace = pg_namespace.oid
- JOIN pg_indexes ON i.relname = pg_indexes.indexname AND pg_namespace.nspname = pg_indexes.schemaname
- JOIN pg_am a ON i.relam = a.oid
- WHERE pg_namespace.nspname <> 'pg_catalog'::name AND (pg_namespace.nspname = ANY (ARRAY["current_schema"(), 'gitlab_partitions_dynamic'::name, 'gitlab_partitions_static'::name]));
- SQL
- end
-
- def down
- execute(<<~SQL)
- DROP VIEW IF EXISTS postgres_indexes;
-
- CREATE VIEW postgres_indexes AS
- SELECT (pg_namespace.nspname::text || '.'::text) || i.relname::text AS identifier,
- pg_index.indexrelid,
- pg_namespace.nspname AS schema,
- i.relname AS name,
- pg_indexes.tablename,
- a.amname AS type,
- pg_index.indisunique AS "unique",
- pg_index.indisvalid AS valid_index,
- i.relispartition AS partitioned,
- pg_index.indisexclusion AS exclusion,
- pg_index.indexprs IS NOT NULL AS expression,
- pg_index.indpred IS NOT NULL AS partial,
- pg_indexes.indexdef AS definition,
- pg_relation_size(i.oid::regclass) AS ondisk_size_bytes
- FROM pg_index
- JOIN pg_class i ON i.oid = pg_index.indexrelid
- JOIN pg_namespace ON i.relnamespace = pg_namespace.oid
- JOIN pg_indexes ON i.relname = pg_indexes.indexname
- JOIN pg_am a ON i.relam = a.oid
- WHERE pg_namespace.nspname <> 'pg_catalog'::name AND (pg_namespace.nspname = ANY (ARRAY["current_schema"(), 'gitlab_partitions_dynamic'::name, 'gitlab_partitions_static'::name]));
- SQL
- end
-end
diff --git a/db/migrate/20211019153615_add_state_to_merge_request_assignees.rb b/db/migrate/20211019153615_add_state_to_merge_request_assignees.rb
deleted file mode 100644
index 0eb8d0989a5..00000000000
--- a/db/migrate/20211019153615_add_state_to_merge_request_assignees.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-class AddStateToMergeRequestAssignees < Gitlab::Database::Migration[1.0]
- REVIEW_DEFAULT_STATE = 0
-
- def change
- add_column :merge_request_assignees, :state, :smallint, default: REVIEW_DEFAULT_STATE, null: false
- end
-end
diff --git a/db/migrate/20211020030948_add_runtime_runner_features_to_ci_builds_metadata.rb b/db/migrate/20211020030948_add_runtime_runner_features_to_ci_builds_metadata.rb
deleted file mode 100644
index 970c018df46..00000000000
--- a/db/migrate/20211020030948_add_runtime_runner_features_to_ci_builds_metadata.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddRuntimeRunnerFeaturesToCiBuildsMetadata < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :ci_builds_metadata, :runtime_runner_features, :jsonb, default: {}, null: false
- end
-end
diff --git a/db/migrate/20211020095357_add_group_traversal_id_index.rb b/db/migrate/20211020095357_add_group_traversal_id_index.rb
deleted file mode 100644
index e4739ff217e..00000000000
--- a/db/migrate/20211020095357_add_group_traversal_id_index.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddGroupTraversalIdIndex < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_namespaces_on_traversal_ids_for_groups'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :namespaces, :traversal_ids, using: :gin, where: "type='Group'", name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :namespaces, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211021115409_add_color_to_epics.rb b/db/migrate/20211021115409_add_color_to_epics.rb
deleted file mode 100644
index 14b38209f30..00000000000
--- a/db/migrate/20211021115409_add_color_to_epics.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-class AddColorToEpics < Gitlab::Database::Migration[1.0]
- # rubocop:disable Migration/AddLimitToTextColumns
- # limit is added in 20211021124715_add_text_limit_to_epics_color
- def change
- add_column :epics, :color, :text, default: '#1068bf'
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-end
diff --git a/db/migrate/20211021124715_add_text_limit_to_epics_color.rb b/db/migrate/20211021124715_add_text_limit_to_epics_color.rb
deleted file mode 100644
index 7844575c521..00000000000
--- a/db/migrate/20211021124715_add_text_limit_to_epics_color.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddTextLimitToEpicsColor < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :epics, :color, 7
- end
-
- def down
- remove_text_limit :epics, :color
- end
-end
diff --git a/db/migrate/20211021125908_add_sentry_settings_to_application_settings.rb b/db/migrate/20211021125908_add_sentry_settings_to_application_settings.rb
deleted file mode 100644
index d8b40893b47..00000000000
--- a/db/migrate/20211021125908_add_sentry_settings_to_application_settings.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-class AddSentrySettingsToApplicationSettings < Gitlab::Database::Migration[1.0]
- # rubocop:disable Migration/AddLimitToTextColumns
- def change
- add_column :application_settings, :sentry_enabled, :boolean, default: false, null: false
- add_column :application_settings, :sentry_dsn, :text
- add_column :application_settings, :sentry_clientside_dsn, :text
- add_column :application_settings, :sentry_environment, :text
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-end
diff --git a/db/migrate/20211021134458_add_limits_to_sentry_settings_on_application_settings.rb b/db/migrate/20211021134458_add_limits_to_sentry_settings_on_application_settings.rb
deleted file mode 100644
index 34d18741788..00000000000
--- a/db/migrate/20211021134458_add_limits_to_sentry_settings_on_application_settings.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class AddLimitsToSentrySettingsOnApplicationSettings < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :application_settings, :sentry_dsn, 255
- add_text_limit :application_settings, :sentry_clientside_dsn, 255
- add_text_limit :application_settings, :sentry_environment, 255
- end
-
- def down
- remove_text_limit :application_settings, :sentry_dsn
- remove_text_limit :application_settings, :sentry_clientside_dsn
- remove_text_limit :application_settings, :sentry_environment
- end
-end
diff --git a/db/migrate/20211025103744_add_state_id_to_vsa_issue_stage_events.rb b/db/migrate/20211025103744_add_state_id_to_vsa_issue_stage_events.rb
deleted file mode 100644
index 345cd1785ea..00000000000
--- a/db/migrate/20211025103744_add_state_id_to_vsa_issue_stage_events.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddStateIdToVsaIssueStageEvents < Gitlab::Database::Migration[1.0]
- def change
- add_column :analytics_cycle_analytics_issue_stage_events, :state_id, :smallint, default: 1, null: false
- end
-end
diff --git a/db/migrate/20211025103758_add_state_id_to_vsa_merge_request_stage_events.rb b/db/migrate/20211025103758_add_state_id_to_vsa_merge_request_stage_events.rb
deleted file mode 100644
index be28d56e19d..00000000000
--- a/db/migrate/20211025103758_add_state_id_to_vsa_merge_request_stage_events.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddStateIdToVsaMergeRequestStageEvents < Gitlab::Database::Migration[1.0]
- def change
- add_column :analytics_cycle_analytics_merge_request_stage_events, :state_id, :smallint, default: 1, null: false
- end
-end
diff --git a/db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb b/db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb
deleted file mode 100644
index 90e68f6a0ac..00000000000
--- a/db/migrate/20211026124336_add_archive_trace_events_to_integrations.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddArchiveTraceEventsToIntegrations < Gitlab::Database::Migration[1.0]
- def change
- add_column :integrations, :archive_trace_events, :boolean, null: false, default: false
- end
-end
diff --git a/db/migrate/20211026143238_remove_index_releases_on_author_id.rb b/db/migrate/20211026143238_remove_index_releases_on_author_id.rb
deleted file mode 100644
index 7cd086dbf7d..00000000000
--- a/db/migrate/20211026143238_remove_index_releases_on_author_id.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveIndexReleasesOnAuthorId < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_releases_on_author_id'
-
- disable_ddl_transaction!
-
- def up
- remove_concurrent_index_by_name :releases, INDEX_NAME
- end
-
- def down
- add_concurrent_index :releases, [:author_id], name: INDEX_NAME
- end
-end
diff --git a/db/migrate/20211027203950_add_updated_index_for_dormant_users.rb b/db/migrate/20211027203950_add_updated_index_for_dormant_users.rb
deleted file mode 100644
index 8b004af06c0..00000000000
--- a/db/migrate/20211027203950_add_updated_index_for_dormant_users.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class AddUpdatedIndexForDormantUsers < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_users_on_id_and_last_activity_on_for_active_human_service'
-
- disable_ddl_transaction!
-
- def up
- index_condition = "state = 'active' AND (users.user_type IS NULL OR users.user_type = 4)"
-
- add_concurrent_index :users, [:id, :last_activity_on], where: index_condition, name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :users, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211028132247_create_packages_npm_metadata.rb b/db/migrate/20211028132247_create_packages_npm_metadata.rb
deleted file mode 100644
index cbe5429fca1..00000000000
--- a/db/migrate/20211028132247_create_packages_npm_metadata.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-class CreatePackagesNpmMetadata < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- with_lock_retries do
- create_table :packages_npm_metadata, id: false do |t|
- t.references :package, primary_key: true, default: nil, index: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
- t.jsonb :package_json, default: {}, null: false
-
- t.check_constraint 'char_length(package_json::text) < 20000'
- end
- end
- end
-
- def down
- with_lock_retries do
- drop_table :packages_npm_metadata
- end
- end
-end
diff --git a/db/migrate/20211028212259_add_default_to_personal_access_tokens_prefix.rb b/db/migrate/20211028212259_add_default_to_personal_access_tokens_prefix.rb
deleted file mode 100644
index d9949863a92..00000000000
--- a/db/migrate/20211028212259_add_default_to_personal_access_tokens_prefix.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddDefaultToPersonalAccessTokensPrefix < Gitlab::Database::Migration[1.0]
- def change
- change_column_default(:application_settings, :personal_access_token_prefix, from: nil, to: 'glpat-')
- end
-end
diff --git a/db/migrate/20211101132310_add_reindexing_queue.rb b/db/migrate/20211101132310_add_reindexing_queue.rb
deleted file mode 100644
index d9d1f9dce89..00000000000
--- a/db/migrate/20211101132310_add_reindexing_queue.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-class AddReindexingQueue < Gitlab::Database::Migration[1.0]
- def change
- create_table :postgres_reindex_queued_actions do |t|
- t.text :index_identifier, null: false, limit: 255
- t.integer :state, limit: 2, null: false, default: 0
- t.timestamps_with_timezone null: false
-
- t.index :state
- end
-
- change_column_default :postgres_reindex_queued_actions, :created_at, from: nil, to: -> { 'NOW()' }
- change_column_default :postgres_reindex_queued_actions, :updated_at, from: nil, to: -> { 'NOW()' }
- end
-end
diff --git a/db/migrate/20211101165656_create_upload_states.rb b/db/migrate/20211101165656_create_upload_states.rb
deleted file mode 100644
index 64873f4c9a2..00000000000
--- a/db/migrate/20211101165656_create_upload_states.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-class CreateUploadStates < Gitlab::Database::Migration[1.0]
- VERIFICATION_STATE_INDEX_NAME = "index_upload_states_on_verification_state"
- PENDING_VERIFICATION_INDEX_NAME = "index_upload_states_pending_verification"
- FAILED_VERIFICATION_INDEX_NAME = "index_upload_states_failed_verification"
- NEEDS_VERIFICATION_INDEX_NAME = "index_upload_states_needs_verification"
-
- disable_ddl_transaction!
-
- def up
- create_table :upload_states, id: false do |t|
- t.datetime_with_timezone :verification_started_at
- t.datetime_with_timezone :verification_retry_at
- t.datetime_with_timezone :verified_at
- t.references :upload, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
- t.integer :verification_state, default: 0, limit: 2, null: false
- t.integer :verification_retry_count, limit: 2
- t.binary :verification_checksum, using: 'verification_checksum::bytea'
- t.text :verification_failure, limit: 255
-
- t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
- t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
- t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
- t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
- end
- end
-
- def down
- drop_table :upload_states
- end
-end
diff --git a/db/migrate/20211103062728_add_with_highest_role_minimal_access_to_users_statistics.rb b/db/migrate/20211103062728_add_with_highest_role_minimal_access_to_users_statistics.rb
deleted file mode 100644
index 43cd7afbf06..00000000000
--- a/db/migrate/20211103062728_add_with_highest_role_minimal_access_to_users_statistics.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddWithHighestRoleMinimalAccessToUsersStatistics < Gitlab::Database::Migration[1.0]
- def change
- add_column :users_statistics, :with_highest_role_minimal_access, :integer, null: false, default: 0
- end
-end
diff --git a/db/migrate/20211104012209_add_text_limit_to_application_settings_content_validation_endpoint_url.rb b/db/migrate/20211104012209_add_text_limit_to_application_settings_content_validation_endpoint_url.rb
deleted file mode 100644
index 4062fd1be01..00000000000
--- a/db/migrate/20211104012209_add_text_limit_to_application_settings_content_validation_endpoint_url.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddTextLimitToApplicationSettingsContentValidationEndpointUrl < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :application_settings, :content_validation_endpoint_url, 255
- end
-
- def down
- remove_text_limit :application_settings, :content_validation_endpoint_url
- end
-end
diff --git a/db/migrate/20211105010101_add_archived_column_to_deployments.rb b/db/migrate/20211105010101_add_archived_column_to_deployments.rb
deleted file mode 100644
index f9ac81915b4..00000000000
--- a/db/migrate/20211105010101_add_archived_column_to_deployments.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddArchivedColumnToDeployments < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :deployments, :archived, :boolean, default: false, null: false
- end
-end
diff --git a/db/migrate/20211105125756_add_read_at_to_dependency_proxy_manifests.rb b/db/migrate/20211105125756_add_read_at_to_dependency_proxy_manifests.rb
deleted file mode 100644
index a594674f470..00000000000
--- a/db/migrate/20211105125756_add_read_at_to_dependency_proxy_manifests.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddReadAtToDependencyProxyManifests < Gitlab::Database::Migration[1.0]
- def change
- add_column :dependency_proxy_manifests, :read_at, :datetime_with_timezone, null: false, default: -> { 'NOW()' }
- end
-end
diff --git a/db/migrate/20211105125813_add_read_at_to_dependency_proxy_blobs.rb b/db/migrate/20211105125813_add_read_at_to_dependency_proxy_blobs.rb
deleted file mode 100644
index 1808a541498..00000000000
--- a/db/migrate/20211105125813_add_read_at_to_dependency_proxy_blobs.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddReadAtToDependencyProxyBlobs < Gitlab::Database::Migration[1.0]
- def change
- add_column :dependency_proxy_blobs, :read_at, :datetime_with_timezone, null: false, default: -> { 'NOW()' }
- end
-end
diff --git a/db/migrate/20211105160316_create_dotenv_application_limits.rb b/db/migrate/20211105160316_create_dotenv_application_limits.rb
deleted file mode 100644
index 3ea94fd60fc..00000000000
--- a/db/migrate/20211105160316_create_dotenv_application_limits.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-class CreateDotenvApplicationLimits < Gitlab::Database::Migration[1.0]
- def change
- add_column(:plan_limits, :dotenv_variables, :integer, default: 20, null: false)
- add_column(:plan_limits, :dotenv_size, :integer, default: 5.kilobytes, null: false)
- end
-end
diff --git a/db/migrate/20211105161404_insert_dotenv_application_limits.rb b/db/migrate/20211105161404_insert_dotenv_application_limits.rb
deleted file mode 100644
index 2749cf4a019..00000000000
--- a/db/migrate/20211105161404_insert_dotenv_application_limits.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-class InsertDotenvApplicationLimits < Gitlab::Database::Migration[1.0]
- def up
- create_or_update_plan_limit('dotenv_variables', 'default', 150)
- create_or_update_plan_limit('dotenv_variables', 'free', 50)
- create_or_update_plan_limit('dotenv_variables', 'opensource', 150)
- create_or_update_plan_limit('dotenv_variables', 'premium', 100)
- create_or_update_plan_limit('dotenv_variables', 'premium_trial', 100)
- create_or_update_plan_limit('dotenv_variables', 'ultimate', 150)
- create_or_update_plan_limit('dotenv_variables', 'ultimate_trial', 150)
-
- create_or_update_plan_limit('dotenv_size', 'default', 5.kilobytes)
- end
-
- def down
- create_or_update_plan_limit('dotenv_variables', 'default', 20)
- create_or_update_plan_limit('dotenv_variables', 'free', 20)
- create_or_update_plan_limit('dotenv_variables', 'opensource', 20)
- create_or_update_plan_limit('dotenv_variables', 'premium', 20)
- create_or_update_plan_limit('dotenv_variables', 'premium_trial', 20)
- create_or_update_plan_limit('dotenv_variables', 'ultimate', 20)
- create_or_update_plan_limit('dotenv_variables', 'ultimate_trial', 20)
-
- create_or_update_plan_limit('dotenv_size', 'default', 5.kilobytes)
- end
-end
diff --git a/db/migrate/20211108154510_create_pipeline_triggers_application_limits.rb b/db/migrate/20211108154510_create_pipeline_triggers_application_limits.rb
deleted file mode 100644
index 38671c75e0c..00000000000
--- a/db/migrate/20211108154510_create_pipeline_triggers_application_limits.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class CreatePipelineTriggersApplicationLimits < Gitlab::Database::Migration[1.0]
- def change
- add_column(:plan_limits, :pipeline_triggers, :integer, default: 25_000, null: false)
- end
-end
diff --git a/db/migrate/20211108154841_insert_pipeline_triggers_application_limits.rb b/db/migrate/20211108154841_insert_pipeline_triggers_application_limits.rb
deleted file mode 100644
index c1341fad729..00000000000
--- a/db/migrate/20211108154841_insert_pipeline_triggers_application_limits.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-class InsertPipelineTriggersApplicationLimits < Gitlab::Database::Migration[1.0]
- def up
- create_or_update_plan_limit('pipeline_triggers', 'default', 0)
- create_or_update_plan_limit('pipeline_triggers', 'free', 25_000)
- create_or_update_plan_limit('pipeline_triggers', 'opensource', 0)
- create_or_update_plan_limit('pipeline_triggers', 'premium', 0)
- create_or_update_plan_limit('pipeline_triggers', 'premium_trial', 0)
- create_or_update_plan_limit('pipeline_triggers', 'ultimate', 0)
- create_or_update_plan_limit('pipeline_triggers', 'ultimate_trial', 0)
- end
-
- def down
- create_or_update_plan_limit('pipeline_triggers', 'default', 0)
- create_or_update_plan_limit('pipeline_triggers', 'free', 0)
- create_or_update_plan_limit('pipeline_triggers', 'opensource', 0)
- create_or_update_plan_limit('pipeline_triggers', 'premium', 0)
- create_or_update_plan_limit('pipeline_triggers', 'premium_trial', 0)
- create_or_update_plan_limit('pipeline_triggers', 'ultimate', 0)
- create_or_update_plan_limit('pipeline_triggers', 'ultimate_trial', 0)
- end
-end
diff --git a/db/migrate/20211108203248_update_dependency_proxy_indexes_with_read_at.rb b/db/migrate/20211108203248_update_dependency_proxy_indexes_with_read_at.rb
deleted file mode 100644
index ac0f0ddca17..00000000000
--- a/db/migrate/20211108203248_update_dependency_proxy_indexes_with_read_at.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-class UpdateDependencyProxyIndexesWithReadAt < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- NEW_BLOB_INDEX = 'index_dependency_proxy_blobs_on_group_id_status_read_at_id'
- OLD_BLOB_INDEX = 'index_dependency_proxy_blobs_on_group_id_status_and_id'
-
- NEW_MANIFEST_INDEX = 'index_dependency_proxy_manifests_on_group_id_status_read_at_id'
- OLD_MANIFEST_INDEX = 'index_dependency_proxy_manifests_on_group_id_status_and_id'
-
- def up
- add_concurrent_index :dependency_proxy_blobs, [:group_id, :status, :read_at, :id], name: NEW_BLOB_INDEX
- add_concurrent_index :dependency_proxy_manifests, [:group_id, :status, :read_at, :id], name: NEW_MANIFEST_INDEX
-
- remove_concurrent_index_by_name :dependency_proxy_blobs, OLD_BLOB_INDEX
- remove_concurrent_index_by_name :dependency_proxy_manifests, OLD_MANIFEST_INDEX
- end
-
- def down
- add_concurrent_index :dependency_proxy_blobs, [:group_id, :status, :id], name: OLD_BLOB_INDEX
- add_concurrent_index :dependency_proxy_manifests, [:group_id, :status, :id], name: OLD_MANIFEST_INDEX
-
- remove_concurrent_index_by_name :dependency_proxy_blobs, NEW_BLOB_INDEX
- remove_concurrent_index_by_name :dependency_proxy_manifests, NEW_MANIFEST_INDEX
- end
-end
diff --git a/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb b/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb
deleted file mode 100644
index 90e5fa34817..00000000000
--- a/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddPolicyIdxToApprovalProjectRule < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :approval_project_rules, :orchestration_policy_idx, :integer, limit: 2
- end
-end
diff --git a/db/migrate/20211108211434_remove_index_for_resource_group.rb b/db/migrate/20211108211434_remove_index_for_resource_group.rb
deleted file mode 100644
index 8b03f12d08b..00000000000
--- a/db/migrate/20211108211434_remove_index_for_resource_group.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveIndexForResourceGroup < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_for_resource_group'
-
- disable_ddl_transaction!
-
- def up
- remove_concurrent_index_by_name :ci_builds, INDEX_NAME
- end
-
- def down
- # rubocop:disable Migration/PreventIndexCreation
- add_concurrent_index :ci_builds, [:resource_group_id, :id], where: 'resource_group_id IS NOT NULL', name: INDEX_NAME
- # rubocop:enable Migration/PreventIndexCreation
- end
-end
diff --git a/db/migrate/20211109100050_add_consume_after_to_loose_fk_deleted_records.rb b/db/migrate/20211109100050_add_consume_after_to_loose_fk_deleted_records.rb
deleted file mode 100644
index 6b8e8c0d4f3..00000000000
--- a/db/migrate/20211109100050_add_consume_after_to_loose_fk_deleted_records.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddConsumeAfterToLooseFkDeletedRecords < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def up
- add_column :loose_foreign_keys_deleted_records, :consume_after, :datetime_with_timezone, default: -> { 'NOW()' }
- end
-
- def down
- remove_column :loose_foreign_keys_deleted_records, :consume_after
- end
-end
diff --git a/db/migrate/20211109101010_support_partition_query_in_loose_fk_table.rb b/db/migrate/20211109101010_support_partition_query_in_loose_fk_table.rb
deleted file mode 100644
index fccb1fc5cac..00000000000
--- a/db/migrate/20211109101010_support_partition_query_in_loose_fk_table.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class SupportPartitionQueryInLooseFkTable < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::PartitioningMigrationHelpers
-
- disable_ddl_transaction!
-
- INDEX_NAME = 'index_loose_foreign_keys_deleted_records_for_partitioned_query'
-
- def up
- add_concurrent_partitioned_index :loose_foreign_keys_deleted_records,
- %I[partition fully_qualified_table_name consume_after id],
- where: 'status = 1',
- name: INDEX_NAME
- end
-
- def down
- remove_concurrent_partitioned_index_by_name :loose_foreign_keys_deleted_records, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211110010101_add_index_on_unarchived_deployments.rb b/db/migrate/20211110010101_add_index_on_unarchived_deployments.rb
deleted file mode 100644
index 0bfafb94d0b..00000000000
--- a/db/migrate/20211110010101_add_index_on_unarchived_deployments.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddIndexOnUnarchivedDeployments < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_deployments_on_archived_project_id_iid'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :deployments, %i[archived project_id iid], name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :deployments, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211110014701_create_agent_activity_events.rb b/db/migrate/20211110014701_create_agent_activity_events.rb
deleted file mode 100644
index 11b9c6d03b3..00000000000
--- a/db/migrate/20211110014701_create_agent_activity_events.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-class CreateAgentActivityEvents < Gitlab::Database::Migration[1.0]
- def change
- create_table :agent_activity_events do |t|
- t.bigint :agent_id, null: false
- t.bigint :user_id, index: { where: 'user_id IS NOT NULL' }
- t.bigint :project_id, index: { where: 'project_id IS NOT NULL' }
- t.bigint :merge_request_id, index: { where: 'merge_request_id IS NOT NULL' }
- t.bigint :agent_token_id, index: { where: 'agent_token_id IS NOT NULL' }
-
- t.datetime_with_timezone :recorded_at, null: false
- t.integer :kind, limit: 2, null: false
- t.integer :level, limit: 2, null: false
-
- t.binary :sha
- t.text :detail, limit: 255
-
- t.index [:agent_id, :recorded_at, :id]
- end
- end
-end
diff --git a/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb b/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb
deleted file mode 100644
index fcbafcccb06..00000000000
--- a/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-class AddAgentActivityEventsForeignKeys < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :agent_activity_events, :cluster_agents, column: :agent_id, on_delete: :cascade
- add_concurrent_foreign_key :agent_activity_events, :users, column: :user_id, on_delete: :nullify
- add_concurrent_foreign_key :agent_activity_events, :projects, column: :project_id, on_delete: :nullify
- add_concurrent_foreign_key :agent_activity_events, :merge_requests, column: :merge_request_id, on_delete: :nullify
- add_concurrent_foreign_key :agent_activity_events, :cluster_agent_tokens, column: :agent_token_id, on_delete: :nullify
- end
-
- def down
- with_lock_retries do
- remove_foreign_key_if_exists :agent_activity_events, column: :agent_id
- end
-
- with_lock_retries do
- remove_foreign_key_if_exists :agent_activity_events, column: :user_id
- end
-
- with_lock_retries do
- remove_foreign_key_if_exists :agent_activity_events, column: :project_id
- end
-
- with_lock_retries do
- remove_foreign_key_if_exists :agent_activity_events, column: :merge_request_id
- end
-
- with_lock_retries do
- remove_foreign_key_if_exists :agent_activity_events, column: :agent_token_id
- end
- end
-end
diff --git a/db/migrate/20211110092710_create_issue_emails.rb b/db/migrate/20211110092710_create_issue_emails.rb
deleted file mode 100644
index 5f6104fa2c3..00000000000
--- a/db/migrate/20211110092710_create_issue_emails.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-# See https://docs.gitlab.com/ee/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class CreateIssueEmails < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def up
- create_table :issue_emails do |t|
- t.references :issue, index: true, null: false, unique: true, foreign_key: { on_delete: :cascade }
- t.text :email_message_id, null: false, limit: 1000
-
- t.index :email_message_id
- end
- end
-
- def down
- drop_table :issue_emails
- end
-end
diff --git a/db/migrate/20211110100050_add_has_shimo_to_project_settings.rb b/db/migrate/20211110100050_add_has_shimo_to_project_settings.rb
deleted file mode 100644
index 01507908e0f..00000000000
--- a/db/migrate/20211110100050_add_has_shimo_to_project_settings.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddHasShimoToProjectSettings < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :project_settings, :has_shimo, :boolean, default: false, null: false
- end
-end
diff --git a/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb b/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb
deleted file mode 100644
index 064dc38f5b3..00000000000
--- a/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class CreateMergeRequestsComplianceViolations < Gitlab::Database::Migration[1.0]
- def change
- create_table :merge_requests_compliance_violations do |t|
- t.bigint :violating_user_id, null: false
- t.bigint :merge_request_id, null: false
- t.integer :reason, limit: 2, null: false
- t.index :violating_user_id
- t.index [:merge_request_id, :violating_user_id, :reason], unique: true, name: 'index_merge_requests_compliance_violations_unique_columns'
- end
- end
-end
diff --git a/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb b/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb
deleted file mode 100644
index b280c35433b..00000000000
--- a/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AddFkComplianceViolationsMergeRequest < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :merge_requests_compliance_violations,
- :merge_requests,
- column: :merge_request_id,
- on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :merge_requests_compliance_violations, column: :merge_request_id
- end
- end
-end
diff --git a/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb b/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb
deleted file mode 100644
index af1cd6f07ed..00000000000
--- a/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AddFkComplianceViolationsViolatingUser < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :merge_requests_compliance_violations,
- :users,
- column: :violating_user_id,
- on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :merge_requests_compliance_violations, column: :violating_user_id
- end
- end
-end
diff --git a/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb b/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb
deleted file mode 100644
index 6120a6ed0b4..00000000000
--- a/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddSquashCommitTemplateToProjectSettings < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :project_settings, :squash_commit_template, :text # rubocop:disable Migration/AddLimitToTextColumns
- end
-end
diff --git a/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb b/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb
deleted file mode 100644
index 578d2271d60..00000000000
--- a/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddSquashCommitTemplateLimitToProjectSettings < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :project_settings, :squash_commit_template, 500
- end
-
- def down
- remove_text_limit :project_settings, :squash_commit_template
- end
-end
diff --git a/db/migrate/20211112073413_change_package_index_on_corpus.rb b/db/migrate/20211112073413_change_package_index_on_corpus.rb
deleted file mode 100644
index 6e8222f853c..00000000000
--- a/db/migrate/20211112073413_change_package_index_on_corpus.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-class ChangePackageIndexOnCorpus < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_coverage_fuzzing_corpuses_on_package_id'
-
- disable_ddl_transaction!
-
- # Changing this index is safe.
- # The table does not have any data in it as it's behind a feature flag.
- def up
- remove_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME
- add_concurrent_index :coverage_fuzzing_corpuses, :package_id, unique: true, name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME
- add_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME
- end
-end
diff --git a/db/migrate/20211112155416_populate_default_value_for_personal_access_tokens_prefix.rb b/db/migrate/20211112155416_populate_default_value_for_personal_access_tokens_prefix.rb
deleted file mode 100644
index 8dd23e1a72e..00000000000
--- a/db/migrate/20211112155416_populate_default_value_for_personal_access_tokens_prefix.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class PopulateDefaultValueForPersonalAccessTokensPrefix < Gitlab::Database::Migration[1.0]
- def up
- execute(
- <<-SQL
- UPDATE
- application_settings
- SET
- personal_access_token_prefix = default
- WHERE
- personal_access_token_prefix IS NULL
- SQL
- )
- end
-
- def down
- # no-op
- end
-end
diff --git a/db/migrate/20211115132613_create_incident_management_timeline_events.rb b/db/migrate/20211115132613_create_incident_management_timeline_events.rb
deleted file mode 100644
index 217dcd27b4c..00000000000
--- a/db/migrate/20211115132613_create_incident_management_timeline_events.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-class CreateIncidentManagementTimelineEvents < Gitlab::Database::Migration[1.0]
- def up
- create_table :incident_management_timeline_events do |t|
- t.timestamps_with_timezone null: false
- t.datetime_with_timezone :occurred_at, null: false
- t.bigint :project_id, null: false
- t.bigint :author_id
- t.bigint :issue_id, null: false
- t.bigint :updated_by_user_id
- t.bigint :promoted_from_note_id
- t.integer :cached_markdown_version
- t.boolean :editable, null: false, default: false
- t.text :note, limit: 10_000, null: false
- t.text :note_html, limit: 10_000, null: false
- t.text :action, limit: 128, null: false
-
- t.index :project_id, name: 'index_im_timeline_events_project_id'
- t.index :author_id, name: 'index_im_timeline_events_author_id'
- t.index :issue_id, name: 'index_im_timeline_events_issue_id'
- t.index :updated_by_user_id, name: 'index_im_timeline_events_updated_by_user_id'
- t.index :promoted_from_note_id, name: 'index_im_timeline_events_promoted_from_note_id'
- end
- end
-
- def down
- drop_table :incident_management_timeline_events
- end
-end
diff --git a/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb b/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb
deleted file mode 100644
index 893043cc1ab..00000000000
--- a/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToIncidentManagementTimelineEventsOnProject < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :incident_management_timeline_events, :projects, column: :project_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :incident_management_timeline_events, column: :project_id
- end
- end
-end
diff --git a/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb b/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb
deleted file mode 100644
index 0f5886eb5ed..00000000000
--- a/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToIncidentManagementTimelineEventsOnUser < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :author_id, on_delete: :nullify
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :incident_management_timeline_events, column: :author_id
- end
- end
-end
diff --git a/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb b/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb
deleted file mode 100644
index bdcf7f389d1..00000000000
--- a/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToIncidentManagementTimelineEventsOnIssue < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :incident_management_timeline_events, :issues, column: :issue_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :incident_management_timeline_events, column: :issue_id
- end
- end
-end
diff --git a/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb b/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb
deleted file mode 100644
index e0e2bec72ad..00000000000
--- a/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class AddCreatedAtToNamespaceMonthlyUsages < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- with_lock_retries do
- add_column :ci_namespace_monthly_usages, :created_at, :datetime_with_timezone
- end
- end
-
- def down
- with_lock_retries do
- remove_column :ci_namespace_monthly_usages, :created_at
- end
- end
-end
diff --git a/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb b/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb
deleted file mode 100644
index eb0cd448da3..00000000000
--- a/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class AddCreatedAtToProjectMonthlyUsage < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- with_lock_retries do
- add_column :ci_project_monthly_usages, :created_at, :datetime_with_timezone
- end
- end
-
- def down
- with_lock_retries do
- remove_column :ci_project_monthly_usages, :created_at
- end
- end
-end
diff --git a/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb b/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb
deleted file mode 100644
index a35020699fc..00000000000
--- a/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToIncidentManagementTimelineEventsOnUpdatedByUser < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :updated_by_user_id, on_delete: :nullify
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :incident_management_timeline_events, column: :updated_by_user_id
- end
- end
-end
diff --git a/db/migrate/20211117174209_create_vulnerability_reads.rb b/db/migrate/20211117174209_create_vulnerability_reads.rb
deleted file mode 100644
index b9e32bfd0fa..00000000000
--- a/db/migrate/20211117174209_create_vulnerability_reads.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-class CreateVulnerabilityReads < Gitlab::Database::Migration[1.0]
- def change
- create_table :vulnerability_reads do |t|
- t.bigint :vulnerability_id, null: false
- t.bigint :project_id, null: false
- t.bigint :scanner_id, null: false
- t.integer :report_type, limit: 2, null: false
- t.integer :severity, limit: 2, null: false
- t.integer :state, limit: 2, null: false
- t.boolean :has_issues, default: false, null: false
- t.boolean :resolved_on_default_branch, default: false, null: false
- t.uuid :uuid, null: false
- t.text :location_image, limit: 2048
-
- t.index :vulnerability_id, unique: true
- t.index :scanner_id
- t.index :uuid, unique: true
- t.index [:project_id, :state, :severity, :vulnerability_id], name: :index_vuln_reads_on_project_id_state_severity_and_vuln_id, order: { vulnerability_id: :desc }
- t.index :location_image, where: "report_type IN (2, 7)", name: :index_vulnerability_reads_on_location_image
- end
- end
-end
diff --git a/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb b/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb
deleted file mode 100644
index 185178d8025..00000000000
--- a/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class ChangeDefaultValueOfLooseFkDeletedRecordsPartition < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- change_column_default(:loose_foreign_keys_deleted_records, :partition, from: nil, to: 1)
- end
-end
diff --git a/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb b/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb
deleted file mode 100644
index 33159167b19..00000000000
--- a/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveHardcodedPartitionFromLooseFkTriggerFunction < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
-
- enable_lock_retries!
-
- def up
- execute(<<~SQL)
- CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}()
- RETURNS TRIGGER AS
- $$
- BEGIN
- INSERT INTO loose_foreign_keys_deleted_records
- (fully_qualified_table_name, primary_key_value)
- SELECT TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table;
-
- RETURN NULL;
- END
- $$ LANGUAGE PLPGSQL
- SQL
- end
-
- def down
- execute(<<~SQL)
- CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}()
- RETURNS TRIGGER AS
- $$
- BEGIN
- INSERT INTO loose_foreign_keys_deleted_records
- (partition, fully_qualified_table_name, primary_key_value)
- SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table
- ON CONFLICT DO NOTHING;
-
- RETURN NULL;
- END
- $$ LANGUAGE PLPGSQL
- SQL
- end
-end
diff --git a/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb b/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb
deleted file mode 100644
index 1b0d2104c91..00000000000
--- a/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddMaxSshKeyLifetimeToApplicationSettings < Gitlab::Database::Migration[1.0]
- def change
- add_column :application_settings, :max_ssh_key_lifetime, :integer
- end
-end
diff --git a/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb b/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb
deleted file mode 100644
index dd5b0bdc028..00000000000
--- a/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToVulnerabilityReadsOnVulnerability < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :vulnerability_reads, :vulnerabilities, column: :vulnerability_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :vulnerability_reads, column: :vulnerability_id
- end
- end
-end
diff --git a/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb b/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb
deleted file mode 100644
index 14dde371e3d..00000000000
--- a/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToVulnerabilityReadsOnProject < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :vulnerability_reads, :projects, column: :project_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :vulnerability_reads, column: :project_id
- end
- end
-end
diff --git a/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb b/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb
deleted file mode 100644
index 923e62a4beb..00000000000
--- a/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToVulnerabilityReadsOnScanner < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :vulnerability_reads, :vulnerability_scanners, column: :scanner_id, on_delete: :cascade
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :vulnerability_reads, column: :scanner_id
- end
- end
-end
diff --git a/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb b/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb
deleted file mode 100644
index f52bc346d16..00000000000
--- a/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-class AddOrignalFilenameToCiJobArtifact < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- # rubocop:disable Migration/AddLimitToTextColumns
- # limit is added in 20211119085036_add_text_limit_to_job_artifact_original_filename.rb
- def up
- add_column :ci_job_artifacts, :original_filename, :text
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-
- def down
- remove_column :ci_job_artifacts, :original_filename, :text
- end
-end
diff --git a/db/migrate/20211119111006_create_job_artifact_states.rb b/db/migrate/20211119111006_create_job_artifact_states.rb
deleted file mode 100644
index 44dffed58ee..00000000000
--- a/db/migrate/20211119111006_create_job_artifact_states.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-class CreateJobArtifactStates < Gitlab::Database::Migration[1.0]
- VERIFICATION_STATE_INDEX_NAME = "index_job_artifact_states_on_verification_state"
- PENDING_VERIFICATION_INDEX_NAME = "index_job_artifact_states_pending_verification"
- FAILED_VERIFICATION_INDEX_NAME = "index_job_artifact_states_failed_verification"
- NEEDS_VERIFICATION_INDEX_NAME = "index_job_artifact_states_needs_verification"
-
- enable_lock_retries!
-
- def up
- create_table :ci_job_artifact_states, id: false do |t|
- t.datetime_with_timezone :verification_started_at
- t.datetime_with_timezone :verification_retry_at
- t.datetime_with_timezone :verified_at
- t.references :job_artifact, primary_key: true, null: false, foreign_key: { on_delete: :cascade, to_table: :ci_job_artifacts }
- t.integer :verification_state, default: 0, limit: 2, null: false
- t.integer :verification_retry_count, limit: 2
- t.binary :verification_checksum, using: 'verification_checksum::bytea'
- t.text :verification_failure, limit: 255
-
- t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
- t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
- t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
- t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
- end
- end
-
- def down
- drop_table :ci_job_artifact_states
- end
-end
diff --git a/db/migrate/20211119154221_create_pages_deployment_states.rb b/db/migrate/20211119154221_create_pages_deployment_states.rb
deleted file mode 100644
index 283f6c7d0d7..00000000000
--- a/db/migrate/20211119154221_create_pages_deployment_states.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-class CreatePagesDeploymentStates < Gitlab::Database::Migration[1.0]
- VERIFICATION_STATE_INDEX_NAME = "index_pages_deployment_states_on_verification_state"
- PENDING_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_pending_verification"
- FAILED_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_failed_verification"
- NEEDS_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_needs_verification"
-
- disable_ddl_transaction!
-
- def up
- unless table_exists?(:pages_deployment_states)
- with_lock_retries do
- create_table :pages_deployment_states, id: false do |t|
- t.references :pages_deployment, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
- t.integer :verification_state, default: 0, limit: 2, null: false
- t.column :verification_started_at, :datetime_with_timezone
- t.datetime_with_timezone :verification_retry_at
- t.datetime_with_timezone :verified_at
- t.integer :verification_retry_count, limit: 2
- t.binary :verification_checksum, using: 'verification_checksum::bytea'
- t.text :verification_failure
-
- t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
- t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
- t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
- t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
- end
- end
- end
-
- add_text_limit :pages_deployment_states, :verification_failure, 255
- end
-
- def down
- drop_table :pages_deployment_states
- end
-end
diff --git a/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb b/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb
deleted file mode 100644
index 9064242ee30..00000000000
--- a/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveTestReportRequirementIssueConstraint < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- TARGET_TABLE = :requirements_management_test_reports
- CONSTRAINT_NAME = 'requirements_test_reports_requirement_id_xor_issue_id'
-
- def up
- remove_check_constraint TARGET_TABLE, CONSTRAINT_NAME
- end
-
- def down
- add_check_constraint(TARGET_TABLE, 'num_nonnulls(requirement_id, issue_id) = 1', CONSTRAINT_NAME)
- end
-end
diff --git a/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb b/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb
deleted file mode 100644
index ca6b78efbc7..00000000000
--- a/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddRequiredApprovalCountToProtectedEnvironments < Gitlab::Database::Migration[1.0]
- def change
- add_column :protected_environments, :required_approval_count, :integer, default: 0, null: false
- end
-end
diff --git a/db/migrate/20211119195201_create_deployment_approvals.rb b/db/migrate/20211119195201_create_deployment_approvals.rb
deleted file mode 100644
index a238da302f9..00000000000
--- a/db/migrate/20211119195201_create_deployment_approvals.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class CreateDeploymentApprovals < Gitlab::Database::Migration[1.0]
- def change
- create_table :deployment_approvals do |t|
- t.bigint :deployment_id, null: false
- t.bigint :user_id, null: false, index: true
- t.timestamps_with_timezone null: false
- t.integer :status, limit: 2, null: false
- t.index [:deployment_id, :user_id], unique: true
- end
- end
-end
diff --git a/db/migrate/20211122103051_add_line_code_to_draft_notes.rb b/db/migrate/20211122103051_add_line_code_to_draft_notes.rb
deleted file mode 100644
index c78b75f3a33..00000000000
--- a/db/migrate/20211122103051_add_line_code_to_draft_notes.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-class AddLineCodeToDraftNotes < Gitlab::Database::Migration[1.0]
- # rubocop:disable Migration/AddLimitToTextColumns
- # limit is added in db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb
- def change
- add_column :draft_notes, :line_code, :text
- end
- # rubocop:enable Migration/AddLimitToTextColumns
-end
diff --git a/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb b/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb
deleted file mode 100644
index b1c7bc4d5ce..00000000000
--- a/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class AddPolicyIdxToApprovalMergeRequestRule < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def change
- add_column :approval_merge_request_rules, :orchestration_policy_idx, :integer, limit: 2
- end
-end
diff --git a/db/migrate/20211123135255_create_batched_background_migration_job_transition_logs.rb b/db/migrate/20211123135255_create_batched_background_migration_job_transition_logs.rb
deleted file mode 100644
index 280626c5d3b..00000000000
--- a/db/migrate/20211123135255_create_batched_background_migration_job_transition_logs.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-class CreateBatchedBackgroundMigrationJobTransitionLogs < Gitlab::Database::Migration[1.0]
- include Gitlab::Database::PartitioningMigrationHelpers
-
- def up
- execute(<<~SQL)
- CREATE TABLE batched_background_migration_job_transition_logs (
- id bigserial NOT NULL,
- batched_background_migration_job_id bigint NOT NULL,
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL,
- previous_status smallint NOT NULL,
- next_status smallint NOT NULL,
- exception_class text,
- exception_message text,
- CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)),
- CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)),
- PRIMARY KEY (id, created_at)
- ) PARTITION BY RANGE (created_at);
-
- CREATE INDEX i_batched_background_migration_job_transition_logs_on_job_id
- ON batched_background_migration_job_transition_logs USING btree (batched_background_migration_job_id);
-
- ALTER TABLE batched_background_migration_job_transition_logs ADD CONSTRAINT fk_rails_b7523a175b
- FOREIGN KEY (batched_background_migration_job_id) REFERENCES batched_background_migration_jobs(id) ON DELETE CASCADE;
- SQL
-
- min_date = Date.today
- max_date = Date.today + 6.months
-
- create_daterange_partitions('batched_background_migration_job_transition_logs', 'created_at', min_date, max_date)
- end
-
- def down
- drop_table :batched_background_migration_job_transition_logs
- end
-end
diff --git a/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb b/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb
deleted file mode 100644
index da20e9a8f8e..00000000000
--- a/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddUserForeignKeyToDeploymentApprovals < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :deployment_approvals, :users, column: :user_id
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :deployment_approvals, :users
- end
- end
-end
diff --git a/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb b/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb
deleted file mode 100644
index 10a0c6ca402..00000000000
--- a/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class MakeIterationCadencesStartDateNullable < Gitlab::Database::Migration[1.0]
- def change
- change_column_null :iterations_cadences, :start_date, true
- end
-end
diff --git a/db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb b/db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb
deleted file mode 100644
index b3567d6b873..00000000000
--- a/db/migrate/20211124095704_add_draft_notes_line_code_text_limit.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddDraftNotesLineCodeTextLimit < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :draft_notes, :line_code, 255
- end
-
- def down
- remove_text_limit :draft_notes, :line_code
- end
-end
diff --git a/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb b/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb
deleted file mode 100644
index 868bc4f14f2..00000000000
--- a/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-class AddEncryptedStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0]
- def up
- # rubocop:disable Migration/AddLimitToTextColumns
- # limit is added in 20211126113029_add_text_limit_for_static_objects_external_storage_auth_token
- add_column :application_settings, :static_objects_external_storage_auth_token_encrypted, :text
- # rubocop:enable Migration/AddLimitToTextColumns
- end
-
- def down
- remove_column :application_settings, :static_objects_external_storage_auth_token_encrypted
- end
-end
diff --git a/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb b/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb
deleted file mode 100644
index cbe5dbf99fc..00000000000
--- a/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-class AddSequenceColumnToSprintsTable < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def up
- add_column :sprints, :sequence, :integer
- execute "ALTER TABLE sprints ADD CONSTRAINT sequence_is_unique_per_iterations_cadence_id UNIQUE (iterations_cadence_id, sequence) DEFERRABLE INITIALLY DEFERRED"
- end
-
- def down
- remove_column :sprints, :sequence
- end
-end
diff --git a/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb b/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb
deleted file mode 100644
index 45c4686e674..00000000000
--- a/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-class AddTextLimitForStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :application_settings, :static_objects_external_storage_auth_token_encrypted, 255
- end
-
- def down
- remove_text_limit :application_settings, :static_objects_external_storage_auth_token_encrypted
- end
-end
diff --git a/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb b/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb
deleted file mode 100644
index 92ba54d4c89..00000000000
--- a/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-class EncryptStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0]
- class ApplicationSetting < ActiveRecord::Base
- self.table_name = 'application_settings'
-
- scope :encrypted_token_is_null, -> { where(static_objects_external_storage_auth_token_encrypted: nil) }
- scope :encrypted_token_is_not_null, -> { where.not(static_objects_external_storage_auth_token_encrypted: nil) }
- scope :plaintext_token_is_not_null, -> { where.not(static_objects_external_storage_auth_token: nil) }
- end
-
- def up
- ApplicationSetting.reset_column_information
-
- ApplicationSetting.encrypted_token_is_null.plaintext_token_is_not_null.find_each do |application_setting|
- next if application_setting.static_objects_external_storage_auth_token.empty?
-
- token_encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(application_setting.static_objects_external_storage_auth_token)
- application_setting.update!(static_objects_external_storage_auth_token_encrypted: token_encrypted)
- end
- end
-
- def down
- ApplicationSetting.reset_column_information
-
- ApplicationSetting.encrypted_token_is_not_null.find_each do |application_setting|
- token = Gitlab::CryptoHelper.aes256_gcm_decrypt(application_setting.static_objects_external_storage_auth_token_encrypted)
- application_setting.update!(static_objects_external_storage_auth_token: token, static_objects_external_storage_auth_token_encrypted: nil)
- end
- end
-end
diff --git a/db/migrate/20211126142200_add_encrypted_static_object_token.rb b/db/migrate/20211126142200_add_encrypted_static_object_token.rb
deleted file mode 100644
index 839354244e7..00000000000
--- a/db/migrate/20211126142200_add_encrypted_static_object_token.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-class AddEncryptedStaticObjectToken < Gitlab::Database::Migration[1.0]
- enable_lock_retries!
-
- def up
- # rubocop:disable Migration/AddLimitToTextColumns
- # limit is added in 20211126142354_add_text_limit_to_encrypted_static_object_token
- add_column :users, :static_object_token_encrypted, :text # rubocop:disable Migration/AddColumnsToWideTables
- # rubocop:enable Migration/AddLimitToTextColumns
- end
-
- def down
- remove_column :users, :static_object_token_encrypted
- end
-end
diff --git a/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb b/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb
deleted file mode 100644
index a43e7d9a741..00000000000
--- a/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-class AddTextLimitToEncryptedStaticObjectToken < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_text_limit :users, :static_object_token_encrypted, 255
- end
-
- def down
- remove_text_limit :users, :static_object_token_encrypted
- end
-end
diff --git a/db/migrate/20211126204445_add_task_to_work_item_types.rb b/db/migrate/20211126204445_add_task_to_work_item_types.rb
deleted file mode 100644
index 875c2272c6d..00000000000
--- a/db/migrate/20211126204445_add_task_to_work_item_types.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-class AddTaskToWorkItemTypes < Gitlab::Database::Migration[1.0]
- TASK_ENUM_VALUE = 4
-
- class WorkItemType < ActiveRecord::Base
- self.inheritance_column = :_type_disabled
- self.table_name = 'work_item_types'
-
- validates :name, uniqueness: { case_sensitive: false, scope: [:namespace_id] }
- end
-
- def up
- # New instances will not run this migration and add this type via fixtures
- # checking if record exists mostly because migration specs will run all migrations
- # and that will conflict with the preloaded base work item types
- task_work_item = WorkItemType.find_by(name: 'Task', namespace_id: nil)
-
- if task_work_item
- say('Task item record exist, skipping creation')
- else
- WorkItemType.create(name: 'Task', namespace_id: nil, base_type: TASK_ENUM_VALUE, icon_name: 'issue-type-task')
- end
- end
-
- def down
- # There's the remote possibility that issues could already be
- # using this issue type, with a tight foreign constraint.
- # Therefore we will not attempt to remove any data.
- end
-end
diff --git a/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb b/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb
deleted file mode 100644
index 8c3cf82d7c7..00000000000
--- a/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddMigratedToNewStructureColumnToVulnerabilityOccurrences < Gitlab::Database::Migration[1.0]
- def change
- add_column :vulnerability_occurrences, :migrated_to_new_structure, :boolean, default: false, null: false
- end
-end
diff --git a/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb b/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb
deleted file mode 100644
index 4cf8263f8f0..00000000000
--- a/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddIndexOnVulnerabilityOccurrencesMigratedToNewStructureColumn < Gitlab::Database::Migration[1.0]
- INDEX_NAME = 'index_vulnerability_occurrences_on_migrated_to_new_structure'
-
- disable_ddl_transaction!
-
- def up
- add_concurrent_index :vulnerability_occurrences, [:migrated_to_new_structure, :id], name: INDEX_NAME
- end
-
- def down
- remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME
- end
-end
diff --git a/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb b/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb
deleted file mode 100644
index a09409900f7..00000000000
--- a/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddForeignKeyToIncidentManagementTimelineEventsOnNote < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :incident_management_timeline_events, :notes, column: :promoted_from_note_id, on_delete: :nullify
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :incident_management_timeline_events, column: :promoted_from_note_id
- end
- end
-end
diff --git a/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb b/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb
deleted file mode 100644
index 1aca3e7e8e2..00000000000
--- a/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AddUniquenessForEvidenceOccurrenceId < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- INDEX_NAME = 'finding_evidences_on_vulnerability_occurrence_id'
- UNIQUE_INDEX_NAME = 'finding_evidences_on_unique_vulnerability_occurrence_id'
-
- def up
- add_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], unique: true, name: UNIQUE_INDEX_NAME
- remove_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: INDEX_NAME
- end
-
- def down
- add_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: INDEX_NAME
- remove_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: UNIQUE_INDEX_NAME
- end
-end
diff --git a/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb b/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb
deleted file mode 100644
index 9cbbef42327..00000000000
--- a/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class AddFutureSubscriptionsToApplicationSettings < Gitlab::Database::Migration[1.0]
- def change
- add_column :application_settings, :future_subscriptions, :jsonb, null: false, default: []
- end
-end
diff --git a/db/migrate/20211201143042_create_lfs_object_states.rb b/db/migrate/20211201143042_create_lfs_object_states.rb
deleted file mode 100644
index 91accbcd438..00000000000
--- a/db/migrate/20211201143042_create_lfs_object_states.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-class CreateLfsObjectStates < Gitlab::Database::Migration[1.0]
- VERIFICATION_STATE_INDEX_NAME = "index_lfs_object_states_on_verification_state"
- PENDING_VERIFICATION_INDEX_NAME = "index_lfs_object_states_pending_verification"
- FAILED_VERIFICATION_INDEX_NAME = "index_lfs_object_states_failed_verification"
- NEEDS_VERIFICATION_INDEX_NAME = "index_lfs_object_states_needs_verification"
-
- disable_ddl_transaction!
-
- def up
- create_table :lfs_object_states, id: false do |t|
- t.datetime_with_timezone :verification_started_at
- t.datetime_with_timezone :verification_retry_at
- t.datetime_with_timezone :verified_at
- t.references :lfs_object, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
- t.integer :verification_state, default: 0, limit: 2, null: false
- t.integer :verification_retry_count, limit: 2
- t.binary :verification_checksum, using: 'verification_checksum::bytea'
- t.text :verification_failure, limit: 255
-
- t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
- t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
- t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
- t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
- end
- end
-
- def down
- drop_table :lfs_object_states
- end
-end
diff --git a/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb b/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb
deleted file mode 100644
index 60bc892d792..00000000000
--- a/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class AddDeploymentForeignKeyToDeploymentApprovals < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- def up
- add_concurrent_foreign_key :deployment_approvals, :deployments, column: :deployment_id
- end
-
- def down
- with_lock_retries do
- remove_foreign_key :deployment_approvals, :deployments
- end
- end
-end
diff --git a/db/migrate/20210826171758_init_schema.rb b/db/migrate/20211202041233_init_schema.rb
index 971a3e0e2db..97027f8a9e4 100644
--- a/db/migrate/20210826171758_init_schema.rb
+++ b/db/migrate/20211202041233_init_schema.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class InitSchema < ActiveRecord::Migration[6.0]
+class InitSchema < Gitlab::Database::Migration[1.0]
DOWNTIME = false
def up
diff --git a/db/migrate/20221225010101_create_workspaces_table.rb b/db/migrate/20221225010101_create_workspaces_table.rb
new file mode 100644
index 00000000000..4c8bc26bcf6
--- /dev/null
+++ b/db/migrate/20221225010101_create_workspaces_table.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+class CreateWorkspacesTable < Gitlab::Database::Migration[2.1]
+ def up
+ create_table :workspaces do |t|
+ t.timestamps_with_timezone null: false
+ # NOTE: All workspace foreign key references are currently `on_delete: :cascade`, because we have no support or
+ # testing around null values. However, in the future we may want to switch these to nullify, especially
+ # once we start introducing logging, metrics, billing, etc. around workspaces.
+ t.bigint :user_id, null: false, index: true
+ t.bigint :project_id, null: false, index: true
+ t.bigint :cluster_agent_id, null: false, index: true
+ t.datetime_with_timezone :desired_state_updated_at, null: false
+ t.datetime_with_timezone :responded_to_agent_at
+ t.integer :max_hours_before_termination, limit: 2, null: false
+ t.text :name, limit: 64, null: false, index: { unique: true }
+ t.text :namespace, limit: 64, null: false
+ t.text :desired_state, limit: 32, null: false
+ t.text :actual_state, limit: 32, null: false
+ t.text :editor, limit: 256, null: false
+ t.text :devfile_ref, limit: 256, null: false
+ t.text :devfile_path, limit: 2048, null: false
+ # NOTE: The limit on the devfile fields are arbitrary, and only added to avoid a rubocop
+ # Migration/AddLimitToTextColumns error. We expect the average devfile side to be small, perhaps ~0.5k for a
+ # devfile and ~2k for a processed_devfile, but to account for unexpected usage resulting in larger files,
+ # we have specified 65535, which allows for a YAML file with over 800 lines of an average 80-character
+ # length.
+ t.text :devfile, limit: 65535
+ t.text :processed_devfile, limit: 65535
+ t.text :url, limit: 1024, null: false
+ # NOTE: The resource version is currently backed by etcd's mod_revision.
+ # However, it's important to note that the application should not rely on the implementation details of
+ # the versioning system maintained by Kubernetes. We may change the implementation of resource version
+ # in the future, such as to change it to a timestamp or per-object counter.
+ # https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
+ # The limit of 64 is arbitrary.
+ t.text :deployment_resource_version, limit: 64
+ end
+ end
+
+ def down
+ drop_table :workspaces
+ end
+end
diff --git a/db/migrate/20221225010102_create_workspaces_user_foreign_key.rb b/db/migrate/20221225010102_create_workspaces_user_foreign_key.rb
new file mode 100644
index 00000000000..f6c38f289d6
--- /dev/null
+++ b/db/migrate/20221225010102_create_workspaces_user_foreign_key.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateWorkspacesUserForeignKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ # NOTE: All workspace foreign key references are currently `on_delete: :cascade`, because we have no support or
+ # testing around null values. However, in the future we may want to switch these to nullify, especially
+ # once we start introducing logging, metrics, billing, etc. around workspaces.
+ add_concurrent_foreign_key :workspaces, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :workspaces, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20221225010103_create_workspaces_project_foreign_key.rb b/db/migrate/20221225010103_create_workspaces_project_foreign_key.rb
new file mode 100644
index 00000000000..fe2b6eec2e0
--- /dev/null
+++ b/db/migrate/20221225010103_create_workspaces_project_foreign_key.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateWorkspacesProjectForeignKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ # NOTE: All workspace foreign key references are currently `on_delete: :cascade`, because we have no support or
+ # testing around null values. However, in the future we may want to switch these to nullify, especially
+ # once we start introducing logging, metrics, billing, etc. around workspaces.
+ add_concurrent_foreign_key :workspaces, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :workspaces, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20221225010104_create_workspaces_cluster_agent_foreign_key.rb b/db/migrate/20221225010104_create_workspaces_cluster_agent_foreign_key.rb
new file mode 100644
index 00000000000..c7874349e86
--- /dev/null
+++ b/db/migrate/20221225010104_create_workspaces_cluster_agent_foreign_key.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateWorkspacesClusterAgentForeignKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ # NOTE: All workspace foreign key references are currently `on_delete: :cascade`, because we have no support or
+ # testing around null values. However, in the future we may want to switch these to nullify, especially
+ # once we start introducing logging, metrics, billing, etc. around workspaces.
+ add_concurrent_foreign_key :workspaces, :cluster_agents, column: :cluster_agent_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :workspaces, column: :cluster_agent_id
+ end
+ end
+end
diff --git a/db/migrate/20221225010105_create_remote_development_agent_configs_table.rb b/db/migrate/20221225010105_create_remote_development_agent_configs_table.rb
new file mode 100644
index 00000000000..f375f78b616
--- /dev/null
+++ b/db/migrate/20221225010105_create_remote_development_agent_configs_table.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateRemoteDevelopmentAgentConfigsTable < Gitlab::Database::Migration[2.1]
+ def up
+ create_table :remote_development_agent_configs do |t|
+ t.timestamps_with_timezone null: false
+ t.bigint :cluster_agent_id, null: false, index: true
+ t.boolean :enabled, null: false
+ t.text :dns_zone, null: false, limit: 256
+ end
+ end
+
+ def down
+ drop_table :remote_development_agent_configs
+ end
+end
diff --git a/db/migrate/20221225010106_create_remote_development_agent_config_agent_foreign_key.rb b/db/migrate/20221225010106_create_remote_development_agent_config_agent_foreign_key.rb
new file mode 100644
index 00000000000..b861f417168
--- /dev/null
+++ b/db/migrate/20221225010106_create_remote_development_agent_config_agent_foreign_key.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateRemoteDevelopmentAgentConfigAgentForeignKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :remote_development_agent_configs,
+ :cluster_agents, column: :cluster_agent_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :remote_development_agent_configs, column: :cluster_agent_id
+ end
+ end
+end
diff --git a/db/migrate/20221229172604_add_runner_registration_enabled_to_project_settings.rb b/db/migrate/20221229172604_add_runner_registration_enabled_to_project_settings.rb
new file mode 100644
index 00000000000..0e403dac24f
--- /dev/null
+++ b/db/migrate/20221229172604_add_runner_registration_enabled_to_project_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRunnerRegistrationEnabledToProjectSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :project_settings, :runner_registration_enabled, :boolean, default: true
+ end
+end
diff --git a/db/migrate/20230113164245_create_namespace_ldap_settings.rb b/db/migrate/20230113164245_create_namespace_ldap_settings.rb
new file mode 100644
index 00000000000..5ad72c00b47
--- /dev/null
+++ b/db/migrate/20230113164245_create_namespace_ldap_settings.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateNamespaceLdapSettings < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :namespace_ldap_settings, if_not_exists: true, id: false do |t|
+ t.references :namespace, primary_key: true, default: nil,
+ type: :bigint, index: false, foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.column :sync_last_start_at, :datetime_with_timezone
+ t.column :sync_last_update_at, :datetime_with_timezone
+ t.column :sync_last_successful_at, :datetime_with_timezone
+ t.integer :sync_status, null: false, default: 0, limit: 2
+ t.text :sync_error, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20230118135145_add_service_desk_custom_email_verifications.rb b/db/migrate/20230118135145_add_service_desk_custom_email_verifications.rb
new file mode 100644
index 00000000000..32f7f3392e6
--- /dev/null
+++ b/db/migrate/20230118135145_add_service_desk_custom_email_verifications.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddServiceDeskCustomEmailVerifications < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ create_table(:service_desk_custom_email_verifications, id: false, primary_key: :project_id) do |t|
+ t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
+ t.references :triggerer, index: true, foreign_key: { to_table: :users, on_delete: :nullify }
+ t.timestamps_with_timezone
+ t.datetime_with_timezone :triggered_at
+ t.integer :state, limit: 2, null: false, default: 0
+ t.integer :error, limit: 2
+ t.binary :encrypted_token
+ t.binary :encrypted_token_iv
+ end
+
+ execute "ALTER TABLE service_desk_custom_email_verifications ADD PRIMARY KEY (project_id);"
+ end
+
+ def down
+ drop_table :service_desk_custom_email_verifications
+ end
+end
diff --git a/db/migrate/20230127024835_add_database_apdex_settings_to_application_settings.rb b/db/migrate/20230127024835_add_database_apdex_settings_to_application_settings.rb
new file mode 100644
index 00000000000..70c4962d02d
--- /dev/null
+++ b/db/migrate/20230127024835_add_database_apdex_settings_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddDatabaseApdexSettingsToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :database_apdex_settings, :jsonb
+ end
+end
diff --git a/db/migrate/20230127030015_add_deny_all_outgoing_requests_to_application_settings.rb b/db/migrate/20230127030015_add_deny_all_outgoing_requests_to_application_settings.rb
new file mode 100644
index 00000000000..b12176a5541
--- /dev/null
+++ b/db/migrate/20230127030015_add_deny_all_outgoing_requests_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDenyAllOutgoingRequestsToApplicationSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :application_settings, :deny_all_requests_except_allowed, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb b/db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb
index 960421ae38e..4ce3643208e 100644
--- a/db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb
+++ b/db/migrate/20230127155217_add_id_column_to_package_metadata_join_table.rb
@@ -6,6 +6,10 @@ class AddIdColumnToPackageMetadataJoinTable < Gitlab::Database::Migration[2.1]
COMPOSITE_UNIQUE_INDEX = :i_pm_package_version_licenses_join_ids
def up
+ if Gitlab::Database::PostgresPartitionedTable.where(name: 'pm_package_version_licenses').exists?
+ recreate_unpartitioned_tables
+ end
+
drop_constraint(:pm_package_version_licenses, :pm_package_version_licenses_pkey, cascade: true)
add_column(:pm_package_version_licenses, :id, :primary_key)
add_concurrent_index(:pm_package_version_licenses, [:pm_package_version_id, :pm_license_id], unique: true,
@@ -13,8 +17,60 @@ class AddIdColumnToPackageMetadataJoinTable < Gitlab::Database::Migration[2.1]
end
def down
+ return if Gitlab::Database::PostgresPartitionedTable.where(name: 'pm_package_version_licenses').exists?
+
remove_column(:pm_package_version_licenses, :id)
add_primary_key_using_index(:pm_package_version_licenses, :pm_package_version_licenses_pkey, COMPOSITE_UNIQUE_INDEX)
remove_concurrent_index_by_name(:pm_package_version_licenses, COMPOSITE_UNIQUE_INDEX)
end
+
+ private
+
+ def recreate_unpartitioned_tables
+ drop_table(:pm_package_version_licenses, force: :cascade) # rubocop:disable Migration/DropTable
+ drop_table(:pm_package_versions, force: :cascade) # rubocop:disable Migration/DropTable
+ drop_table(:pm_packages, force: :cascade) # rubocop:disable Migration/DropTable
+
+ create_table :pm_packages do |t|
+ t.integer :purl_type, limit: 2, null: false
+ t.text :name, null: false, limit: 255
+ t.timestamps_with_timezone null: false
+ t.index [:purl_type, :name], name: 'i_pm_packages_purl_type_and_name', unique: true
+ end
+
+ create_table :pm_package_versions do |t|
+ t.references :pm_package,
+ index: false,
+ null: false,
+ foreign_key: {
+ to_table: :pm_packages,
+ column: :pm_package_id,
+ name: 'fk_rails_cf94c3e601',
+ on_delete: :cascade
+ }
+ t.text :version, null: false, limit: 255
+ t.timestamps_with_timezone null: false
+ t.index [:pm_package_id, :version], name: 'i_pm_package_versions_on_package_id_and_version', unique: true
+ t.index :pm_package_id, name: 'index_pm_package_versions_on_pm_package_id'
+ end
+
+ create_table :pm_package_version_licenses, primary_key: [:pm_package_version_id, :pm_license_id] do |t|
+ t.references :pm_package_version,
+ index: false,
+ null: false,
+ foreign_key: {
+ to_table: :pm_package_versions,
+ column: :pm_package_version_id,
+ name: 'fk_rails_30ddb7f837',
+ on_delete: :cascade
+ }
+ t.references :pm_license,
+ index: false,
+ null: false,
+ foreign_key: { name: 'fk_rails_7520ea026d', on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.index :pm_license_id, name: 'index_pm_package_version_licenses_on_pm_license_id'
+ t.index :pm_package_version_id, name: 'index_pm_package_version_licenses_on_pm_package_version_id'
+ end
+ end
end
diff --git a/db/migrate/20230201165656_create_container_repository_states.rb b/db/migrate/20230201165656_create_container_repository_states.rb
new file mode 100644
index 00000000000..0e84faf11ee
--- /dev/null
+++ b/db/migrate/20230201165656_create_container_repository_states.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+class CreateContainerRepositoryStates < Gitlab::Database::Migration[2.1]
+ VERIFICATION_STATE_INDEX_NAME = "index_container_repository_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_container_repository_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_container_repository_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_container_repository_states_needs_verification"
+
+ disable_ddl_transaction!
+
+ def up
+ create_table :container_repository_states, id: false do |t|
+ t.datetime_with_timezone :verification_started_at
+ t.datetime_with_timezone :verification_retry_at
+ t.datetime_with_timezone :verified_at
+ t.references :container_repository,
+ primary_key: true,
+ default: nil,
+ index: false,
+ foreign_key: { on_delete: :cascade }
+ t.integer :verification_state, default: 0, limit: 2, null: false
+ t.integer :verification_retry_count, default: 0, limit: 2, null: false
+ t.binary :verification_checksum, using: 'verification_checksum::bytea'
+ t.text :verification_failure, limit: 255
+
+ t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
+ t.index :verified_at,
+ where: "(verification_state = 0)",
+ order: { verified_at: 'ASC NULLS FIRST' },
+ name: PENDING_VERIFICATION_INDEX_NAME
+ t.index :verification_retry_at,
+ where: "(verification_state = 3)",
+ order: { verification_retry_at: 'ASC NULLS FIRST' },
+ name: FAILED_VERIFICATION_INDEX_NAME
+ t.index :verification_state,
+ where: "(verification_state = 0 OR verification_state = 3)",
+ name: NEEDS_VERIFICATION_INDEX_NAME
+ end
+ end
+
+ def down
+ drop_table :container_repository_states
+ end
+end
diff --git a/db/migrate/20230202094723_add_default_syntax_highlighting_theme_to_application_settings.rb b/db/migrate/20230202094723_add_default_syntax_highlighting_theme_to_application_settings.rb
new file mode 100644
index 00000000000..048afb51f26
--- /dev/null
+++ b/db/migrate/20230202094723_add_default_syntax_highlighting_theme_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddDefaultSyntaxHighlightingThemeToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :default_syntax_highlighting_theme, :integer, default: 1, null: false
+ end
+end
diff --git a/db/migrate/20230207002330_add_project_group_link_on_delete_cascade_fk.rb b/db/migrate/20230207002330_add_project_group_link_on_delete_cascade_fk.rb
new file mode 100644
index 00000000000..5d6f4961baf
--- /dev/null
+++ b/db/migrate/20230207002330_add_project_group_link_on_delete_cascade_fk.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddProjectGroupLinkOnDeleteCascadeFk < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(
+ :project_group_links,
+ :namespaces,
+ column: :group_id,
+ on_delete: :cascade,
+ validate: false
+ )
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :project_group_links, column: :group_id
+ end
+ end
+end
diff --git a/db/migrate/20230210152109_add_bulk_import_export_batches.rb b/db/migrate/20230210152109_add_bulk_import_export_batches.rb
new file mode 100644
index 00000000000..380f8a43aae
--- /dev/null
+++ b/db/migrate/20230210152109_add_bulk_import_export_batches.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddBulkImportExportBatches < Gitlab::Database::Migration[2.1]
+ def up
+ create_table :bulk_import_export_batches do |t|
+ t.references :export, index: true, null: false, foreign_key: {
+ to_table: :bulk_import_exports, on_delete: :cascade
+ }
+ t.timestamps_with_timezone null: false
+ t.integer :status, limit: 2, null: false, default: 0
+ t.integer :batch_number, null: false, default: 0
+ t.integer :objects_count, null: false, default: 0
+ t.text :error, limit: 255
+ t.index [:export_id, :batch_number], unique: true, name: 'i_bulk_import_export_batches_id_batch_number'
+ end
+ end
+
+ def down
+ drop_table :bulk_import_export_batches
+ end
+end
diff --git a/db/migrate/20230210153420_add_batched_column_to_bulk_import_exports.rb b/db/migrate/20230210153420_add_batched_column_to_bulk_import_exports.rb
new file mode 100644
index 00000000000..cfe4a2059bb
--- /dev/null
+++ b/db/migrate/20230210153420_add_batched_column_to_bulk_import_exports.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddBatchedColumnToBulkImportExports < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :bulk_import_exports, :batched, :boolean, null: false, default: false
+ add_column :bulk_import_exports, :batches_count, :integer, null: false, default: 0
+ add_column :bulk_import_exports, :total_objects_count, :integer, null: false, default: 0
+ end
+end
diff --git a/db/migrate/20230210155715_add_batch_id_to_bulk_import_export_uploads.rb b/db/migrate/20230210155715_add_batch_id_to_bulk_import_export_uploads.rb
new file mode 100644
index 00000000000..986d31a5839
--- /dev/null
+++ b/db/migrate/20230210155715_add_batch_id_to_bulk_import_export_uploads.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddBatchIdToBulkImportExportUploads < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :bulk_import_export_uploads, :batch_id, :bigint
+ end
+end
diff --git a/db/migrate/20230210160037_add_batch_foreign_key_to_bulk_import_export_uploads.rb b/db/migrate/20230210160037_add_batch_foreign_key_to_bulk_import_export_uploads.rb
new file mode 100644
index 00000000000..de0286f27ed
--- /dev/null
+++ b/db/migrate/20230210160037_add_batch_foreign_key_to_bulk_import_export_uploads.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddBatchForeignKeyToBulkImportExportUploads < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :bulk_import_export_uploads, :bulk_import_export_batches, column: :batch_id
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :bulk_import_export_uploads, column: :batch_id
+ end
+ end
+end
diff --git a/db/migrate/20230210160351_add_bulk_import_batch_trackers.rb b/db/migrate/20230210160351_add_bulk_import_batch_trackers.rb
new file mode 100644
index 00000000000..40f6341680f
--- /dev/null
+++ b/db/migrate/20230210160351_add_bulk_import_batch_trackers.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddBulkImportBatchTrackers < Gitlab::Database::Migration[2.1]
+ def up
+ create_table :bulk_import_batch_trackers do |t|
+ t.references :tracker, index: true, null: false, foreign_key: {
+ to_table: :bulk_import_trackers, on_delete: :cascade
+ }
+ t.timestamps_with_timezone null: false
+ t.integer :status, limit: 2, null: false, default: 0
+ t.integer :batch_number, null: false, default: 0
+ t.integer :fetched_objects_count, null: false, default: 0
+ t.integer :imported_objects_count, null: false, default: 0
+ t.text :error, limit: 255
+ t.index [:tracker_id, :batch_number], unique: true, name: 'i_bulk_import_trackers_id_batch_number'
+ end
+ end
+
+ def down
+ drop_table :bulk_import_batch_trackers
+ end
+end
diff --git a/db/migrate/20230210161002_add_batched_column_to_bulk_import_trackers.rb b/db/migrate/20230210161002_add_batched_column_to_bulk_import_trackers.rb
new file mode 100644
index 00000000000..5640164a117
--- /dev/null
+++ b/db/migrate/20230210161002_add_batched_column_to_bulk_import_trackers.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddBatchedColumnToBulkImportTrackers < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :bulk_import_trackers, :batched, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20230210171012_add_batch_id_index_to_bulk_import_export_uploads.rb b/db/migrate/20230210171012_add_batch_id_index_to_bulk_import_export_uploads.rb
new file mode 100644
index 00000000000..c2fd4198762
--- /dev/null
+++ b/db/migrate/20230210171012_add_batch_id_index_to_bulk_import_export_uploads.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddBatchIdIndexToBulkImportExportUploads < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'bulk_import_export_uploads_batch_id'
+
+ def up
+ add_concurrent_index :bulk_import_export_uploads, :batch_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :bulk_import_export_uploads, :batch_id, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230213213559_add_index_on_project_id_and_scanner_id_and_vulnerability_id_on_vulnerability_reads.rb b/db/migrate/20230213213559_add_index_on_project_id_and_scanner_id_and_vulnerability_id_on_vulnerability_reads.rb
new file mode 100644
index 00000000000..ee9e15d2484
--- /dev/null
+++ b/db/migrate/20230213213559_add_index_on_project_id_and_scanner_id_and_vulnerability_id_on_vulnerability_reads.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnProjectIdAndScannerIdAndVulnerabilityIdOnVulnerabilityReads < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = "idx_vulnerability_reads_project_id_scanner_id_vulnerability_id"
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerability_reads, [:project_id, :scanner_id, :vulnerability_id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230215074223_add_ci_runner_machine_builds_partitioned_table.rb b/db/migrate/20230215074223_add_ci_runner_machine_builds_partitioned_table.rb
new file mode 100644
index 00000000000..4e47d35d804
--- /dev/null
+++ b/db/migrate/20230215074223_add_ci_runner_machine_builds_partitioned_table.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class AddCiRunnerMachineBuildsPartitionedTable < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
+
+ enable_lock_retries!
+
+ TABLE_NAME = :ci_runner_machine_builds
+ PARENT_TABLE_NAME = :p_ci_runner_machine_builds
+ FIRST_PARTITION = 100
+
+ def up
+ execute(<<~SQL)
+ CREATE TABLE #{PARENT_TABLE_NAME} (
+ partition_id bigint NOT NULL,
+ build_id bigint NOT NULL,
+ runner_machine_id bigint NOT NULL,
+ PRIMARY KEY (partition_id, build_id),
+ CONSTRAINT fk_bb490f12fe_p FOREIGN KEY (partition_id, build_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE
+ )
+ PARTITION BY LIST (partition_id);
+
+ CREATE INDEX index_ci_runner_machine_builds_on_runner_machine_id ON #{PARENT_TABLE_NAME} USING btree (runner_machine_id);
+ SQL
+ end
+
+ def down
+ drop_table PARENT_TABLE_NAME
+ end
+end
diff --git a/db/migrate/20230215124011_add_provisioned_by_group_at_to_user_details.rb b/db/migrate/20230215124011_add_provisioned_by_group_at_to_user_details.rb
new file mode 100644
index 00000000000..3ff1cf6c6d4
--- /dev/null
+++ b/db/migrate/20230215124011_add_provisioned_by_group_at_to_user_details.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProvisionedByGroupAtToUserDetails < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :user_details, :provisioned_by_group_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20230215131026_add_has_failures_column_to_bulk_imports.rb b/db/migrate/20230215131026_add_has_failures_column_to_bulk_imports.rb
new file mode 100644
index 00000000000..52517244f3e
--- /dev/null
+++ b/db/migrate/20230215131026_add_has_failures_column_to_bulk_imports.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddHasFailuresColumnToBulkImports < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :bulk_imports, :has_failures, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20230215180605_index_sbom_occurrences_on_project_id_and_id.rb b/db/migrate/20230215180605_index_sbom_occurrences_on_project_id_and_id.rb
new file mode 100644
index 00000000000..34538a1a7ff
--- /dev/null
+++ b/db/migrate/20230215180605_index_sbom_occurrences_on_project_id_and_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class IndexSbomOccurrencesOnProjectIdAndId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_sbom_occurrences_on_project_id_and_id'
+
+ def up
+ add_concurrent_index :sbom_occurrences, [:project_id, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :sbom_occurrences, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230216040505_add_status_and_resolved_at_to_abuse_reports.rb b/db/migrate/20230216040505_add_status_and_resolved_at_to_abuse_reports.rb
new file mode 100644
index 00000000000..3cfd082b465
--- /dev/null
+++ b/db/migrate/20230216040505_add_status_and_resolved_at_to_abuse_reports.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddStatusAndResolvedAtToAbuseReports < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :abuse_reports, :status, :integer, limit: 2, default: 1, null: false
+ add_timestamps_with_timezone(:abuse_reports, columns: [:resolved_at], null: true)
+ end
+end
diff --git a/db/migrate/20230216071312_add_status_category_and_id_index_to_abuse_reports.rb b/db/migrate/20230216071312_add_status_category_and_id_index_to_abuse_reports.rb
new file mode 100644
index 00000000000..0c529f15b1b
--- /dev/null
+++ b/db/migrate/20230216071312_add_status_category_and_id_index_to_abuse_reports.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddStatusCategoryAndIdIndexToAbuseReports < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_abuse_reports_on_status_category_and_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :abuse_reports, [:status, :category, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :abuse_reports, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230216142836_update_vulnerability_reads_trigger_to_set_has_issue.rb b/db/migrate/20230216142836_update_vulnerability_reads_trigger_to_set_has_issue.rb
new file mode 100644
index 00000000000..73afa176b97
--- /dev/null
+++ b/db/migrate/20230216142836_update_vulnerability_reads_trigger_to_set_has_issue.rb
@@ -0,0 +1,185 @@
+# frozen_string_literal: true
+
+class UpdateVulnerabilityReadsTriggerToSetHasIssue < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_or_update_vulnerability_reads()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ severity smallint;
+ state smallint;
+ report_type smallint;
+ resolved_on_default_branch boolean;
+ present_on_default_branch boolean;
+ namespace_id bigint;
+ has_issues boolean;
+ BEGIN
+ IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
+ RETURN NULL;
+ END IF;
+
+ IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch, vulnerabilities.present_on_default_branch
+ INTO
+ severity, state, report_type, resolved_on_default_branch, present_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ IF present_on_default_branch IS NOT true THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ projects.namespace_id
+ INTO
+ namespace_id
+ FROM
+ projects
+ WHERE
+ projects.id = NEW.project_id;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.vulnerability_id)
+ INTO
+ has_issues;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues)
+ VALUES (NEW.vulnerability_id, namespace_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint), has_issues)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$
+ SQL
+
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_vulnerability_reads_from_vulnerability()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ scanner_id bigint;
+ uuid uuid;
+ location_image text;
+ cluster_agent_id text;
+ casted_cluster_agent_id bigint;
+ namespace_id bigint;
+ has_issues boolean;
+ BEGIN
+ SELECT
+ v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint), projects.namespace_id
+ INTO
+ scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, namespace_id
+ FROM
+ vulnerability_occurrences v_o
+ INNER JOIN projects ON projects.id = v_o.project_id
+ WHERE
+ v_o.vulnerability_id = NEW.id
+ LIMIT 1;
+
+ SELECT
+ EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.id)
+ INTO
+ has_issues;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues)
+ VALUES (NEW.id, namespace_id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_or_update_vulnerability_reads() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ severity smallint;
+ state smallint;
+ report_type smallint;
+ resolved_on_default_branch boolean;
+ present_on_default_branch boolean;
+ namespace_id bigint;
+ BEGIN
+ IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
+ RETURN NULL;
+ END IF;
+
+ IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch, vulnerabilities.present_on_default_branch
+ INTO
+ severity, state, report_type, resolved_on_default_branch, present_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ IF present_on_default_branch IS NOT true THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ projects.namespace_id
+ INTO
+ namespace_id
+ FROM
+ projects
+ WHERE
+ projects.id = NEW.project_id;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.vulnerability_id, namespace_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint))
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$;
+ SQL
+
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_vulnerability_reads_from_vulnerability() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ scanner_id bigint;
+ uuid uuid;
+ location_image text;
+ cluster_agent_id text;
+ casted_cluster_agent_id bigint;
+ namespace_id bigint;
+ BEGIN
+ SELECT
+ v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint), projects.namespace_id
+ INTO
+ scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, namespace_id
+ FROM
+ vulnerability_occurrences v_o
+ INNER JOIN projects ON projects.id = v_o.project_id
+ WHERE
+ v_o.vulnerability_id = NEW.id
+ LIMIT 1;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.id, namespace_id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$;
+ SQL
+ end
+end
diff --git a/db/migrate/20230216144719_drop_table_airflow_dags.rb b/db/migrate/20230216144719_drop_table_airflow_dags.rb
new file mode 100644
index 00000000000..ed80ca16703
--- /dev/null
+++ b/db/migrate/20230216144719_drop_table_airflow_dags.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class DropTableAirflowDags < Gitlab::Database::Migration[2.1]
+ def up
+ # the table is not in use
+ drop_table :airflow_dags, if_exists: true # rubocop: disable Migration/DropTable
+ end
+
+ def down
+ create_table :airflow_dags do |t|
+ t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
+ t.timestamps_with_timezone null: false
+ t.datetime_with_timezone :next_run
+ t.boolean :has_import_errors
+ t.boolean :is_active
+ t.boolean :is_paused
+ t.text :dag_name, null: false, limit: 255
+ t.text :schedule, limit: 255
+ t.text :fileloc, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20230216152912_add_has_failures_column_to_bulk_import_entities.rb b/db/migrate/20230216152912_add_has_failures_column_to_bulk_import_entities.rb
new file mode 100644
index 00000000000..4c48acd9dce
--- /dev/null
+++ b/db/migrate/20230216152912_add_has_failures_column_to_bulk_import_entities.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddHasFailuresColumnToBulkImportEntities < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :bulk_import_entities, :has_failures, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20230216171309_create_ci_runner_cost_settings.rb b/db/migrate/20230216171309_create_ci_runner_cost_settings.rb
new file mode 100644
index 00000000000..5bc624c635a
--- /dev/null
+++ b/db/migrate/20230216171309_create_ci_runner_cost_settings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateCiRunnerCostSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :ci_cost_settings, id: false do |t|
+ t.timestamps_with_timezone null: false
+ t.references :runner, null: false, primary_key: true, index: false,
+ foreign_key: { to_table: :ci_runners, on_delete: :cascade },
+ type: :bigint, default: nil
+ t.float :standard_factor, null: false, default: 1.00
+ t.float :os_contribution_factor, null: false, default: 0.008
+ t.float :os_plan_factor, null: false, default: 0.5
+ end
+ end
+end
diff --git a/db/migrate/20230217065736_add_projects_api_rate_limit_unauthenticated_to_application_settings.rb b/db/migrate/20230217065736_add_projects_api_rate_limit_unauthenticated_to_application_settings.rb
new file mode 100644
index 00000000000..f11560c33e9
--- /dev/null
+++ b/db/migrate/20230217065736_add_projects_api_rate_limit_unauthenticated_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddProjectsApiRateLimitUnauthenticatedToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :projects_api_rate_limit_unauthenticated, :integer, default: 400, null: false
+ end
+end
diff --git a/db/migrate/20230217144421_add_check_type_to_pre_scan_step.rb b/db/migrate/20230217144421_add_check_type_to_pre_scan_step.rb
new file mode 100644
index 00000000000..e4b59c28d73
--- /dev/null
+++ b/db/migrate/20230217144421_add_check_type_to_pre_scan_step.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddCheckTypeToPreScanStep < Gitlab::Database::Migration[2.1]
+ def up
+ add_column :dast_pre_scan_verification_steps, :check_type, :integer, limit: 2, default: 0, null: false
+ end
+
+ def down
+ remove_column :dast_pre_scan_verification_steps, :check_type
+ end
+end
diff --git a/db/migrate/20230217232554_add_state_changed_in_to_vulnerability_state_transitions.rb b/db/migrate/20230217232554_add_state_changed_in_to_vulnerability_state_transitions.rb
new file mode 100644
index 00000000000..6a8b3b87e21
--- /dev/null
+++ b/db/migrate/20230217232554_add_state_changed_in_to_vulnerability_state_transitions.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddStateChangedInToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.1]
+ def up
+ add_column :vulnerability_state_transitions, :state_changed_at_pipeline_id, :bigint
+ end
+
+ def down
+ remove_column :vulnerability_state_transitions, :state_changed_at_pipeline_id
+ end
+end
diff --git a/db/migrate/20230220035034_add_status_and_id_index_to_abuse_reports.rb b/db/migrate/20230220035034_add_status_and_id_index_to_abuse_reports.rb
new file mode 100644
index 00000000000..cea01572e37
--- /dev/null
+++ b/db/migrate/20230220035034_add_status_and_id_index_to_abuse_reports.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddStatusAndIdIndexToAbuseReports < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_abuse_reports_on_status_and_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :abuse_reports, [:status, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :abuse_reports, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230220163141_create_catalog_resources_table.rb b/db/migrate/20230220163141_create_catalog_resources_table.rb
new file mode 100644
index 00000000000..9a60a68415a
--- /dev/null
+++ b/db/migrate/20230220163141_create_catalog_resources_table.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class CreateCatalogResourcesTable < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :catalog_resources do |t|
+ t.references :project, index: true, null: false, foreign_key: { on_delete: :cascade }
+
+ t.datetime_with_timezone :created_at, null: false
+ end
+ end
+end
diff --git a/db/migrate/20230221110256_create_initial_partition_for_ci_runner_machine_builds.rb b/db/migrate/20230221110256_create_initial_partition_for_ci_runner_machine_builds.rb
new file mode 100644
index 00000000000..9aa7049dde1
--- /dev/null
+++ b/db/migrate/20230221110256_create_initial_partition_for_ci_runner_machine_builds.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+class CreateInitialPartitionForCiRunnerMachineBuilds < Gitlab::Database::Migration[2.1]
+ PARTITION_NAME = 'gitlab_partitions_dynamic.ci_runner_machine_builds_100'
+ TABLE_NAME = 'p_ci_runner_machine_builds'
+ FIRST_PARTITION = 100
+ BUILDS_TABLE = 'ci_builds'
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries(**lock_args) do
+ connection.execute(<<~SQL)
+ LOCK TABLE #{BUILDS_TABLE} IN SHARE UPDATE EXCLUSIVE MODE;
+ LOCK TABLE ONLY #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE;
+ SQL
+
+ connection.execute(<<~SQL)
+ CREATE TABLE IF NOT EXISTS #{PARTITION_NAME}
+ PARTITION OF #{TABLE_NAME}
+ FOR VALUES IN (#{FIRST_PARTITION});
+ SQL
+ end
+ end
+
+ def down
+ # no-op
+ #
+ # The migration should not remove the partition table since it might
+ # have been created by 20230215074223_add_ci_runner_machine_builds_partitioned_table.rb.
+ # In that case, the rollback would result in a different state.
+ end
+
+ private
+
+ def lock_args
+ {
+ raise_on_exhaustion: true,
+ timing_configuration: lock_timing_configuration
+ }
+ end
+
+ def lock_timing_configuration
+ iterations = Gitlab::Database::WithLockRetries::DEFAULT_TIMING_CONFIGURATION
+ aggressive_iterations = Array.new(5) { [10.seconds, 1.minute] }
+
+ iterations + aggressive_iterations
+ end
+end
diff --git a/db/migrate/20230222153048_add_registry_size_estimated_to_namespace_root_storage_statistics.rb b/db/migrate/20230222153048_add_registry_size_estimated_to_namespace_root_storage_statistics.rb
new file mode 100644
index 00000000000..50fcf6fd113
--- /dev/null
+++ b/db/migrate/20230222153048_add_registry_size_estimated_to_namespace_root_storage_statistics.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddRegistrySizeEstimatedToNamespaceRootStorageStatistics < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_ns_root_stor_stats_on_registry_size_estimated'
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :namespace_root_storage_statistics, :registry_size_estimated, :boolean, default: false, null: false
+ end
+
+ add_concurrent_index :namespace_root_storage_statistics, :registry_size_estimated, name: INDEX_NAME
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :namespace_root_storage_statistics, :registry_size_estimated
+ end
+ end
+end
diff --git a/db/migrate/20230222161226_add_custom_jira_regex_to_jira_tracker_data.rb b/db/migrate/20230222161226_add_custom_jira_regex_to_jira_tracker_data.rb
new file mode 100644
index 00000000000..c9668c311a3
--- /dev/null
+++ b/db/migrate/20230222161226_add_custom_jira_regex_to_jira_tracker_data.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddCustomJiraRegexToJiraTrackerData < Gitlab::Database::Migration[2.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20230222161954_add_text_limit_to_custom_jira_regex_fields.rb
+ enable_lock_retries!
+ def change
+ add_column :jira_tracker_data, :jira_issue_prefix, :text
+ add_column :jira_tracker_data, :jira_issue_regex, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230222161954_add_text_limit_to_custom_jira_regex_fields.rb b/db/migrate/20230222161954_add_text_limit_to_custom_jira_regex_fields.rb
new file mode 100644
index 00000000000..625655fda9d
--- /dev/null
+++ b/db/migrate/20230222161954_add_text_limit_to_custom_jira_regex_fields.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddTextLimitToCustomJiraRegexFields < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :jira_tracker_data, :jira_issue_prefix, 255
+ add_text_limit :jira_tracker_data, :jira_issue_regex, 255
+ end
+
+ def down
+ remove_text_limit :jira_tracker_data, :jira_issue_regex
+ remove_text_limit :jira_tracker_data, :jira_issue_regex
+ end
+end
diff --git a/db/migrate/20230222193845_change_public_projects_minutes_cost_factor_default_to_1.rb b/db/migrate/20230222193845_change_public_projects_minutes_cost_factor_default_to_1.rb
new file mode 100644
index 00000000000..c86c16f692a
--- /dev/null
+++ b/db/migrate/20230222193845_change_public_projects_minutes_cost_factor_default_to_1.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ChangePublicProjectsMinutesCostFactorDefaultTo1 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ change_column_default :ci_runners, :public_projects_minutes_cost_factor, from: 0.0, to: 1.0
+ end
+ end
+
+ def down
+ with_lock_retries do
+ change_column_default :ci_runners, :public_projects_minutes_cost_factor, from: 1.0, to: 0.0
+ end
+ end
+end
diff --git a/db/migrate/20230224130315_add_constraint_type_to_postgres_async_constraint_validation.rb b/db/migrate/20230224130315_add_constraint_type_to_postgres_async_constraint_validation.rb
new file mode 100644
index 00000000000..dee5810d0d1
--- /dev/null
+++ b/db/migrate/20230224130315_add_constraint_type_to_postgres_async_constraint_validation.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddConstraintTypeToPostgresAsyncConstraintValidation < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :postgres_async_foreign_key_validations, :constraint_type, :integer, null: false, default: 0, limit: 2
+ end
+end
diff --git a/db/migrate/20230224161346_add_saml_group_lock_to_application_settings.rb b/db/migrate/20230224161346_add_saml_group_lock_to_application_settings.rb
new file mode 100644
index 00000000000..003dd5c5b61
--- /dev/null
+++ b/db/migrate/20230224161346_add_saml_group_lock_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddSamlGroupLockToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :lock_memberships_to_saml, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230228092612_add_index_next_over_limit_check_at_asc_order_synchronously.rb b/db/migrate/20230228092612_add_index_next_over_limit_check_at_asc_order_synchronously.rb
new file mode 100644
index 00000000000..a811b67bb43
--- /dev/null
+++ b/db/migrate/20230228092612_add_index_next_over_limit_check_at_asc_order_synchronously.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexNextOverLimitCheckAtAscOrderSynchronously < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'namespace_details'
+ INDEX_NAME = 'index_next_over_limit_check_at_asc_order'
+ COLUMN = 'next_over_limit_check_at'
+
+ def up
+ add_concurrent_index TABLE_NAME, COLUMN, name: INDEX_NAME, order: { next_over_limit_check_at: 'ASC NULLS FIRST' }
+ end
+
+ def down
+ remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230228133011_add_design_description.rb b/db/migrate/20230228133011_add_design_description.rb
new file mode 100644
index 00000000000..bff9a25f2ac
--- /dev/null
+++ b/db/migrate/20230228133011_add_design_description.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddDesignDescription < Gitlab::Database::Migration[2.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # text limit is added in a separate migration
+ def up
+ add_column :design_management_designs, :cached_markdown_version, :integer
+ add_column :design_management_designs, :description, :text
+ add_column :design_management_designs, :description_html, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+
+ def down
+ remove_column :design_management_designs, :cached_markdown_version
+ remove_column :design_management_designs, :description
+ remove_column :design_management_designs, :description_html
+ end
+end
diff --git a/db/migrate/20230228135034_add_design_description_limit.rb b/db/migrate/20230228135034_add_design_description_limit.rb
new file mode 100644
index 00000000000..47c5f8c6ab1
--- /dev/null
+++ b/db/migrate/20230228135034_add_design_description_limit.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddDesignDescriptionLimit < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :design_management_designs, :description, 1_000_000
+ end
+
+ def down
+ remove_text_limit :design_management_designs, :description
+ end
+end
diff --git a/db/migrate/20230228142350_add_notifications_work_item_widget.rb b/db/migrate/20230228142350_add_notifications_work_item_widget.rb
new file mode 100644
index 00000000000..1bc89a6875c
--- /dev/null
+++ b/db/migrate/20230228142350_add_notifications_work_item_widget.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+class AddNotificationsWorkItemWidget < Gitlab::Database::Migration[2.1]
+ class WorkItemType < MigrationRecord
+ self.table_name = 'work_item_types'
+ end
+
+ class WidgetDefinition < MigrationRecord
+ self.table_name = 'work_item_widget_definitions'
+ end
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ WIDGET_NAME = 'Notifications'
+ WIDGET_ENUM_VALUE = 14
+ WORK_ITEM_TYPES = [
+ 'Issue',
+ 'Incident',
+ 'Test Case',
+ 'Requirement',
+ 'Task',
+ 'Objective',
+ 'Key Result'
+ ].freeze
+
+ def up
+ widgets = []
+
+ WORK_ITEM_TYPES.each do |type_name|
+ type = WorkItemType.find_by_name_and_namespace_id(type_name, nil)
+
+ unless type
+ Gitlab::AppLogger.warn("type #{type_name} is missing, not adding widget")
+
+ next
+ end
+
+ widgets << {
+ work_item_type_id: type.id,
+ name: WIDGET_NAME,
+ widget_type: WIDGET_ENUM_VALUE
+ }
+ end
+
+ return if widgets.empty?
+
+ WidgetDefinition.upsert_all(
+ widgets,
+ unique_by: :index_work_item_widget_definitions_on_default_witype_and_name
+ )
+ end
+
+ def down
+ WidgetDefinition.where(name: WIDGET_NAME).delete_all
+ end
+end
diff --git a/db/migrate/20230228183644_add_partitioning_info_to_postgres_foreign_keys.rb b/db/migrate/20230228183644_add_partitioning_info_to_postgres_foreign_keys.rb
new file mode 100644
index 00000000000..5fe2a497077
--- /dev/null
+++ b/db/migrate/20230228183644_add_partitioning_info_to_postgres_foreign_keys.rb
@@ -0,0 +1,90 @@
+# frozen_string_literal: true
+
+class AddPartitioningInfoToPostgresForeignKeys < Gitlab::Database::Migration[2.1]
+ def up
+ execute <<~SQL
+ DROP VIEW IF EXISTS postgres_foreign_keys;
+ CREATE VIEW postgres_foreign_keys AS
+ SELECT pg_constraint.oid AS oid,
+ pg_constraint.conname AS name,
+ constrained_namespace.nspname::text || '.'::text ||
+ constrained_table.relname::text AS constrained_table_identifier,
+ referenced_namespace.nspname::text || '.'::text ||
+ referenced_table.relname::text AS referenced_table_identifier,
+ constrained_table.relname::text AS constrained_table_name,
+ referenced_table.relname::text AS referenced_table_name,
+ constrained_cols.constrained_columns,
+ referenced_cols.referenced_columns,
+ pg_constraint.confdeltype AS on_delete_action,
+ pg_constraint.confupdtype as on_update_action,
+ pg_constraint.coninhcount > 0 as is_inherited,
+ pg_constraint.convalidated as is_valid,
+ partitioned_parent_oids.parent_oid as parent_oid
+ FROM pg_constraint
+ INNER JOIN pg_class constrained_table ON constrained_table.oid = pg_constraint.conrelid
+ INNER JOIN pg_class referenced_table ON referenced_table.oid = pg_constraint.confrelid
+ INNER JOIN pg_namespace constrained_namespace ON constrained_table.relnamespace = constrained_namespace.oid
+ INNER JOIN pg_namespace referenced_namespace ON referenced_table.relnamespace = referenced_namespace.oid
+ CROSS JOIN LATERAL (
+ SELECT array_agg(pg_attribute.attname ORDER BY conkey.idx) -- must order here so that attributes are in correct order in array
+ FROM unnest(pg_constraint.conkey) WITH ORDINALITY conkey(attnum, idx)
+ INNER JOIN pg_attribute
+ ON pg_attribute.attnum = conkey.attnum AND pg_attribute.attrelid = constrained_table.oid
+ ) constrained_cols(constrained_columns)
+ CROSS JOIN LATERAL (
+ SELECT array_agg(pg_attribute.attname ORDER BY confkey.idx)
+ FROM unnest(pg_constraint.confkey) WITH ORDINALITY confkey(attnum, idx)
+ INNER JOIN pg_attribute
+ ON pg_attribute.attnum = confkey.attnum AND pg_attribute.attrelid = referenced_table.oid
+ ) referenced_cols(referenced_columns)
+ LEFT JOIN LATERAL (
+ SELECT refobjid as parent_oid
+ FROM pg_depend
+ WHERE objid = pg_constraint.oid
+ AND pg_depend.deptype = 'P'
+ AND refobjid IN (SELECT oid FROM pg_constraint WHERE contype = 'f')
+ LIMIT 1
+ ) partitioned_parent_oids(parent_oid) ON true
+ WHERE contype = 'f';
+ SQL
+
+ Gitlab::Database::PostgresForeignKey.reset_column_information
+ end
+
+ def down
+ execute <<~SQL
+ DROP VIEW IF EXISTS postgres_foreign_keys;
+ CREATE VIEW postgres_foreign_keys AS
+ SELECT
+ pg_constraint.oid AS oid,
+ pg_constraint.conname AS name,
+ constrained_namespace.nspname::text || '.'::text || constrained_table.relname::text AS constrained_table_identifier,
+ referenced_namespace.nspname::text || '.'::text || referenced_table.relname::text AS referenced_table_identifier,
+ constrained_table.relname::text AS constrained_table_name,
+ referenced_table.relname::text AS referenced_table_name,
+ constrained_cols.constrained_columns,
+ referenced_cols.referenced_columns,
+ pg_constraint.confdeltype AS on_delete_action,
+ pg_constraint.confupdtype as on_update_action,
+ pg_constraint.coninhcount > 0 as is_inherited
+ FROM pg_constraint
+ INNER JOIN pg_class constrained_table ON constrained_table.oid = pg_constraint.conrelid
+ INNER JOIN pg_class referenced_table ON referenced_table.oid = pg_constraint.confrelid
+ INNER JOIN pg_namespace constrained_namespace ON constrained_table.relnamespace = constrained_namespace.oid
+ INNER JOIN pg_namespace referenced_namespace ON referenced_table.relnamespace = referenced_namespace.oid
+ CROSS JOIN LATERAL (
+ SELECT array_agg(pg_attribute.attname ORDER BY conkey.idx) -- must order here so that attributes are in correct order in array
+ FROM unnest(pg_constraint.conkey) WITH ORDINALITY conkey(attnum, idx)
+ INNER JOIN pg_attribute ON pg_attribute.attnum = conkey.attnum AND pg_attribute.attrelid = constrained_table.oid
+ ) constrained_cols(constrained_columns)
+ CROSS JOIN LATERAL (
+ SELECT array_agg(pg_attribute.attname ORDER BY confkey.idx)
+ FROM unnest(pg_constraint.confkey) WITH ORDINALITY confkey(attnum, idx)
+ INNER JOIN pg_attribute ON pg_attribute.attnum = confkey.attnum AND pg_attribute.attrelid = referenced_table.oid
+ ) referenced_cols(referenced_columns)
+ WHERE contype = 'f';
+ SQL
+
+ Gitlab::Database::PostgresForeignKey.reset_column_information
+ end
+end
diff --git a/db/migrate/20230228212427_add_index_user_details_on_user_id_for_enterprise_users_without_date.rb b/db/migrate/20230228212427_add_index_user_details_on_user_id_for_enterprise_users_without_date.rb
new file mode 100644
index 00000000000..198aee2201c
--- /dev/null
+++ b/db/migrate/20230228212427_add_index_user_details_on_user_id_for_enterprise_users_without_date.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexUserDetailsOnUserIdForEnterpriseUsersWithoutDate < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_user_details_on_user_id_for_enterprise_users_without_date'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(
+ :user_details, :user_id,
+ where: 'provisioned_by_group_id IS NOT NULL AND provisioned_by_group_at IS NULL',
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name :user_details, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230228212905_add_index_user_details_on_user_id_for_enterprise_users_with_date.rb b/db/migrate/20230228212905_add_index_user_details_on_user_id_for_enterprise_users_with_date.rb
new file mode 100644
index 00000000000..e57d4fc4261
--- /dev/null
+++ b/db/migrate/20230228212905_add_index_user_details_on_user_id_for_enterprise_users_with_date.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexUserDetailsOnUserIdForEnterpriseUsersWithDate < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_user_details_on_user_id_for_enterprise_users_with_date'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(
+ :user_details, :user_id,
+ where: 'provisioned_by_group_id IS NOT NULL AND provisioned_by_group_at IS NOT NULL',
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name :user_details, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230303144424_unique_index_on_catalog_resources_project.rb b/db/migrate/20230303144424_unique_index_on_catalog_resources_project.rb
new file mode 100644
index 00000000000..6ac2e72616a
--- /dev/null
+++ b/db/migrate/20230303144424_unique_index_on_catalog_resources_project.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class UniqueIndexOnCatalogResourcesProject < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_catalog_resources_on_project_id'
+
+ def up
+ remove_concurrent_index :catalog_resources, :project_id, name: INDEX_NAME
+ add_concurrent_index :catalog_resources, :project_id, unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :catalog_resources, :project_id, name: INDEX_NAME
+ add_concurrent_index :catalog_resources, :project_id, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230303232426_add_role_approvers_to_scan_result_policies.rb b/db/migrate/20230303232426_add_role_approvers_to_scan_result_policies.rb
new file mode 100644
index 00000000000..7d3f4491818
--- /dev/null
+++ b/db/migrate/20230303232426_add_role_approvers_to_scan_result_policies.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRoleApproversToScanResultPolicies < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :scan_result_policies, :role_approvers, :integer, array: true, default: []
+ end
+end
diff --git a/db/migrate/20230306145230_add_product_analytics_data_collector_host_to_application_settings.rb b/db/migrate/20230306145230_add_product_analytics_data_collector_host_to_application_settings.rb
new file mode 100644
index 00000000000..4ae2479b1e6
--- /dev/null
+++ b/db/migrate/20230306145230_add_product_analytics_data_collector_host_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProductAnalyticsDataCollectorHostToApplicationSettings < Gitlab::Database::Migration[2.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ def change
+ add_column :application_settings, :product_analytics_data_collector_host, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230307000000_create_design_management_repository.rb b/db/migrate/20230307000000_create_design_management_repository.rb
new file mode 100644
index 00000000000..da4dee9f320
--- /dev/null
+++ b/db/migrate/20230307000000_create_design_management_repository.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class CreateDesignManagementRepository < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :design_management_repositories do |t|
+ t.references :project, index: { unique: true }, null: false, foreign_key: { on_delete: :cascade }
+
+ t.timestamps_with_timezone null: false
+ end
+ end
+end
diff --git a/db/migrate/20230307091216_add_status_reporter_id_and_id_index_to_abuse_reports.rb b/db/migrate/20230307091216_add_status_reporter_id_and_id_index_to_abuse_reports.rb
new file mode 100644
index 00000000000..cfd077368c8
--- /dev/null
+++ b/db/migrate/20230307091216_add_status_reporter_id_and_id_index_to_abuse_reports.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddStatusReporterIdAndIdIndexToAbuseReports < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_abuse_reports_on_status_reporter_id_and_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :abuse_reports, [:status, :reporter_id, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :abuse_reports, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230307122838_add_text_limit_to_application_settings_product_analytics_data_collector_host.rb b/db/migrate/20230307122838_add_text_limit_to_application_settings_product_analytics_data_collector_host.rb
new file mode 100644
index 00000000000..4f87cc9aee0
--- /dev/null
+++ b/db/migrate/20230307122838_add_text_limit_to_application_settings_product_analytics_data_collector_host.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToApplicationSettingsProductAnalyticsDataCollectorHost < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :application_settings, :product_analytics_data_collector_host, 255
+ end
+
+ def down
+ remove_text_limit :application_settings, :product_analytics_data_collector_host
+ end
+end
diff --git a/db/migrate/20230307132729_create_schema_inconsistencies.rb b/db/migrate/20230307132729_create_schema_inconsistencies.rb
new file mode 100644
index 00000000000..4891cc6ab7b
--- /dev/null
+++ b/db/migrate/20230307132729_create_schema_inconsistencies.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateSchemaInconsistencies < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :schema_inconsistencies do |t|
+ t.references :issue, index: true, null: false, foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.text :object_name, null: false, limit: 63
+ t.text :table_name, null: false, limit: 63
+ t.text :valitador_name, null: false, limit: 63
+ end
+ end
+end
diff --git a/db/migrate/20230307212637_remove_create_learn_gitlab_worker_job_instances.rb b/db/migrate/20230307212637_remove_create_learn_gitlab_worker_job_instances.rb
new file mode 100644
index 00000000000..b2e4cc8ceb2
--- /dev/null
+++ b/db/migrate/20230307212637_remove_create_learn_gitlab_worker_job_instances.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveCreateLearnGitlabWorkerJobInstances < Gitlab::Database::Migration[2.1]
+ def up
+ # No-op to fix https://gitlab.com/gitlab-com/gl-infra/production/-/issues/8612
+ end
+
+ def down
+ # No-op to fix https://gitlab.com/gitlab-com/gl-infra/production/-/issues/8612
+ end
+end
diff --git a/db/migrate/20230307233631_add_public_runner_release_version_fetch_setting.rb b/db/migrate/20230307233631_add_public_runner_release_version_fetch_setting.rb
new file mode 100644
index 00000000000..584774d58ad
--- /dev/null
+++ b/db/migrate/20230307233631_add_public_runner_release_version_fetch_setting.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddPublicRunnerReleaseVersionFetchSetting < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_column :application_settings, :update_runner_versions_enabled, :boolean,
+ default: true, null: false, if_not_exists: true
+ end
+
+ def down
+ remove_column :application_settings, :update_runner_versions_enabled, if_exists: true
+ end
+end
diff --git a/db/migrate/20230308154243_add_package_id_to_ml_candidates.rb b/db/migrate/20230308154243_add_package_id_to_ml_candidates.rb
new file mode 100644
index 00000000000..ed13ddc894c
--- /dev/null
+++ b/db/migrate/20230308154243_add_package_id_to_ml_candidates.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddPackageIdToMlCandidates < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :ml_candidates, :package_id, :bigint, null: true
+ end
+end
diff --git a/db/migrate/20230308154244_add_package_id_foreign_key_to_ml_candidates.rb b/db/migrate/20230308154244_add_package_id_foreign_key_to_ml_candidates.rb
new file mode 100644
index 00000000000..7f12673e410
--- /dev/null
+++ b/db/migrate/20230308154244_add_package_id_foreign_key_to_ml_candidates.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddPackageIdForeignKeyToMlCandidates < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ml_candidates, :packages_packages, column: :package_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :ml_candidates, column: :package_id
+ end
+ end
+end
diff --git a/db/migrate/20230308154245_add_index_on_package_id_for_ml_candidates.rb b/db/migrate/20230308154245_add_index_on_package_id_for_ml_candidates.rb
new file mode 100644
index 00000000000..cb3c9cd5a33
--- /dev/null
+++ b/db/migrate/20230308154245_add_index_on_package_id_for_ml_candidates.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnPackageIdForMlCandidates < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ml_candidates_on_package_id'
+
+ def up
+ add_concurrent_index :ml_candidates, :package_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ml_candidates, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230308163018_create_container_registry_data_repair_details.rb b/db/migrate/20230308163018_create_container_registry_data_repair_details.rb
new file mode 100644
index 00000000000..b682eb6ee7e
--- /dev/null
+++ b/db/migrate/20230308163018_create_container_registry_data_repair_details.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateContainerRegistryDataRepairDetails < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :container_registry_data_repair_details, id: false do |t|
+ t.integer :missing_count, default: 0
+ t.references :project,
+ primary_key: true,
+ default: nil,
+ index: false,
+ foreign_key: { to_table: :projects, on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ end
+ end
+end
diff --git a/db/migrate/20230309000957_add_external_identifiers_to_import_failures.rb b/db/migrate/20230309000957_add_external_identifiers_to_import_failures.rb
new file mode 100644
index 00000000000..f95cf0035d4
--- /dev/null
+++ b/db/migrate/20230309000957_add_external_identifiers_to_import_failures.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddExternalIdentifiersToImportFailures < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :import_failures, :external_identifiers, :jsonb, default: {}, null: false
+ end
+end
diff --git a/db/migrate/20230313012226_create_search_indices.rb b/db/migrate/20230313012226_create_search_indices.rb
new file mode 100644
index 00000000000..e1ef29be5af
--- /dev/null
+++ b/db/migrate/20230313012226_create_search_indices.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateSearchIndices < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :search_indices do |t|
+ t.timestamps_with_timezone null: false
+ t.integer :bucket_number # We allow null bucket numbers to support custom index assignments
+ t.text :path, null: false, limit: 255
+ t.text :type, null: false, limit: 255
+ end
+
+ add_index :search_indices, [:id, :type], unique: true
+ add_index :search_indices, [:type, :path], unique: true
+ add_index :search_indices, [:type, :bucket_number], unique: true
+ end
+end
diff --git a/db/migrate/20230313012609_create_search_namespace_index_assignments.rb b/db/migrate/20230313012609_create_search_namespace_index_assignments.rb
new file mode 100644
index 00000000000..ea3760ead74
--- /dev/null
+++ b/db/migrate/20230313012609_create_search_namespace_index_assignments.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class CreateSearchNamespaceIndexAssignments < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :search_namespace_index_assignments do |t|
+ t.references :namespace, foreign_key: true, null: true, on_delete: :nullify
+ t.bigint :search_index_id, index: true, null: false
+ t.bigint :namespace_id_non_nullable, null: false
+ t.timestamps_with_timezone null: false
+ t.integer :namespace_id_hashed, null: false
+ t.text :index_type, null: false, limit: 255
+ end
+
+ add_index :search_namespace_index_assignments,
+ [:namespace_id, :index_type],
+ unique: true,
+ name: 'index_search_namespace_index_assignments_uniqueness_index_type'
+
+ add_index :search_namespace_index_assignments,
+ [:namespace_id, :search_index_id],
+ unique: true,
+ name: 'index_search_namespace_index_assignments_uniqueness_on_index_id'
+ end
+end
diff --git a/db/migrate/20230313014038_add_search_index_foreign_key_to_search_namespace_index_assignments.rb b/db/migrate/20230313014038_add_search_index_foreign_key_to_search_namespace_index_assignments.rb
new file mode 100644
index 00000000000..c49833b01e1
--- /dev/null
+++ b/db/migrate/20230313014038_add_search_index_foreign_key_to_search_namespace_index_assignments.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddSearchIndexForeignKeyToSearchNamespaceIndexAssignments < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ FK_NAME = 'fk_search_index_id_and_type'
+
+ def up
+ add_concurrent_foreign_key :search_namespace_index_assignments, :search_indices,
+ name: FK_NAME, column: [:search_index_id, :index_type], target_column: [:id, :type], on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :search_namespace_index_assignments, name: FK_NAME
+ end
+ end
+end
diff --git a/db/migrate/20230313031351_create_resource_link_events.rb b/db/migrate/20230313031351_create_resource_link_events.rb
new file mode 100644
index 00000000000..03f00c9416b
--- /dev/null
+++ b/db/migrate/20230313031351_create_resource_link_events.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateResourceLinkEvents < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :resource_link_events do |t|
+ t.integer :action, limit: 2, null: false
+ t.bigint :user_id, null: false
+ t.references :issue, index: true, null: false, foreign_key: { on_delete: :cascade }
+ t.references :child_work_item, index: true, null: false, foreign_key: { to_table: :issues, on_delete: :cascade }
+ t.datetime_with_timezone :created_at, null: false
+
+ t.index :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230313054226_add_status_created_at_and_updated_at_indexes_to_abuse_reports.rb b/db/migrate/20230313054226_add_status_created_at_and_updated_at_indexes_to_abuse_reports.rb
new file mode 100644
index 00000000000..b619d6b8732
--- /dev/null
+++ b/db/migrate/20230313054226_add_status_created_at_and_updated_at_indexes_to_abuse_reports.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddStatusCreatedAtAndUpdatedAtIndexesToAbuseReports < Gitlab::Database::Migration[2.1]
+ STATUS_AND_CREATED_AT_INDEX = 'index_abuse_reports_on_status_and_created_at'
+ STATUS_AND_UPDATED_AT_INDEX = 'index_abuse_reports_on_status_and_updated_at'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :abuse_reports, [:status, :created_at], name: STATUS_AND_CREATED_AT_INDEX
+ add_concurrent_index :abuse_reports, [:status, :updated_at], name: STATUS_AND_UPDATED_AT_INDEX
+ end
+
+ def down
+ remove_concurrent_index_by_name :abuse_reports, STATUS_AND_CREATED_AT_INDEX
+ remove_concurrent_index_by_name :abuse_reports, STATUS_AND_UPDATED_AT_INDEX
+ end
+end
diff --git a/db/migrate/20230313092109_add_start_end_and_current_values_to_wi_progressess.rb b/db/migrate/20230313092109_add_start_end_and_current_values_to_wi_progressess.rb
new file mode 100644
index 00000000000..308bf4a0cf4
--- /dev/null
+++ b/db/migrate/20230313092109_add_start_end_and_current_values_to_wi_progressess.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddStartEndAndCurrentValuesToWiProgressess < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :work_item_progresses, :start_value, :float, default: 0, null: false
+ add_column :work_item_progresses, :end_value, :float, default: 100, null: false
+ add_column :work_item_progresses, :current_value, :float, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20230313100920_add_gitlab_dedicated_instance_to_application_settings.rb b/db/migrate/20230313100920_add_gitlab_dedicated_instance_to_application_settings.rb
new file mode 100644
index 00000000000..ce83c022661
--- /dev/null
+++ b/db/migrate/20230313100920_add_gitlab_dedicated_instance_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddGitlabDedicatedInstanceToApplicationSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :application_settings, :gitlab_dedicated_instance, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230313181536_create_packages_npm_metadata_caches.rb b/db/migrate/20230313181536_create_packages_npm_metadata_caches.rb
new file mode 100644
index 00000000000..fde33342f04
--- /dev/null
+++ b/db/migrate/20230313181536_create_packages_npm_metadata_caches.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class CreatePackagesNpmMetadataCaches < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ INDEX_NAME = 'index_npm_metadata_caches_on_package_name_project_id_unique'
+
+ def up
+ create_table :packages_npm_metadata_caches do |t|
+ t.timestamps_with_timezone
+
+ t.datetime_with_timezone :last_downloaded_at
+ t.bigint :project_id, index: true
+ t.integer :file_store, default: 1
+ t.integer :size, null: false
+ t.text :file, null: false, limit: 255
+ t.text :package_name, null: false # rubocop:disable Migration/AddLimitToTextColumns
+
+ t.index %i[package_name project_id], name: INDEX_NAME, unique: true, where: 'project_id IS NOT NULL'
+ end
+ end
+
+ def down
+ drop_table :packages_npm_metadata_caches
+ end
+end
diff --git a/db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb b/db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb
new file mode 100644
index 00000000000..52c661a5f1d
--- /dev/null
+++ b/db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class DropIndexFromWebauthnRegistrationsOnU2fRegistrationId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists :webauthn_registrations, column: :u2f_registration_id
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key(
+ :webauthn_registrations, :u2f_registrations, column: :u2f_registration_id, on_delete: :cascade)
+ end
+end
diff --git a/db/migrate/20230315053635_add_screenshot_to_abuse_reports.rb b/db/migrate/20230315053635_add_screenshot_to_abuse_reports.rb
new file mode 100644
index 00000000000..421878967c4
--- /dev/null
+++ b/db/migrate/20230315053635_add_screenshot_to_abuse_reports.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddScreenshotToAbuseReports < Gitlab::Database::Migration[2.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20230327074932_add_text_limit_to_abuse_reports_screenshot
+ def change
+ add_column :abuse_reports, :screenshot, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230316093433_insert_daily_invites_trial_plan_limits.rb b/db/migrate/20230316093433_insert_daily_invites_trial_plan_limits.rb
new file mode 100644
index 00000000000..f6254cad192
--- /dev/null
+++ b/db/migrate/20230316093433_insert_daily_invites_trial_plan_limits.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class InsertDailyInvitesTrialPlanLimits < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ return unless Gitlab.com?
+
+ create_or_update_plan_limit('daily_invites', 'premium_trial', 50)
+ create_or_update_plan_limit('daily_invites', 'ultimate_trial', 50)
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ create_or_update_plan_limit('daily_invites', 'premium_trial', 0)
+ create_or_update_plan_limit('daily_invites', 'ultimate_trial', 0)
+ end
+end
diff --git a/db/migrate/20230316095948_create_service_desk_custom_email_credentials.rb b/db/migrate/20230316095948_create_service_desk_custom_email_credentials.rb
new file mode 100644
index 00000000000..c0537a1985d
--- /dev/null
+++ b/db/migrate/20230316095948_create_service_desk_custom_email_credentials.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateServiceDeskCustomEmailCredentials < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table(:service_desk_custom_email_credentials, id: false) do |t|
+ t.references :project,
+ primary_key: true,
+ default: nil,
+ index: false,
+ foreign_key: { to_table: :projects, on_delete: :cascade }
+ t.timestamps_with_timezone
+ t.integer :smtp_port
+ t.text :smtp_address, limit: 255
+ t.binary :encrypted_smtp_username
+ t.binary :encrypted_smtp_username_iv
+ t.binary :encrypted_smtp_password
+ t.binary :encrypted_smtp_password_iv
+ end
+ end
+end
diff --git a/db/migrate/20230317162059_add_current_user_todos_work_item_widget.rb b/db/migrate/20230317162059_add_current_user_todos_work_item_widget.rb
new file mode 100644
index 00000000000..4ed1fd6869c
--- /dev/null
+++ b/db/migrate/20230317162059_add_current_user_todos_work_item_widget.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+class AddCurrentUserTodosWorkItemWidget < Gitlab::Database::Migration[2.1]
+ class WorkItemType < MigrationRecord
+ self.table_name = 'work_item_types'
+ end
+
+ class WidgetDefinition < MigrationRecord
+ self.table_name = 'work_item_widget_definitions'
+ end
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ WIDGET_NAME = 'Current user todos'
+ WIDGET_ENUM_VALUE = 15
+ WORK_ITEM_TYPES = [
+ 'Issue',
+ 'Incident',
+ 'Test Case',
+ 'Requirement',
+ 'Task',
+ 'Objective',
+ 'Key Result'
+ ].freeze
+
+ def up
+ widgets = []
+
+ WORK_ITEM_TYPES.each do |type_name|
+ type = WorkItemType.find_by_name_and_namespace_id(type_name, nil)
+
+ unless type
+ Gitlab::AppLogger.warn("type #{type_name} is missing, not adding widget")
+
+ next
+ end
+
+ widgets << {
+ work_item_type_id: type.id,
+ name: WIDGET_NAME,
+ widget_type: WIDGET_ENUM_VALUE
+ }
+ end
+
+ return if widgets.empty?
+
+ WidgetDefinition.upsert_all(
+ widgets,
+ unique_by: :index_work_item_widget_definitions_on_default_witype_and_name
+ )
+ end
+
+ def down
+ WidgetDefinition.where(name: WIDGET_NAME).delete_all
+ end
+end
diff --git a/db/migrate/20230321085011_add_column_to_users_statistisc.rb b/db/migrate/20230321085011_add_column_to_users_statistisc.rb
new file mode 100644
index 00000000000..8eef2ff5765
--- /dev/null
+++ b/db/migrate/20230321085011_add_column_to_users_statistisc.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddColumnToUsersStatistisc < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :users_statistics, :with_highest_role_guest_with_custom_role, :integer, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20230321113956_add_indexes_to_merge_request_compliance_violations.rb b/db/migrate/20230321113956_add_indexes_to_merge_request_compliance_violations.rb
new file mode 100644
index 00000000000..66a24dc73c4
--- /dev/null
+++ b/db/migrate/20230321113956_add_indexes_to_merge_request_compliance_violations.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddIndexesToMergeRequestComplianceViolations < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_SEVERITY_LEVEL_DESC = 'i_compliance_violations_on_project_id_severity_and_id'
+ INDEX_REASON_ASC = 'i_compliance_violations_on_project_id_reason_and_id'
+ INDEX_TITLE_ASC = 'i_compliance_violations_on_project_id_title_and_id'
+ INDEX_MERGED_AT_ASC = 'i_compliance_violations_on_project_id_merged_at_and_id'
+
+ def up
+ add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :severity_level, :id],
+ order: { severity_level: :desc, id: :desc }, using: :btree, name: INDEX_SEVERITY_LEVEL_DESC
+ add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :reason, :id],
+ order: { reason: :asc, id: :asc }, using: :btree, name: INDEX_REASON_ASC
+ add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :title, :id],
+ order: { title: :asc, id: :asc }, using: :btree, name: INDEX_TITLE_ASC
+ add_concurrent_index :merge_requests_compliance_violations, [:target_project_id, :merged_at, :id],
+ order: { merged_at: :asc, id: :asc }, using: :btree, name: INDEX_MERGED_AT_ASC
+ end
+
+ def down
+ remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_TITLE_ASC
+ remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_TITLE_ASC
+ remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_SEVERITY_LEVEL_DESC
+ remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_REASON_ASC
+ remove_concurrent_index_by_name :merge_requests_compliance_violations, INDEX_MERGED_AT_ASC
+ end
+end
diff --git a/db/migrate/20230321153304_rename_ml_candidates_iid_to_eid.rb b/db/migrate/20230321153304_rename_ml_candidates_iid_to_eid.rb
new file mode 100644
index 00000000000..2e884e92aa7
--- /dev/null
+++ b/db/migrate/20230321153304_rename_ml_candidates_iid_to_eid.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RenameMlCandidatesIidToEid < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :ml_candidates, :iid, :eid
+ end
+
+ def down
+ undo_rename_column_concurrently :ml_candidates, :iid, :eid
+ end
+end
diff --git a/db/migrate/20230321161218_add_project_access_token_limit_to_plan_limits.rb b/db/migrate/20230321161218_add_project_access_token_limit_to_plan_limits.rb
new file mode 100644
index 00000000000..5f9400b9498
--- /dev/null
+++ b/db/migrate/20230321161218_add_project_access_token_limit_to_plan_limits.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddProjectAccessTokenLimitToPlanLimits < Gitlab::Database::Migration[2.1]
+ def change
+ add_column(:plan_limits, :project_access_token_limit, :integer, default: 0, null: false)
+ end
+end
diff --git a/db/migrate/20230321161441_insert_project_access_token_limit.rb b/db/migrate/20230321161441_insert_project_access_token_limit.rb
new file mode 100644
index 00000000000..a449e6f8e7c
--- /dev/null
+++ b/db/migrate/20230321161441_insert_project_access_token_limit.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class InsertProjectAccessTokenLimit < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ create_or_update_plan_limit('project_access_token_limit', 'premium_trial', 1)
+ create_or_update_plan_limit('project_access_token_limit', 'ultimate_trial', 1)
+ end
+
+ def down
+ create_or_update_plan_limit('project_access_token_limit', 'premium_trial', 0)
+ create_or_update_plan_limit('project_access_token_limit', 'ultimate_trial', 0)
+ end
+end
diff --git a/db/migrate/20230321162810_add_project_id_to_ml_candidates.rb b/db/migrate/20230321162810_add_project_id_to_ml_candidates.rb
new file mode 100644
index 00000000000..a8121f197d9
--- /dev/null
+++ b/db/migrate/20230321162810_add_project_id_to_ml_candidates.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectIdToMlCandidates < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :ml_candidates, :project_id, :bigint, null: true
+ end
+end
diff --git a/db/migrate/20230321162902_add_index_on_project_id_on_ml_candidates.rb b/db/migrate/20230321162902_add_index_on_project_id_on_ml_candidates.rb
new file mode 100644
index 00000000000..e6c08468c0c
--- /dev/null
+++ b/db/migrate/20230321162902_add_index_on_project_id_on_ml_candidates.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnProjectIdOnMlCandidates < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ml_candidates_on_project_id'
+
+ def up
+ add_concurrent_index :ml_candidates, :project_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ml_candidates, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230321163051_add_project_id_foreign_key_to_ml_candidates.rb b/db/migrate/20230321163051_add_project_id_foreign_key_to_ml_candidates.rb
new file mode 100644
index 00000000000..3e43a160306
--- /dev/null
+++ b/db/migrate/20230321163051_add_project_id_foreign_key_to_ml_candidates.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddProjectIdForeignKeyToMlCandidates < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ml_candidates, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :ml_candidates, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20230321170734_add_internal_id_to_ml_candidates.rb b/db/migrate/20230321170734_add_internal_id_to_ml_candidates.rb
new file mode 100644
index 00000000000..f6ced91c0a8
--- /dev/null
+++ b/db/migrate/20230321170734_add_internal_id_to_ml_candidates.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddInternalIdToMlCandidates < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :ml_candidates, :internal_id, :bigint, null: true
+ end
+end
diff --git a/db/migrate/20230321170803_add_index_on_project_id_on_internal_id_to_ml_candidates.rb b/db/migrate/20230321170803_add_index_on_project_id_on_internal_id_to_ml_candidates.rb
new file mode 100644
index 00000000000..4c295972106
--- /dev/null
+++ b/db/migrate/20230321170803_add_index_on_project_id_on_internal_id_to_ml_candidates.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnProjectIdOnInternalIdToMlCandidates < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ml_candidates_on_project_id_on_internal_id'
+
+ def up
+ add_concurrent_index :ml_candidates, [:project_id, :internal_id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ml_candidates, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230322145403_add_project_id_foreign_key_to_packages_npm_metadata_caches.rb b/db/migrate/20230322145403_add_project_id_foreign_key_to_packages_npm_metadata_caches.rb
new file mode 100644
index 00000000000..7c542279bd0
--- /dev/null
+++ b/db/migrate/20230322145403_add_project_id_foreign_key_to_packages_npm_metadata_caches.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddProjectIdForeignKeyToPackagesNpmMetadataCaches < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ SOURCE_TABLE = :packages_npm_metadata_caches
+ TARGET_TABLE = :projects
+ COLUMN = :project_id
+
+ def up
+ add_concurrent_foreign_key SOURCE_TABLE, TARGET_TABLE, column: COLUMN, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key SOURCE_TABLE, column: COLUMN
+ end
+ end
+end
diff --git a/db/migrate/20230322151605_rerun_remove_invalid_deploy_access_level.rb b/db/migrate/20230322151605_rerun_remove_invalid_deploy_access_level.rb
new file mode 100644
index 00000000000..e140ecc58c7
--- /dev/null
+++ b/db/migrate/20230322151605_rerun_remove_invalid_deploy_access_level.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class RerunRemoveInvalidDeployAccessLevel < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ # clean up any rows with invalid access_level entries
+ def up
+ update_column_in_batches(:protected_environment_deploy_access_levels, :access_level, nil) do |table, query|
+ query.where(
+ table.grouping(table[:user_id].not_eq(nil).or(table[:group_id].not_eq(nil)))
+ .and(table[:access_level].not_eq(nil)))
+ end
+
+ update_column_in_batches(:protected_environment_deploy_access_levels, :group_id, nil) do |table, query|
+ query.where(table[:user_id].not_eq(nil).and(table[:group_id].not_eq(nil)))
+ end
+ end
+
+ def down
+ # no-op
+
+ # we are setting access_level to NULL if group_id or user_id are present
+ end
+end
diff --git a/db/migrate/20230322162512_add_valid_deploy_access_level_constraint.rb b/db/migrate/20230322162512_add_valid_deploy_access_level_constraint.rb
new file mode 100644
index 00000000000..4cf82375563
--- /dev/null
+++ b/db/migrate/20230322162512_add_valid_deploy_access_level_constraint.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddValidDeployAccessLevelConstraint < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = 'check_deploy_access_levels_user_group_access_level_any_not_null'
+ CONSTRAINT = '(num_nonnulls(user_id, group_id, access_level) = 1)'
+
+ def up
+ add_check_constraint :protected_environment_deploy_access_levels, CONSTRAINT, CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :protected_environment_deploy_access_levels, CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20230322164031_create_design_management_repository_states.rb b/db/migrate/20230322164031_create_design_management_repository_states.rb
new file mode 100644
index 00000000000..0c906a45ae8
--- /dev/null
+++ b/db/migrate/20230322164031_create_design_management_repository_states.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+class CreateDesignManagementRepositoryStates < Gitlab::Database::Migration[2.1]
+ VERIFICATION_STATE_INDEX_NAME = "index_design_management_repository_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_design_management_repository_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_design_management_repository_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_design_management_repository_states_needs_verification"
+
+ enable_lock_retries!
+
+ def up
+ create_table :design_management_repository_states, id: false do |t|
+ t.datetime_with_timezone :verification_started_at
+ t.datetime_with_timezone :verification_retry_at
+ t.datetime_with_timezone :verified_at
+ t.references :design_management_repository, primary_key: true, default: nil, index: false,
+ foreign_key: { on_delete: :cascade }
+ t.integer :verification_state, default: 0, limit: 2, null: false
+ t.integer :verification_retry_count, default: 0, limit: 2, null: false
+ t.binary :verification_checksum, using: 'verification_checksum::bytea'
+ t.text :verification_failure, limit: 255
+
+ t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
+ t.index :verified_at,
+ where: "(verification_state = 0)",
+ order: { verified_at: 'ASC NULLS FIRST' },
+ name: PENDING_VERIFICATION_INDEX_NAME
+ t.index :verification_retry_at,
+ where: "(verification_state = 3)",
+ order: { verification_retry_at: 'ASC NULLS FIRST' },
+ name: FAILED_VERIFICATION_INDEX_NAME
+ t.index :verification_state,
+ where: "(verification_state = 0 OR verification_state = 3)",
+ name: NEEDS_VERIFICATION_INDEX_NAME
+ end
+ end
+
+ def down
+ drop_table :design_management_repository_states
+ end
+end
diff --git a/db/migrate/20230323021618_add_silent_mode_enabled_to_application_settings.rb b/db/migrate/20230323021618_add_silent_mode_enabled_to_application_settings.rb
new file mode 100644
index 00000000000..e3592e0bd13
--- /dev/null
+++ b/db/migrate/20230323021618_add_silent_mode_enabled_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddSilentModeEnabledToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :silent_mode_enabled, :boolean, default: false, null: false, if_not_exists: true
+ end
+end
diff --git a/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb b/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb
new file mode 100644
index 00000000000..6a6b50c81a5
--- /dev/null
+++ b/db/migrate/20230323101138_add_award_emoji_work_item_widget.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+class AddAwardEmojiWorkItemWidget < Gitlab::Database::Migration[2.1]
+ class WorkItemType < MigrationRecord
+ self.table_name = 'work_item_types'
+ end
+
+ class WidgetDefinition < MigrationRecord
+ self.table_name = 'work_item_widget_definitions'
+ end
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ WIDGET_NAME = 'Award emoji'
+ WIDGET_ENUM_VALUE = 16
+ WORK_ITEM_TYPES = [
+ 'Issue',
+ 'Incident',
+ 'Test Case',
+ 'Requirement',
+ 'Task',
+ 'Objective',
+ 'Key Result'
+ ].freeze
+
+ def up
+ widgets = []
+
+ WORK_ITEM_TYPES.each do |type_name|
+ type = WorkItemType.find_by_name_and_namespace_id(type_name, nil)
+
+ unless type
+ Gitlab::AppLogger.warn("type #{type_name} is missing, not adding widget")
+
+ next
+ end
+
+ widgets << {
+ work_item_type_id: type.id,
+ name: WIDGET_NAME,
+ widget_type: WIDGET_ENUM_VALUE
+ }
+ end
+
+ return if widgets.empty?
+
+ WidgetDefinition.upsert_all(
+ widgets,
+ unique_by: :index_work_item_widget_definitions_on_default_witype_and_name
+ )
+ end
+
+ def down
+ WidgetDefinition.where(name: WIDGET_NAME).delete_all
+ end
+end
diff --git a/db/migrate/20230323120601_create_dora_performance_scores.rb b/db/migrate/20230323120601_create_dora_performance_scores.rb
new file mode 100644
index 00000000000..2c4304fedb6
--- /dev/null
+++ b/db/migrate/20230323120601_create_dora_performance_scores.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateDoraPerformanceScores < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :dora_performance_scores do |t|
+ t.references :project, null: false, foreign_key: { on_delete: :cascade }, index: false
+ t.date :date, null: false
+ t.integer :deployment_frequency, limit: 2
+ t.integer :lead_time_for_changes, limit: 2
+ t.integer :time_to_restore_service, limit: 2
+ t.integer :change_failure_rate, limit: 2
+
+ t.index [:project_id, :date], unique: true
+ end
+ end
+end
diff --git a/db/migrate/20230323140745_add_root_directory_to_pages_deployment.rb b/db/migrate/20230323140745_add_root_directory_to_pages_deployment.rb
new file mode 100644
index 00000000000..781ba3e89d4
--- /dev/null
+++ b/db/migrate/20230323140745_add_root_directory_to_pages_deployment.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddRootDirectoryToPagesDeployment < Gitlab::Database::Migration[2.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20230323140746_add_text_limit_to_pages_deployment_root_directory
+ def change
+ add_column :pages_deployments, :root_directory, :text, default: "public"
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230323140746_add_text_limit_to_pages_deployment_root_directory.rb b/db/migrate/20230323140746_add_text_limit_to_pages_deployment_root_directory.rb
new file mode 100644
index 00000000000..12209422fbb
--- /dev/null
+++ b/db/migrate/20230323140746_add_text_limit_to_pages_deployment_root_directory.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToPagesDeploymentRootDirectory < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :pages_deployments, :root_directory, 255
+ end
+
+ def down
+ remove_text_limit :pages_deployments, :root_directory
+ end
+end
diff --git a/db/migrate/20230323153042_track_push_rules_deletions.rb b/db/migrate/20230323153042_track_push_rules_deletions.rb
new file mode 100644
index 00000000000..2aa7fad8de1
--- /dev/null
+++ b/db/migrate/20230323153042_track_push_rules_deletions.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackPushRulesDeletions < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:push_rules)
+ end
+
+ def down
+ untrack_record_deletions(:push_rules)
+ end
+end
diff --git a/db/migrate/20230323153328_track_tags_deletions.rb b/db/migrate/20230323153328_track_tags_deletions.rb
new file mode 100644
index 00000000000..085d14a56fa
--- /dev/null
+++ b/db/migrate/20230323153328_track_tags_deletions.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackTagsDeletions < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:tags)
+ end
+
+ def down
+ untrack_record_deletions(:tags)
+ end
+end
diff --git a/db/migrate/20230323191750_add_shard_settings_to_search_indices.rb b/db/migrate/20230323191750_add_shard_settings_to_search_indices.rb
new file mode 100644
index 00000000000..b032e3b8a61
--- /dev/null
+++ b/db/migrate/20230323191750_add_shard_settings_to_search_indices.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddShardSettingsToSearchIndices < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :search_indices, :number_of_shards, :integer, default: 2, null: false
+ add_column :search_indices, :number_of_replicas, :integer, default: 1, null: false
+ end
+end
diff --git a/db/migrate/20230327074932_add_text_limit_to_abuse_reports_screenshot.rb b/db/migrate/20230327074932_add_text_limit_to_abuse_reports_screenshot.rb
new file mode 100644
index 00000000000..3bb9722188f
--- /dev/null
+++ b/db/migrate/20230327074932_add_text_limit_to_abuse_reports_screenshot.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToAbuseReportsScreenshot < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :abuse_reports, :screenshot, 255
+ end
+
+ def down
+ remove_text_limit :abuse_reports, :screenshot
+ end
+end
diff --git a/db/migrate/20230327123333_backfill_product_analytics_data_collector_host.rb b/db/migrate/20230327123333_backfill_product_analytics_data_collector_host.rb
new file mode 100644
index 00000000000..04041d78c3e
--- /dev/null
+++ b/db/migrate/20230327123333_backfill_product_analytics_data_collector_host.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class BackfillProductAnalyticsDataCollectorHost < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ # fills product_analytics_data_collector_host by replacing jitsu_host subdomain with collector
+ regex = "'://(.+?\\.)'"
+ replace_with = "'://collector.'"
+ execute <<~SQL
+ UPDATE application_settings
+ SET product_analytics_data_collector_host = regexp_replace(jitsu_host, #{regex}, #{replace_with}, 'g')
+ WHERE jitsu_host IS NOT NULL AND product_analytics_data_collector_host IS NULL
+ SQL
+ end
+
+ def down
+ # noop
+ end
+end
diff --git a/db/migrate/20230328020316_delete_unused_index_on_merge_requests_on_state_id_and_merge_status.rb b/db/migrate/20230328020316_delete_unused_index_on_merge_requests_on_state_id_and_merge_status.rb
new file mode 100644
index 00000000000..eac1d4e30c1
--- /dev/null
+++ b/db/migrate/20230328020316_delete_unused_index_on_merge_requests_on_state_id_and_merge_status.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DeleteUnusedIndexOnMergeRequestsOnStateIdAndMergeStatus < Gitlab::Database::Migration[2.1]
+ # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/402491
+
+ def up
+ prepare_async_index_removal :merge_requests, [:state_id, :merge_status],
+ where: "((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text))",
+ name: 'idx_merge_requests_on_state_id_and_merge_status'
+ end
+
+ def down
+ unprepare_async_index :merge_requests, [:state_id, :merge_status],
+ where: "((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text))",
+ name: 'idx_merge_requests_on_state_id_and_merge_status'
+ end
+end
diff --git a/db/migrate/20230328023535_initialize_conversion_of_award_emoji_awardable_id_to_bigint.rb b/db/migrate/20230328023535_initialize_conversion_of_award_emoji_awardable_id_to_bigint.rb
new file mode 100644
index 00000000000..00bccb5cde2
--- /dev/null
+++ b/db/migrate/20230328023535_initialize_conversion_of_award_emoji_awardable_id_to_bigint.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class InitializeConversionOfAwardEmojiAwardableIdToBigint < Gitlab::Database::Migration[2.1]
+ TABLE = :award_emoji
+ COLUMNS = %i[awardable_id]
+
+ enable_lock_retries!
+
+ def up
+ initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+end
diff --git a/db/migrate/20230328031720_initialize_conversion_of_events_target_id_to_bigint.rb b/db/migrate/20230328031720_initialize_conversion_of_events_target_id_to_bigint.rb
new file mode 100644
index 00000000000..b30b681f42d
--- /dev/null
+++ b/db/migrate/20230328031720_initialize_conversion_of_events_target_id_to_bigint.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class InitializeConversionOfEventsTargetIdToBigint < Gitlab::Database::Migration[2.1]
+ TABLE = :events
+ COLUMNS = %i[target_id]
+
+ enable_lock_retries!
+
+ def up
+ initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+end
diff --git a/db/migrate/20230328165313_add_disabled_following_to_user_preferences.rb b/db/migrate/20230328165313_add_disabled_following_to_user_preferences.rb
new file mode 100644
index 00000000000..0841829c957
--- /dev/null
+++ b/db/migrate/20230328165313_add_disabled_following_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDisabledFollowingToUserPreferences < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :user_preferences, :enabled_following, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20230329032129_add_lock_version_to_terraform_state.rb b/db/migrate/20230329032129_add_lock_version_to_terraform_state.rb
new file mode 100644
index 00000000000..78f0122c609
--- /dev/null
+++ b/db/migrate/20230329032129_add_lock_version_to_terraform_state.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddLockVersionToTerraformState < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :terraform_states, :activerecord_lock_version, :integer, null: false, default: 0
+ end
+end
diff --git a/db/migrate/20230329085754_add_foreign_key_to_resource_link_events_on_user.rb b/db/migrate/20230329085754_add_foreign_key_to_resource_link_events_on_user.rb
new file mode 100644
index 00000000000..6a167f232ae
--- /dev/null
+++ b/db/migrate/20230329085754_add_foreign_key_to_resource_link_events_on_user.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToResourceLinkEventsOnUser < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :resource_link_events, :users, column: :user_id, on_delete: :nullify, validate: true
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :resource_link_events, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230329152410_add_achievements_enabled_to_user_preferences.rb b/db/migrate/20230329152410_add_achievements_enabled_to_user_preferences.rb
new file mode 100644
index 00000000000..bd11a4a6128
--- /dev/null
+++ b/db/migrate/20230329152410_add_achievements_enabled_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddAchievementsEnabledToUserPreferences < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :user_preferences, :achievements_enabled, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20230329194244_add_index_packages_debian_file_metadata_when_unknown.rb b/db/migrate/20230329194244_add_index_packages_debian_file_metadata_when_unknown.rb
new file mode 100644
index 00000000000..9b87f1319f3
--- /dev/null
+++ b/db/migrate/20230329194244_add_index_packages_debian_file_metadata_when_unknown.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexPackagesDebianFileMetadataWhenUnknown < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'i_pkgs_deb_file_meta_on_updated_at_package_file_id_when_unknown'
+ UNKNOWN = 1
+
+ def up
+ add_concurrent_index :packages_debian_file_metadata, [:updated_at, :package_file_id],
+ where: "file_type = #{UNKNOWN}", name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_debian_file_metadata, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230330101438_create_fk_ml_candidate_params_on_candidate_id.rb b/db/migrate/20230330101438_create_fk_ml_candidate_params_on_candidate_id.rb
new file mode 100644
index 00000000000..8273ffc27e2
--- /dev/null
+++ b/db/migrate/20230330101438_create_fk_ml_candidate_params_on_candidate_id.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateFkMlCandidateParamsOnCandidateId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ NEW_CONSTRAINT_NAME = 'fk_ml_candidate_params_on_candidate_id'
+
+ def up
+ add_concurrent_foreign_key(
+ :ml_candidate_params,
+ :ml_candidates,
+ column: :candidate_id,
+ on_delete: :cascade,
+ validate: false,
+ name: NEW_CONSTRAINT_NAME
+ )
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists(
+ :ml_candidate_params,
+ column: :candidate_id,
+ on_delete: :cascade,
+ name: NEW_CONSTRAINT_NAME
+ )
+ end
+ end
+end
diff --git a/db/migrate/20230330101439_validate_fk_ml_candidate_params_on_candidate_id.rb b/db/migrate/20230330101439_validate_fk_ml_candidate_params_on_candidate_id.rb
new file mode 100644
index 00000000000..912380ac3b7
--- /dev/null
+++ b/db/migrate/20230330101439_validate_fk_ml_candidate_params_on_candidate_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ValidateFkMlCandidateParamsOnCandidateId < Gitlab::Database::Migration[2.1]
+ NEW_CONSTRAINT_NAME = 'fk_ml_candidate_params_on_candidate_id'
+
+ def up
+ validate_foreign_key(:ml_candidate_params, :candidate_id, name: NEW_CONSTRAINT_NAME)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20230330101440_remove_old_fk_ml_candidate_params_on_candidate_id.rb b/db/migrate/20230330101440_remove_old_fk_ml_candidate_params_on_candidate_id.rb
new file mode 100644
index 00000000000..8e143cd3ed2
--- /dev/null
+++ b/db/migrate/20230330101440_remove_old_fk_ml_candidate_params_on_candidate_id.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveOldFkMlCandidateParamsOnCandidateId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ OLD_CONSTRAINT_NAME = 'fk_rails_d4a51d1185'
+
+ def up
+ remove_foreign_key_if_exists(:ml_candidate_params, column: :candidate_id, name: OLD_CONSTRAINT_NAME)
+ end
+
+ def down
+ add_concurrent_foreign_key(
+ :ml_candidate_params,
+ :ml_candidates,
+ column: :candidate_id,
+ validate: false,
+ name: OLD_CONSTRAINT_NAME
+ )
+ end
+end
diff --git a/db/migrate/20230330101441_create_fk_ml_candidate_metrics_on_candidate_id.rb b/db/migrate/20230330101441_create_fk_ml_candidate_metrics_on_candidate_id.rb
new file mode 100644
index 00000000000..0ef0075127d
--- /dev/null
+++ b/db/migrate/20230330101441_create_fk_ml_candidate_metrics_on_candidate_id.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateFkMlCandidateMetricsOnCandidateId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ NEW_CONSTRAINT_NAME = 'fk_ml_candidate_metrics_on_candidate_id'
+
+ def up
+ add_concurrent_foreign_key(
+ :ml_candidate_metrics,
+ :ml_candidates,
+ column: :candidate_id,
+ on_delete: :cascade,
+ validate: false,
+ name: NEW_CONSTRAINT_NAME
+ )
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists(
+ :ml_candidate_metrics,
+ column: :candidate_id,
+ on_delete: :cascade,
+ name: NEW_CONSTRAINT_NAME
+ )
+ end
+ end
+end
diff --git a/db/migrate/20230330101442_validate_fk_ml_candidate_metrics_on_candidate_id.rb b/db/migrate/20230330101442_validate_fk_ml_candidate_metrics_on_candidate_id.rb
new file mode 100644
index 00000000000..5180c6582cf
--- /dev/null
+++ b/db/migrate/20230330101442_validate_fk_ml_candidate_metrics_on_candidate_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ValidateFkMlCandidateMetricsOnCandidateId < Gitlab::Database::Migration[2.1]
+ NEW_CONSTRAINT_NAME = 'fk_ml_candidate_metrics_on_candidate_id'
+
+ def up
+ validate_foreign_key(:ml_candidate_metrics, :candidate_id, name: NEW_CONSTRAINT_NAME)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20230330101443_remove_old_fk_ml_candidate_metrics_on_candidate_id.rb b/db/migrate/20230330101443_remove_old_fk_ml_candidate_metrics_on_candidate_id.rb
new file mode 100644
index 00000000000..2e9153cb9d9
--- /dev/null
+++ b/db/migrate/20230330101443_remove_old_fk_ml_candidate_metrics_on_candidate_id.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveOldFkMlCandidateMetricsOnCandidateId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ OLD_CONSTRAINT_NAME = 'fk_rails_efb613a25a'
+
+ def up
+ remove_foreign_key_if_exists(:ml_candidate_metrics, column: :candidate_id, name: OLD_CONSTRAINT_NAME)
+ end
+
+ def down
+ add_concurrent_foreign_key(
+ :ml_candidate_metrics,
+ :ml_candidates,
+ column: :candidate_id,
+ validate: false,
+ name: OLD_CONSTRAINT_NAME
+ )
+ end
+end
diff --git a/db/migrate/20230330215636_remove_unused_project_jira_indexes.rb b/db/migrate/20230330215636_remove_unused_project_jira_indexes.rb
new file mode 100644
index 00000000000..ce10b70f81c
--- /dev/null
+++ b/db/migrate/20230330215636_remove_unused_project_jira_indexes.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class RemoveUnusedProjectJiraIndexes < Gitlab::Database::Migration[2.1]
+ TITLE_INDEX = {
+ name: 'index_merge_requests_on_target_project_id_and_iid_jira_title',
+ where: "((title)::text ~ '[A-Z][A-Z_0-9]+-\d+'::text)"
+ }.freeze
+
+ DESCRIPTION_INDEX = {
+ name: 'index_merge_requests_on_target_project_id_iid_jira_description',
+ where: "(description ~ '[A-Z][A-Z_0-9]+-\d+'::text)"
+ }.freeze
+
+ # TODO: Indexes to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/403327
+ def up
+ prepare_async_index_removal :merge_requests, [:target_project_id, :iid],
+ where: TITLE_INDEX[:where],
+ name: TITLE_INDEX[:name]
+
+ prepare_async_index_removal :merge_requests, [:target_project_id, :iid],
+ where: DESCRIPTION_INDEX[:where],
+ name: DESCRIPTION_INDEX[:name]
+ end
+
+ def down
+ unprepare_async_index :merge_requests, [:target_project_id, :iid],
+ where: TITLE_INDEX[:where],
+ name: TITLE_INDEX[:name]
+
+ unprepare_async_index :merge_requests, [:target_project_id, :iid],
+ where: DESCRIPTION_INDEX[:where],
+ name: DESCRIPTION_INDEX[:name]
+ end
+end
diff --git a/db/migrate/20230331142006_add_open_ai_api_key_application_setting.rb b/db/migrate/20230331142006_add_open_ai_api_key_application_setting.rb
new file mode 100644
index 00000000000..735cb414c99
--- /dev/null
+++ b/db/migrate/20230331142006_add_open_ai_api_key_application_setting.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddOpenAiApiKeyApplicationSetting < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :encrypted_openai_api_key, :binary
+ add_column :application_settings, :encrypted_openai_api_key_iv, :binary
+ end
+end
diff --git a/db/migrate/20230403023440_add_database_max_running_batched_background_migrations_to_application_settings.rb b/db/migrate/20230403023440_add_database_max_running_batched_background_migrations_to_application_settings.rb
new file mode 100644
index 00000000000..136855403f9
--- /dev/null
+++ b/db/migrate/20230403023440_add_database_max_running_batched_background_migrations_to_application_settings.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddDatabaseMaxRunningBatchedBackgroundMigrationsToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :database_max_running_batched_background_migrations,
+ :integer, null: false, default: 2
+ end
+end
diff --git a/db/migrate/20230403023441_set_max_running_batched_background_migrations_for_gitlab_com.rb b/db/migrate/20230403023441_set_max_running_batched_background_migrations_for_gitlab_com.rb
new file mode 100644
index 00000000000..6e8d423e679
--- /dev/null
+++ b/db/migrate/20230403023441_set_max_running_batched_background_migrations_for_gitlab_com.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class SetMaxRunningBatchedBackgroundMigrationsForGitlabCom < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ return unless Gitlab.com? && !Gitlab.jh?
+
+ execute 'UPDATE application_settings SET database_max_running_batched_background_migrations = 4'
+ end
+
+ def down
+ return unless Gitlab.com? && !Gitlab.jh?
+
+ execute 'UPDATE application_settings SET database_max_running_batched_background_migrations = 2'
+ end
+end
diff --git a/db/migrate/20230403093349_ensure_packages_npm_metadata_caches_is_empty.rb b/db/migrate/20230403093349_ensure_packages_npm_metadata_caches_is_empty.rb
new file mode 100644
index 00000000000..baeb368fda1
--- /dev/null
+++ b/db/migrate/20230403093349_ensure_packages_npm_metadata_caches_is_empty.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class EnsurePackagesNpmMetadataCachesIsEmpty < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ truncate_tables!('packages_npm_metadata_caches')
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20230403113620_add_pinned_nav_items_to_user_preference.rb b/db/migrate/20230403113620_add_pinned_nav_items_to_user_preference.rb
new file mode 100644
index 00000000000..8f7509db318
--- /dev/null
+++ b/db/migrate/20230403113620_add_pinned_nav_items_to_user_preference.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPinnedNavItemsToUserPreference < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :user_preferences, :pinned_nav_items, :jsonb, null: false, default: {}
+ end
+end
diff --git a/db/migrate/20230403145705_add_purl_sync_to_settings.rb b/db/migrate/20230403145705_add_purl_sync_to_settings.rb
new file mode 100644
index 00000000000..3bc9ce07235
--- /dev/null
+++ b/db/migrate/20230403145705_add_purl_sync_to_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddPurlSyncToSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :package_metadata_purl_types, :smallint, array: true, default: []
+ end
+end
diff --git a/db/migrate/20230403164454_add_fork_storage_size_columns_to_root_storage_statistics.rb b/db/migrate/20230403164454_add_fork_storage_size_columns_to_root_storage_statistics.rb
new file mode 100644
index 00000000000..3428fba669f
--- /dev/null
+++ b/db/migrate/20230403164454_add_fork_storage_size_columns_to_root_storage_statistics.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddForkStorageSizeColumnsToRootStorageStatistics < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_root_storage_statistics, :public_forks_storage_size, :bigint, default: 0, null: false
+ add_column :namespace_root_storage_statistics, :internal_forks_storage_size, :bigint, default: 0, null: false
+ add_column :namespace_root_storage_statistics, :private_forks_storage_size, :bigint, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20230404111427_add_first_contribution_to_merge_request_metrics.rb b/db/migrate/20230404111427_add_first_contribution_to_merge_request_metrics.rb
new file mode 100644
index 00000000000..d0366907191
--- /dev/null
+++ b/db/migrate/20230404111427_add_first_contribution_to_merge_request_metrics.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddFirstContributionToMergeRequestMetrics < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :merge_request_metrics, :first_contribution, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230404160131_add_status_to_data_repair_details.rb b/db/migrate/20230404160131_add_status_to_data_repair_details.rb
new file mode 100644
index 00000000000..564b0450752
--- /dev/null
+++ b/db/migrate/20230404160131_add_status_to_data_repair_details.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddStatusToDataRepairDetails < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_container_registry_data_repair_details_on_status'
+
+ def up
+ unless column_exists?(:container_registry_data_repair_details, :status)
+ add_column(:container_registry_data_repair_details, :status, :integer, default: 0, null: false, limit: 2)
+ end
+
+ add_concurrent_index :container_registry_data_repair_details, :status, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :container_registry_data_repair_details, name: INDEX_NAME
+ remove_column :container_registry_data_repair_details, :status
+ end
+end
diff --git a/db/migrate/20230405071033_add_object_storage_key_to_packages_npm_metadata_caches.rb b/db/migrate/20230405071033_add_object_storage_key_to_packages_npm_metadata_caches.rb
new file mode 100644
index 00000000000..a4c0f01ab2a
--- /dev/null
+++ b/db/migrate/20230405071033_add_object_storage_key_to_packages_npm_metadata_caches.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddObjectStorageKeyToPackagesNpmMetadataCaches < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_packages_npm_metadata_caches_on_object_storage_key'
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20230503191056_add_text_limit_to_packages_npm_metadata_caches_object_storage_key
+ def up
+ unless column_exists?(:packages_npm_metadata_caches, :object_storage_key)
+ # The existing table is empty.
+ # rubocop:disable Rails/NotNullColumn
+ add_column :packages_npm_metadata_caches, :object_storage_key, :text, null: false
+ # rubocop:enable Rails/NotNullColumn
+ end
+
+ add_concurrent_index :packages_npm_metadata_caches, :object_storage_key, unique: true, name: INDEX_NAME
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+
+ def down
+ remove_column :packages_npm_metadata_caches, :object_storage_key
+ end
+end
diff --git a/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb b/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb
new file mode 100644
index 00000000000..d732fb35ce9
--- /dev/null
+++ b/db/migrate/20230405102815_add_unique_namespace_index_to_storage_limit_exclusions.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddUniqueNamespaceIndexToStorageLimitExclusions < Gitlab::Database::Migration[2.1]
+ TABLE_NAME = 'namespaces_storage_limit_exclusions'
+ OLD_INDEX_NAME = 'index_namespaces_storage_limit_exclusions_on_namespace_id'
+ NEW_INDEX_NAME = 'unique_idx_namespaces_storage_limit_exclusions_on_namespace_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index TABLE_NAME, :namespace_id,
+ unique: true,
+ name: NEW_INDEX_NAME
+
+ remove_concurrent_index_by_name TABLE_NAME, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index TABLE_NAME, :namespace_id,
+ unique: false,
+ name: OLD_INDEX_NAME
+
+ remove_concurrent_index_by_name TABLE_NAME, NEW_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230406040908_add_system_note_metadata_id__to_resource_link_events.rb b/db/migrate/20230406040908_add_system_note_metadata_id__to_resource_link_events.rb
new file mode 100644
index 00000000000..042e588a5f5
--- /dev/null
+++ b/db/migrate/20230406040908_add_system_note_metadata_id__to_resource_link_events.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddSystemNoteMetadataIdToResourceLinkEvents < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :resource_link_events, :system_note_metadata_id, :bigint
+ end
+end
diff --git a/db/migrate/20230406042906_add_unique_index_to_resource_link_events_on_system_note_metadata_id.rb b/db/migrate/20230406042906_add_unique_index_to_resource_link_events_on_system_note_metadata_id.rb
new file mode 100644
index 00000000000..97d2e89c80b
--- /dev/null
+++ b/db/migrate/20230406042906_add_unique_index_to_resource_link_events_on_system_note_metadata_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexToResourceLinkEventsOnSystemNoteMetadataId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'unique_index_on_system_note_metadata_id'
+
+ def up
+ add_concurrent_index :resource_link_events, :system_note_metadata_id, unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :resource_link_events, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230406043900_add_system_note_metadata_foreign_key_to_resource_link_events.rb b/db/migrate/20230406043900_add_system_note_metadata_foreign_key_to_resource_link_events.rb
new file mode 100644
index 00000000000..431e7ac0e7e
--- /dev/null
+++ b/db/migrate/20230406043900_add_system_note_metadata_foreign_key_to_resource_link_events.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddSystemNoteMetadataForeignKeyToResourceLinkEvents < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :resource_link_events, :system_note_metadata,
+ column: :system_note_metadata_id, on_delete: :cascade, validate: false
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :resource_link_events, column: :system_note_metadata_id
+ end
+ end
+end
diff --git a/db/migrate/20230406060452_create_instance_external_audit_event_destinations.rb b/db/migrate/20230406060452_create_instance_external_audit_event_destinations.rb
new file mode 100644
index 00000000000..4347d13ceb4
--- /dev/null
+++ b/db/migrate/20230406060452_create_instance_external_audit_event_destinations.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateInstanceExternalAuditEventDestinations < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :audit_events_instance_external_audit_event_destinations do |t|
+ t.timestamps_with_timezone null: false
+ t.text :destination_url, null: false, limit: 255 # rubocop:disable Migration/AddLimitToTextColumns
+ t.binary :encrypted_verification_token, null: false
+ t.binary :encrypted_verification_token_iv, null: false
+ end
+ end
+end
diff --git a/db/migrate/20230406073847_validate_foreign_key_for_resource_link_events_on_system_note_metadata_id.rb b/db/migrate/20230406073847_validate_foreign_key_for_resource_link_events_on_system_note_metadata_id.rb
new file mode 100644
index 00000000000..f06657ccabc
--- /dev/null
+++ b/db/migrate/20230406073847_validate_foreign_key_for_resource_link_events_on_system_note_metadata_id.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class ValidateForeignKeyForResourceLinkEventsOnSystemNoteMetadataId < Gitlab::Database::Migration[2.1]
+ def up
+ validate_foreign_key :resource_link_events, :system_note_metadata_id
+ end
+
+ def down
+ # No-op
+ end
+end
diff --git a/db/migrate/20230406095544_add_pa_configurator_base_to_app_settings.rb b/db/migrate/20230406095544_add_pa_configurator_base_to_app_settings.rb
new file mode 100644
index 00000000000..b6b33cdf17b
--- /dev/null
+++ b/db/migrate/20230406095544_add_pa_configurator_base_to_app_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddPaConfiguratorBaseToAppSettings < Gitlab::Database::Migration[2.1]
+ def up
+ add_column :application_settings, :encrypted_product_analytics_configurator_connection_string, :binary
+ add_column :application_settings, :encrypted_product_analytics_configurator_connection_string_iv, :binary
+ end
+
+ def down
+ remove_column :application_settings, :encrypted_product_analytics_configurator_connection_string
+ remove_column :application_settings, :encrypted_product_analytics_configurator_connection_string_iv
+ end
+end
diff --git a/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb b/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb
new file mode 100644
index 00000000000..0b7fcceb3ee
--- /dev/null
+++ b/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddIdentityToggleToUserPreferences < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :user_preferences, :pass_user_identities_to_ci_jwt, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230406150254_create_agent_user_access_project_authorizations_table.rb b/db/migrate/20230406150254_create_agent_user_access_project_authorizations_table.rb
new file mode 100644
index 00000000000..1adc3bb001a
--- /dev/null
+++ b/db/migrate/20230406150254_create_agent_user_access_project_authorizations_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateAgentUserAccessProjectAuthorizationsTable < Gitlab::Database::Migration[2.1]
+ INDEX_NAME_1 = 'index_agent_user_access_on_project_id'
+ INDEX_NAME_2 = 'index_agent_user_access_on_agent_id_and_project_id'
+
+ def change
+ create_table :agent_user_access_project_authorizations do |t|
+ t.bigint :project_id, null: false
+ t.bigint :agent_id, null: false
+ t.jsonb :config, null: false
+
+ t.index [:project_id], name: INDEX_NAME_1
+ t.index [:agent_id, :project_id], unique: true, name: INDEX_NAME_2
+ end
+ end
+end
diff --git a/db/migrate/20230406150354_create_agent_user_access_group_authorizations_table.rb b/db/migrate/20230406150354_create_agent_user_access_group_authorizations_table.rb
new file mode 100644
index 00000000000..1d4df7d7330
--- /dev/null
+++ b/db/migrate/20230406150354_create_agent_user_access_group_authorizations_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateAgentUserAccessGroupAuthorizationsTable < Gitlab::Database::Migration[2.1]
+ INDEX_NAME_1 = 'index_agent_user_access_on_group_id'
+ INDEX_NAME_2 = 'index_agent_user_access_on_agent_id_and_group_id'
+
+ def change
+ create_table :agent_user_access_group_authorizations do |t|
+ t.bigint :group_id, null: false
+ t.bigint :agent_id, null: false
+ t.jsonb :config, null: false
+
+ t.index [:group_id], name: INDEX_NAME_1
+ t.index [:agent_id, :group_id], unique: true, name: INDEX_NAME_2
+ end
+ end
+end
diff --git a/db/migrate/20230406150454_add_fks_to_agent_user_access_authorizations.rb b/db/migrate/20230406150454_add_fks_to_agent_user_access_authorizations.rb
new file mode 100644
index 00000000000..62f00620108
--- /dev/null
+++ b/db/migrate/20230406150454_add_fks_to_agent_user_access_authorizations.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class AddFksToAgentUserAccessAuthorizations < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :agent_user_access_project_authorizations, :projects,
+ column: :project_id, on_delete: :cascade
+ add_concurrent_foreign_key :agent_user_access_project_authorizations, :cluster_agents,
+ column: :agent_id, on_delete: :cascade
+ add_concurrent_foreign_key :agent_user_access_group_authorizations, :namespaces,
+ column: :group_id, on_delete: :cascade
+ add_concurrent_foreign_key :agent_user_access_group_authorizations, :cluster_agents,
+ column: :agent_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_user_access_project_authorizations, column: :project_id
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_user_access_project_authorizations, column: :agent_id
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_user_access_group_authorizations, column: :group_id
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_user_access_group_authorizations, column: :agent_id
+ end
+ end
+end
diff --git a/db/migrate/20230407164616_add_code_suggestions_to_namespace_settings.rb b/db/migrate/20230407164616_add_code_suggestions_to_namespace_settings.rb
new file mode 100644
index 00000000000..ce500fec2f0
--- /dev/null
+++ b/db/migrate/20230407164616_add_code_suggestions_to_namespace_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddCodeSuggestionsToNamespaceSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_settings, :code_suggestions, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230410092450_add_product_analytics_instrumentation_key_to_project_settings.rb b/db/migrate/20230410092450_add_product_analytics_instrumentation_key_to_project_settings.rb
new file mode 100644
index 00000000000..eaaddef083c
--- /dev/null
+++ b/db/migrate/20230410092450_add_product_analytics_instrumentation_key_to_project_settings.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddProductAnalyticsInstrumentationKeyToProjectSettings < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb
+ def up
+ with_lock_retries do
+ add_column :project_settings, :product_analytics_instrumentation_key, :text unless
+ column_exists?(:project_settings, :product_analytics_instrumentation_key)
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :project_settings, :product_analytics_instrumentation_key
+ end
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230411171001_create_abuse_trust_scores.rb b/db/migrate/20230411171001_create_abuse_trust_scores.rb
new file mode 100644
index 00000000000..2c95a2ab01e
--- /dev/null
+++ b/db/migrate/20230411171001_create_abuse_trust_scores.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateAbuseTrustScores < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :abuse_trust_scores do |t|
+ t.belongs_to :user, foreign_key: { to_table: :users, on_delete: :cascade }, index: false
+
+ t.float :score, null: false
+ t.timestamps_with_timezone null: false
+ t.integer :source, limit: 2, null: false
+ t.text :correlation_id_value, limit: 32
+
+ t.index [:user_id, :source, :created_at]
+ end
+ end
+end
diff --git a/db/migrate/20230411205121_create_package_metadata_advisory_info.rb b/db/migrate/20230411205121_create_package_metadata_advisory_info.rb
new file mode 100644
index 00000000000..adfc8e868f7
--- /dev/null
+++ b/db/migrate/20230411205121_create_package_metadata_advisory_info.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+class CreatePackageMetadataAdvisoryInfo < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :pm_advisories do |t|
+ t.text :advisory_xid, limit: 36, null: false
+ t.date :published_date, null: false
+ t.timestamps_with_timezone null: false
+ t.integer :source_xid, limit: 2, null: false
+
+ t.text :title, limit: 256
+ t.text :description, limit: 8192
+ t.text :cvss_v2, limit: 128
+ t.text :cvss_v3, limit: 128
+ t.text :urls, array: true, default: []
+ t.jsonb :identifiers, null: false
+
+ t.index [:advisory_xid, :source_xid], unique: true
+ t.check_constraint 'CARDINALITY(urls) <= 10'
+ end
+
+ create_table :pm_affected_packages do |t|
+ t.references :pm_advisory, index: true, foreign_key: { on_delete: :cascade }, null: false
+ t.timestamps_with_timezone null: false
+ t.integer :purl_type, limit: 2, null: false
+
+ t.text :package_name, limit: 256, null: false
+ t.text :distro_version, limit: 256, null: true
+ t.text :solution, limit: 2048, null: true
+ t.text :affected_range, limit: 512, null: false
+ t.text :fixed_versions, array: true, default: []
+ t.jsonb :overridden_advisory_fields, null: false, default: {}
+
+ t.index [:pm_advisory_id, :purl_type, :package_name, :distro_version], unique: true,
+ name: 'i_affected_packages_unique_for_upsert'
+ t.check_constraint 'CARDINALITY(fixed_versions) <= 10'
+ end
+ end
+end
diff --git a/db/migrate/20230412073614_create_issue_assignment_events.rb b/db/migrate/20230412073614_create_issue_assignment_events.rb
new file mode 100644
index 00000000000..1b57c59eb2b
--- /dev/null
+++ b/db/migrate/20230412073614_create_issue_assignment_events.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateIssueAssignmentEvents < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :issue_assignment_events do |t|
+ t.references :user, null: true, index: true, foreign_key: { on_delete: :nullify }
+ t.bigint :issue_id, null: false
+ t.datetime_with_timezone :created_at, null: false, default: -> { 'NOW()' }
+ t.integer :action, limit: 2, null: false, default: 1
+
+ t.index %i[issue_id action created_at id], name: 'index_on_issue_assignment_events_issue_id_action_created_at_id'
+ end
+ end
+end
diff --git a/db/migrate/20230412080242_add_concurrent_fk_to_issue_assignment_events.rb b/db/migrate/20230412080242_add_concurrent_fk_to_issue_assignment_events.rb
new file mode 100644
index 00000000000..3bff98c6e69
--- /dev/null
+++ b/db/migrate/20230412080242_add_concurrent_fk_to_issue_assignment_events.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddConcurrentFkToIssueAssignmentEvents < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :issue_assignment_events,
+ :issues,
+ column: :issue_id,
+ on_delete: :cascade
+ end
+
+ def down
+ remove_foreign_key_if_exists :resource_assignment_events, column: :issue_id
+ end
+end
diff --git a/db/migrate/20230412151659_add_ci_job_artifacts_file_final_path.rb b/db/migrate/20230412151659_add_ci_job_artifacts_file_final_path.rb
new file mode 100644
index 00000000000..18bf8640a45
--- /dev/null
+++ b/db/migrate/20230412151659_add_ci_job_artifacts_file_final_path.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddCiJobArtifactsFileFinalPath < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in db/post_migrate/20230412152538_add_text_limit_to_ci_job_artifacts_file_final_path.rb
+ def change
+ add_column :ci_job_artifacts, :file_final_path, :text, null: true
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230412185920_validate_ci_job_artifacts_file_final_path.rb b/db/migrate/20230412185920_validate_ci_job_artifacts_file_final_path.rb
new file mode 100644
index 00000000000..464ac1eec72
--- /dev/null
+++ b/db/migrate/20230412185920_validate_ci_job_artifacts_file_final_path.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class ValidateCiJobArtifactsFileFinalPath < Gitlab::Database::Migration[2.1]
+ def up
+ constraint_name = text_limit_name(:ci_job_artifacts, :file_final_path)
+ validate_check_constraint :ci_job_artifacts, constraint_name
+ end
+
+ # No-op
+ def down; end
+end
diff --git a/db/migrate/20230413080906_create_merge_request_assignment_events.rb b/db/migrate/20230413080906_create_merge_request_assignment_events.rb
new file mode 100644
index 00000000000..b976dc8935a
--- /dev/null
+++ b/db/migrate/20230413080906_create_merge_request_assignment_events.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateMergeRequestAssignmentEvents < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :merge_request_assignment_events do |t|
+ t.references :user, null: true, index: true, foreign_key: { on_delete: :nullify }
+ t.bigint :merge_request_id, null: false
+ t.datetime_with_timezone :created_at, null: false, default: -> { 'NOW()' }
+ t.integer :action, limit: 2, null: false, default: 1
+
+ t.index %i[merge_request_id action created_at id],
+ name: 'index_on_mr_assignment_events_mr_id_action_created_at_id'
+ end
+ end
+end
diff --git a/db/migrate/20230413080918_add_concurrent_fk_to_merge_request_assignment_events.rb b/db/migrate/20230413080918_add_concurrent_fk_to_merge_request_assignment_events.rb
new file mode 100644
index 00000000000..5b7d08a3547
--- /dev/null
+++ b/db/migrate/20230413080918_add_concurrent_fk_to_merge_request_assignment_events.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddConcurrentFkToMergeRequestAssignmentEvents < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_request_assignment_events,
+ :merge_requests,
+ column: :merge_request_id,
+ on_delete: :cascade
+ end
+
+ def down
+ remove_foreign_key_if_exists :merge_request_assignment_events, column: :merge_request_id
+ end
+end
diff --git a/db/migrate/20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb b/db/migrate/20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb
new file mode 100644
index 00000000000..7ec0a800066
--- /dev/null
+++ b/db/migrate/20230413153140_add_text_limit_to_project_settings_instrumentation_key.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToProjectSettingsInstrumentationKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :project_settings, :product_analytics_instrumentation_key, 255
+ end
+
+ def down
+ remove_text_limit :project_settings, :product_analytics_instrumentation_key
+ end
+end
diff --git a/db/migrate/20230414190012_add_product_analytics_to_project_settings.rb b/db/migrate/20230414190012_add_product_analytics_to_project_settings.rb
new file mode 100644
index 00000000000..c77168f05be
--- /dev/null
+++ b/db/migrate/20230414190012_add_product_analytics_to_project_settings.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+class AddProductAnalyticsToProjectSettings < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :project_settings, :jitsu_host, :text, if_not_exists: true
+ add_column :project_settings, :jitsu_project_xid, :text, if_not_exists: true
+ add_column :project_settings, :jitsu_administrator_email, :text, if_not_exists: true
+ add_column :project_settings, :encrypted_jitsu_administrator_password, :binary, if_not_exists: true
+ add_column :project_settings, :encrypted_jitsu_administrator_password_iv, :binary, if_not_exists: true
+ add_column :project_settings, :product_analytics_data_collector_host, :text, if_not_exists: true
+ add_column :project_settings, :encrypted_product_analytics_clickhouse_connection_string,
+ :binary, if_not_exists: true
+ add_column :project_settings, :encrypted_product_analytics_clickhouse_connection_string_iv,
+ :binary, if_not_exists: true
+ add_column :project_settings, :cube_api_base_url, :text, if_not_exists: true
+ add_column :project_settings, :encrypted_cube_api_key, :binary, if_not_exists: true
+ add_column :project_settings, :encrypted_cube_api_key_iv, :binary, if_not_exists: true
+ end
+
+ add_text_limit :project_settings, :jitsu_host, 255
+ add_text_limit :project_settings, :jitsu_project_xid, 255
+ add_text_limit :project_settings, :jitsu_administrator_email, 255
+ add_text_limit :project_settings, :product_analytics_data_collector_host, 255
+ add_text_limit :project_settings, :cube_api_base_url, 512
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :project_settings, :jitsu_host, if_exists: true
+ remove_column :project_settings, :jitsu_project_xid, if_exists: true
+ remove_column :project_settings, :jitsu_administrator_email, if_exists: true
+ remove_column :project_settings, :encrypted_jitsu_administrator_password, if_exists: true
+ remove_column :project_settings, :encrypted_jitsu_administrator_password_iv, if_exists: true
+ remove_column :project_settings, :product_analytics_data_collector_host, if_exists: true
+ remove_column :project_settings, :encrypted_product_analytics_clickhouse_connection_string, if_exists: true
+ remove_column :project_settings, :encrypted_product_analytics_clickhouse_connection_string_iv, if_exists: true
+ remove_column :project_settings, :cube_api_base_url, if_exists: true
+ remove_column :project_settings, :encrypted_cube_api_key, if_exists: true
+ remove_column :project_settings, :encrypted_cube_api_key_iv, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20230414230535_add_external_identifiers_index_to_import_failures.rb.rb b/db/migrate/20230414230535_add_external_identifiers_index_to_import_failures.rb.rb
new file mode 100644
index 00000000000..5d9a35108f4
--- /dev/null
+++ b/db/migrate/20230414230535_add_external_identifiers_index_to_import_failures.rb.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddExternalIdentifiersIndexToImportFailures < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_import_failures_on_external_identifiers'
+
+ def up
+ add_concurrent_index :import_failures, :external_identifiers, name: INDEX_NAME,
+ where: "external_identifiers != '{}'"
+ end
+
+ def down
+ remove_concurrent_index_by_name :import_failures, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230417145900_add_visibility_pipeline_id_type_to_user_preferences.rb b/db/migrate/20230417145900_add_visibility_pipeline_id_type_to_user_preferences.rb
new file mode 100644
index 00000000000..2c58a40f244
--- /dev/null
+++ b/db/migrate/20230417145900_add_visibility_pipeline_id_type_to_user_preferences.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddVisibilityPipelineIdTypeToUserPreferences < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :user_preferences, :visibility_pipeline_id_type, :integer, default: 0, limit: 2, null: false
+ end
+end
diff --git a/db/migrate/20230418183540_create_project_states.rb b/db/migrate/20230418183540_create_project_states.rb
new file mode 100644
index 00000000000..b23436028b5
--- /dev/null
+++ b/db/migrate/20230418183540_create_project_states.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+class CreateProjectStates < Gitlab::Database::Migration[2.1]
+ VERIFICATION_STATE_INDEX_NAME = "index_project_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_project_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_project_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_project_states_needs_verification"
+
+ enable_lock_retries!
+
+ def up
+ create_table :project_states do |t|
+ t.datetime_with_timezone :verification_started_at
+ t.datetime_with_timezone :verification_retry_at
+ t.datetime_with_timezone :verified_at
+ t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.integer :verification_state, default: 0, limit: 2, null: false
+ t.integer :verification_retry_count, default: 0, limit: 2, null: false
+ t.binary :verification_checksum, using: 'verification_checksum::bytea'
+ t.text :verification_failure, limit: 255
+
+ t.index :verification_state,
+ name: VERIFICATION_STATE_INDEX_NAME
+
+ t.index :verified_at,
+ where: "(verification_state = 0)",
+ order: { verified_at: 'ASC NULLS FIRST' },
+ name: PENDING_VERIFICATION_INDEX_NAME
+
+ t.index :verification_retry_at,
+ where: "(verification_state = 3)",
+ order: { verification_retry_at: 'ASC NULLS FIRST' },
+ name: FAILED_VERIFICATION_INDEX_NAME
+
+ t.index :verification_state,
+ where: "(verification_state = 0 OR verification_state = 3)",
+ name: NEEDS_VERIFICATION_INDEX_NAME
+ end
+ end
+
+ def down
+ drop_table :project_states
+ end
+end
diff --git a/db/migrate/20230418215853_add_assignee_widget_to_incidents.rb b/db/migrate/20230418215853_add_assignee_widget_to_incidents.rb
new file mode 100644
index 00000000000..66eaee8ab87
--- /dev/null
+++ b/db/migrate/20230418215853_add_assignee_widget_to_incidents.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+class AddAssigneeWidgetToIncidents < Gitlab::Database::Migration[2.1]
+ class WorkItemType < MigrationRecord
+ self.table_name = 'work_item_types'
+ end
+
+ class WidgetDefinition < MigrationRecord
+ self.table_name = 'work_item_widget_definitions'
+ end
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ WIDGET_NAME = 'Assignees'
+ WIDGET_ENUM_VALUE = 0
+ WORK_ITEM_TYPE = 'Incident'
+ FAILURE_MSG = "type #{WORK_ITEM_TYPE} is missing, not adding widget"
+
+ def up
+ type = WorkItemType.find_by_name_and_namespace_id(WORK_ITEM_TYPE, nil)
+
+ unless type
+ say(FAILURE_MSG)
+ Gitlab::AppLogger.warn(FAILURE_MSG)
+
+ return
+ end
+
+ widgets = [{
+ work_item_type_id: type.id,
+ name: WIDGET_NAME,
+ widget_type: WIDGET_ENUM_VALUE
+ }]
+
+ WidgetDefinition.upsert_all(
+ widgets,
+ unique_by: :index_work_item_widget_definitions_on_default_witype_and_name
+ )
+ end
+
+ def down
+ type = WorkItemType.find_by_name_and_namespace_id(WORK_ITEM_TYPE, nil)
+ return unless type
+
+ WidgetDefinition.where(work_item_type_id: type, name: WIDGET_NAME).delete_all
+ end
+end
diff --git a/db/migrate/20230419105225_remove_phabricator_from_application_settings.rb b/db/migrate/20230419105225_remove_phabricator_from_application_settings.rb
new file mode 100644
index 00000000000..42b27d3dd76
--- /dev/null
+++ b/db/migrate/20230419105225_remove_phabricator_from_application_settings.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class RemovePhabricatorFromApplicationSettings < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class ApplicationSetting < MigrationRecord
+ end
+
+ def up
+ return if import_sources.empty?
+
+ new_sources = import_sources - ['phabricator']
+
+ ApplicationSetting.update_all(import_sources: new_sources.to_yaml)
+ end
+
+ def down
+ ## a reversion is not needed as Phabricator is no longer a supported import source
+ # and attempting to save it as one will result in a ActiveRecord error.
+ end
+
+ def import_sources
+ ## the last ApplicationSetting record is used to determine application settings
+ import_sources = ApplicationSetting.last&.import_sources
+ import_sources.nil? ? [] : YAML.safe_load(import_sources)
+ end
+end
diff --git a/db/migrate/20230419130952_remove_github_import_job_instances.rb b/db/migrate/20230419130952_remove_github_import_job_instances.rb
new file mode 100644
index 00000000000..e7028032eb4
--- /dev/null
+++ b/db/migrate/20230419130952_remove_github_import_job_instances.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveGithubImportJobInstances < Gitlab::Database::Migration[2.1]
+ def up
+ # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/9300
+ end
+
+ def down
+ # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/9300
+ end
+end
diff --git a/db/migrate/20230419192748_add_bot_user_id_to_security_orchestration_policy_configurations.rb b/db/migrate/20230419192748_add_bot_user_id_to_security_orchestration_policy_configurations.rb
new file mode 100644
index 00000000000..980581c3727
--- /dev/null
+++ b/db/migrate/20230419192748_add_bot_user_id_to_security_orchestration_policy_configurations.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddBotUserIdToSecurityOrchestrationPolicyConfigurations < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :security_orchestration_policy_configurations, :bot_user_id, :integer
+ end
+end
diff --git a/db/migrate/20230419193807_add_foreign_key_for_bot_user_id_to_security_orchestration_policy_configurations.rb b/db/migrate/20230419193807_add_foreign_key_for_bot_user_id_to_security_orchestration_policy_configurations.rb
new file mode 100644
index 00000000000..5a809aa9692
--- /dev/null
+++ b/db/migrate/20230419193807_add_foreign_key_for_bot_user_id_to_security_orchestration_policy_configurations.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddForeignKeyForBotUserIdToSecurityOrchestrationPolicyConfigurations < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_security_policy_configurations_on_bot_user_id'
+
+ def up
+ add_concurrent_foreign_key :security_orchestration_policy_configurations, :users, column: :bot_user_id,
+ on_delete: :nullify
+
+ add_concurrent_index :security_orchestration_policy_configurations, :bot_user_id,
+ where: "security_orchestration_policy_configurations.bot_user_id IS NOT NULL",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :security_orchestration_policy_configurations, INDEX_NAME
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :security_orchestration_policy_configurations, column: :bot_user_id
+ end
+ end
+end
diff --git a/db/migrate/20230420012220_create_organizations.rb b/db/migrate/20230420012220_create_organizations.rb
new file mode 100644
index 00000000000..ba6e89837d8
--- /dev/null
+++ b/db/migrate/20230420012220_create_organizations.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class CreateOrganizations < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :organizations do |t|
+ t.timestamps_with_timezone null: false
+ end
+ end
+end
diff --git a/db/migrate/20230420040912_initialize_conversion_of_ci_pipelines.rb b/db/migrate/20230420040912_initialize_conversion_of_ci_pipelines.rb
new file mode 100644
index 00000000000..84bad801ce4
--- /dev/null
+++ b/db/migrate/20230420040912_initialize_conversion_of_ci_pipelines.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class InitializeConversionOfCiPipelines < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE = :ci_pipelines
+ COLUMNS = %i[id]
+
+ def up
+ initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+end
diff --git a/db/migrate/20230420115733_add_ai_settings_to_namespace_settings.rb b/db/migrate/20230420115733_add_ai_settings_to_namespace_settings.rb
new file mode 100644
index 00000000000..681691d39c7
--- /dev/null
+++ b/db/migrate/20230420115733_add_ai_settings_to_namespace_settings.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddAiSettingsToNamespaceSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_settings, :experiment_features_enabled, :boolean, default: false, null: false
+ add_column :namespace_settings, :third_party_ai_features_enabled, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20230420131608_add_partitioned_vsd_counts_table.rb b/db/migrate/20230420131608_add_partitioned_vsd_counts_table.rb
new file mode 100644
index 00000000000..dc2a3a15239
--- /dev/null
+++ b/db/migrate/20230420131608_add_partitioned_vsd_counts_table.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class AddPartitionedVsdCountsTable < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+
+ def up
+ execute(<<~SQL)
+ CREATE TABLE value_stream_dashboard_counts (
+ id bigserial NOT NULL,
+ namespace_id bigint NOT NULL,
+ count bigint NOT NULL,
+ recorded_at timestamp with time zone NOT NULL,
+ metric smallint NOT NULL,
+ PRIMARY KEY (namespace_id, metric, recorded_at, count, id)
+ ) PARTITION BY RANGE (recorded_at);
+ SQL
+
+ min_date = Date.today
+ max_date = Date.today + 6.months
+ create_daterange_partitions('value_stream_dashboard_counts', 'recorded_at', min_date, max_date)
+ end
+
+ def down
+ drop_table :value_stream_dashboard_counts
+ end
+end
diff --git a/db/migrate/20230420132910_create_ci_ai_conversation.rb b/db/migrate/20230420132910_create_ci_ai_conversation.rb
new file mode 100644
index 00000000000..7676a2b0ae1
--- /dev/null
+++ b/db/migrate/20230420132910_create_ci_ai_conversation.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class CreateCiAiConversation < Gitlab::Database::Migration[2.1]
+ def up
+ create_table :ci_editor_ai_conversation_messages do |t|
+ t.bigint :user_id,
+ null: false
+ t.bigint :project_id,
+ null: false
+ t.timestamps_with_timezone null: false
+ t.text :role, limit: 100,
+ null: false
+ t.text :content, limit: 16384,
+ null: true
+ t.text :async_errors, array: true, null: false, default: []
+
+ t.index [:user_id, :project_id, :created_at],
+ name: :index_ci_editor_ai_messages_on_user_project_and_created_at
+
+ t.index :project_id,
+ name: :index_ci_editor_ai_messages_project_id
+
+ t.index :created_at,
+ name: :index_ci_editor_ai_messages_created_at
+ end
+ end
+
+ def down
+ drop_table :ci_editor_ai_conversation_messages
+ end
+end
diff --git a/db/migrate/20230421035557_create_note_metadata.rb b/db/migrate/20230421035557_create_note_metadata.rb
new file mode 100644
index 00000000000..fd15d8510d1
--- /dev/null
+++ b/db/migrate/20230421035557_create_note_metadata.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateNoteMetadata < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :note_metadata, id: false do |t|
+ t.references :note,
+ primary_key: true,
+ null: false,
+ type: :bigint,
+ index: true,
+ foreign_key: { on_delete: :cascade }
+ t.text :email_participant, null: true, limit: 255
+ t.timestamps_with_timezone null: true
+ end
+ end
+end
diff --git a/db/migrate/20230421081907_add_auth_type_to_jira_tracker_data.rb b/db/migrate/20230421081907_add_auth_type_to_jira_tracker_data.rb
new file mode 100644
index 00000000000..4b2ae667e69
--- /dev/null
+++ b/db/migrate/20230421081907_add_auth_type_to_jira_tracker_data.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddAuthTypeToJiraTrackerData < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def change
+ add_column :jira_tracker_data, :jira_auth_type, :smallint, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20230421124302_epic_boards_show_colors.rb b/db/migrate/20230421124302_epic_boards_show_colors.rb
new file mode 100644
index 00000000000..cfc8e228196
--- /dev/null
+++ b/db/migrate/20230421124302_epic_boards_show_colors.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class EpicBoardsShowColors < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :boards_epic_boards, :display_colors, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20230421165020_add_ci_max_includes_to_application_settings.rb b/db/migrate/20230421165020_add_ci_max_includes_to_application_settings.rb
new file mode 100644
index 00000000000..9996d3b1654
--- /dev/null
+++ b/db/migrate/20230421165020_add_ci_max_includes_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddCiMaxIncludesToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :ci_max_includes, :integer, default: 150, null: false
+ end
+end
diff --git a/db/migrate/20230424094117_add_read_vulnerability_to_member_roles.rb b/db/migrate/20230424094117_add_read_vulnerability_to_member_roles.rb
new file mode 100644
index 00000000000..4ae4a7f6bff
--- /dev/null
+++ b/db/migrate/20230424094117_add_read_vulnerability_to_member_roles.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddReadVulnerabilityToMemberRoles < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :member_roles, :read_vulnerability, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230424122236_add_ci_build_id_to_ml_candidate.rb b/db/migrate/20230424122236_add_ci_build_id_to_ml_candidate.rb
new file mode 100644
index 00000000000..b777f365242
--- /dev/null
+++ b/db/migrate/20230424122236_add_ci_build_id_to_ml_candidate.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddCiBuildIdToMlCandidate < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :ml_candidates, :ci_build_id, :bigint, null: true
+ end
+end
diff --git a/db/migrate/20230424131551_add_index_on_ci_build_id_to_ml_candidates.rb b/db/migrate/20230424131551_add_index_on_ci_build_id_to_ml_candidates.rb
new file mode 100644
index 00000000000..89e5be7e1c5
--- /dev/null
+++ b/db/migrate/20230424131551_add_index_on_ci_build_id_to_ml_candidates.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnCiBuildIdToMlCandidates < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ml_candidates_on_ci_build_id'
+
+ def up
+ add_concurrent_index :ml_candidates, :ci_build_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ml_candidates, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230424155321_add_licenses_field_to_package_metadata_packages.rb b/db/migrate/20230424155321_add_licenses_field_to_package_metadata_packages.rb
new file mode 100644
index 00000000000..99a8f5633dd
--- /dev/null
+++ b/db/migrate/20230424155321_add_licenses_field_to_package_metadata_packages.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddLicensesFieldToPackageMetadataPackages < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :pm_packages, :licenses, :jsonb, null: true
+ end
+end
diff --git a/db/migrate/20230424194721_add_tofa_application_settings.rb b/db/migrate/20230424194721_add_tofa_application_settings.rb
new file mode 100644
index 00000000000..c39e85a1a87
--- /dev/null
+++ b/db/migrate/20230424194721_add_tofa_application_settings.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class AddTofaApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ change_table(:application_settings, bulk: true) do |t|
+ t.column :encrypted_tofa_credentials, :binary
+ t.column :encrypted_tofa_credentials_iv, :binary
+ t.column :encrypted_tofa_host, :binary
+ t.column :encrypted_tofa_host_iv, :binary
+ t.column :encrypted_tofa_url, :binary
+ t.column :encrypted_tofa_url_iv, :binary
+ t.column :encrypted_tofa_response_json_keys, :binary
+ t.column :encrypted_tofa_response_json_keys_iv, :binary
+ t.column :encrypted_tofa_request_json_keys, :binary
+ t.column :encrypted_tofa_request_json_keys_iv, :binary
+ t.column :encrypted_tofa_request_payload, :binary
+ t.column :encrypted_tofa_request_payload_iv, :binary
+ t.column :encrypted_tofa_client_library_class, :binary
+ t.column :encrypted_tofa_client_library_class_iv, :binary
+ t.column :encrypted_tofa_client_library_args, :binary
+ t.column :encrypted_tofa_client_library_args_iv, :binary
+ t.column :encrypted_tofa_client_library_create_credentials_method, :binary
+ t.column :encrypted_tofa_client_library_create_credentials_method_iv, :binary
+ t.column :encrypted_tofa_client_library_fetch_access_token_method, :binary
+ t.column :encrypted_tofa_client_library_fetch_access_token_method_iv, :binary
+ t.column :encrypted_tofa_access_token_expires_in, :binary
+ t.column :encrypted_tofa_access_token_expires_in_iv, :binary
+ end
+ end
+end
diff --git a/db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb b/db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb
new file mode 100644
index 00000000000..cf91b2a52d4
--- /dev/null
+++ b/db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveCreateCrossProjectPipelineWorkerJobInstances < Gitlab::Database::Migration[2.1]
+ def up
+ # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/9566
+ end
+
+ def down
+ # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/9566
+ end
+end
diff --git a/db/migrate/20230425173111_create_merge_request_diff_llm_summary.rb b/db/migrate/20230425173111_create_merge_request_diff_llm_summary.rb
new file mode 100644
index 00000000000..f37459d764e
--- /dev/null
+++ b/db/migrate/20230425173111_create_merge_request_diff_llm_summary.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateMergeRequestDiffLlmSummary < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = "index_merge_request_diff_llm_summaries_on_mr_diff_id"
+
+ def change
+ create_table :merge_request_diff_llm_summaries do |t|
+ t.bigint :user_id, null: true, index: true
+ t.bigint :merge_request_diff_id, null: false, index:
+ { name: INDEX_NAME }
+ t.timestamps_with_timezone null: false
+ t.integer :provider, null: false, limit: 2
+ t.text :content, null: false, limit: 2056
+ end
+ end
+end
diff --git a/db/migrate/20230426102200_fix_import_sources_on_application_settings_after_phabricator_removal.rb b/db/migrate/20230426102200_fix_import_sources_on_application_settings_after_phabricator_removal.rb
new file mode 100644
index 00000000000..e2061138fc4
--- /dev/null
+++ b/db/migrate/20230426102200_fix_import_sources_on_application_settings_after_phabricator_removal.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class FixImportSourcesOnApplicationSettingsAfterPhabricatorRemoval < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class ApplicationSetting < MigrationRecord
+ end
+
+ def up
+ sources = ApplicationSetting.last&.import_sources
+
+ return unless sources.is_a?(String)
+ return if sources.start_with?('---')
+
+ sources = YAML.safe_load(sources)
+
+ ApplicationSetting.update_all(import_sources: sources.to_yaml)
+ end
+
+ def down; end
+end
diff --git a/db/migrate/20230426161259_add_user_foreign_key_to_merge_request_diff_llm_summary.rb b/db/migrate/20230426161259_add_user_foreign_key_to_merge_request_diff_llm_summary.rb
new file mode 100644
index 00000000000..d5692b4d956
--- /dev/null
+++ b/db/migrate/20230426161259_add_user_foreign_key_to_merge_request_diff_llm_summary.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddUserForeignKeyToMergeRequestDiffLlmSummary < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_request_diff_llm_summaries, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :merge_request_diff_llm_summaries, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230426161341_add_merge_request_diff_foreign_key_to_merge_request_diff_llm_summary.rb b/db/migrate/20230426161341_add_merge_request_diff_foreign_key_to_merge_request_diff_llm_summary.rb
new file mode 100644
index 00000000000..4271bd3c07c
--- /dev/null
+++ b/db/migrate/20230426161341_add_merge_request_diff_foreign_key_to_merge_request_diff_llm_summary.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddMergeRequestDiffForeignKeyToMergeRequestDiffLlmSummary < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_request_diff_llm_summaries, :merge_request_diffs, column: :merge_request_diff_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :merge_request_diff_llm_summaries, column: :merge_request_diff_id
+ end
+ end
+end
diff --git a/db/migrate/20230427065641_initialize_conversion_of_ci_pipeline_variables.rb b/db/migrate/20230427065641_initialize_conversion_of_ci_pipeline_variables.rb
new file mode 100644
index 00000000000..1c986dee3d2
--- /dev/null
+++ b/db/migrate/20230427065641_initialize_conversion_of_ci_pipeline_variables.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class InitializeConversionOfCiPipelineVariables < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE = :ci_pipeline_variables
+ COLUMNS = %i[id]
+
+ def up
+ initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+end
diff --git a/db/migrate/20230427094534_create_analytics_value_stream_dashboard_aggregations.rb b/db/migrate/20230427094534_create_analytics_value_stream_dashboard_aggregations.rb
new file mode 100644
index 00000000000..fd6528790ca
--- /dev/null
+++ b/db/migrate/20230427094534_create_analytics_value_stream_dashboard_aggregations.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateAnalyticsValueStreamDashboardAggregations < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :value_stream_dashboard_aggregations, id: false do |t|
+ t.references :namespace, primary_key: true, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.datetime_with_timezone :last_run_at
+ t.boolean :enabled, null: false, default: true
+
+ t.index [:last_run_at, :namespace_id], where: 'enabled IS TRUE',
+ name: 'index_on_value_stream_dashboard_aggregations_last_run_at_id'
+ end
+ end
+end
diff --git a/db/migrate/20230428101217_create_abuse_report_events.rb b/db/migrate/20230428101217_create_abuse_report_events.rb
new file mode 100644
index 00000000000..78395955eaf
--- /dev/null
+++ b/db/migrate/20230428101217_create_abuse_report_events.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateAbuseReportEvents < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :abuse_report_events do |t|
+ t.bigint :abuse_report_id, null: false, index: true
+ t.bigint :user_id, index: true
+ t.datetime_with_timezone :created_at, null: false
+ t.integer :action, limit: 2, null: false, default: 1
+ t.integer :reason, limit: 2
+ t.text :comment, limit: 1024
+ end
+ end
+end
diff --git a/db/migrate/20230428134334_delete_create_cross_project_pipeline_worker_job_instances.rb b/db/migrate/20230428134334_delete_create_cross_project_pipeline_worker_job_instances.rb
new file mode 100644
index 00000000000..517f85c0c1f
--- /dev/null
+++ b/db/migrate/20230428134334_delete_create_cross_project_pipeline_worker_job_instances.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class DeleteCreateCrossProjectPipelineWorkerJobInstances < Gitlab::Database::Migration[2.1]
+ DEPRECATED_JOB_CLASSES = %w[
+ CreateCrossProjectPipelineWorker
+ ]
+
+ disable_ddl_transaction!
+ def up
+ sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ end
+
+ def down
+ # This migration removes any instances of deprecated workers and cannot be undone.
+ end
+end
diff --git a/db/migrate/20230501111636_add_users_fk_to_abuse_report_events.rb b/db/migrate/20230501111636_add_users_fk_to_abuse_report_events.rb
new file mode 100644
index 00000000000..d721bc6bc7c
--- /dev/null
+++ b/db/migrate/20230501111636_add_users_fk_to_abuse_report_events.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddUsersFkToAbuseReportEvents < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :abuse_report_events,
+ :users,
+ column: :user_id,
+ on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :abuse_report_events, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230501163253_add_remember_me_enabled_to_application_settings.rb b/db/migrate/20230501163253_add_remember_me_enabled_to_application_settings.rb
new file mode 100644
index 00000000000..40c4ccd9f26
--- /dev/null
+++ b/db/migrate/20230501163253_add_remember_me_enabled_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddRememberMeEnabledToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :remember_me_enabled, :boolean, default: true, null: false
+ end
+end
diff --git a/db/migrate/20230502083003_add_abuse_reports_fk_to_abuse_report_events.rb b/db/migrate/20230502083003_add_abuse_reports_fk_to_abuse_report_events.rb
new file mode 100644
index 00000000000..3b71867f337
--- /dev/null
+++ b/db/migrate/20230502083003_add_abuse_reports_fk_to_abuse_report_events.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddAbuseReportsFkToAbuseReportEvents < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :abuse_report_events,
+ :abuse_reports,
+ column: :abuse_report_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :abuse_report_events, column: :abuse_report_id
+ end
+ end
+end
diff --git a/db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb b/db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb
new file mode 100644
index 00000000000..97a0541cdb5
--- /dev/null
+++ b/db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddVersionFormatAndDataTypeToCheckpoints < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ add_column(:pm_checkpoints, :data_type, :integer, limit: 2, default: 1, null: false)
+ add_column(:pm_checkpoints, :version_format, :integer, limit: 2, default: 1, null: false)
+ add_index(:pm_checkpoints, [:purl_type, :data_type, :version_format], unique: true, name: :pm_checkpoints_unique_index) # rubocop:disable Migration/AddIndex
+ swap_primary_key(:pm_checkpoints, :pm_checkpoints_pkey, :pm_checkpoints_unique_index)
+ end
+
+ def down
+ add_index(:pm_checkpoints, [:purl_type], unique: true, name: :pm_checkpoints_unique_index) # rubocop:disable Migration/AddIndex
+ unswap_primary_key(:pm_checkpoints, :pm_checkpoints_pkey, :pm_checkpoints_unique_index)
+ remove_column(:pm_checkpoints, :version_format)
+ remove_column(:pm_checkpoints, :data_type)
+ end
+end
diff --git a/db/migrate/20230503191056_add_text_limit_to_packages_npm_metadata_caches_object_storage_key.rb b/db/migrate/20230503191056_add_text_limit_to_packages_npm_metadata_caches_object_storage_key.rb
new file mode 100644
index 00000000000..b2759a30809
--- /dev/null
+++ b/db/migrate/20230503191056_add_text_limit_to_packages_npm_metadata_caches_object_storage_key.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToPackagesNpmMetadataCachesObjectStorageKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :packages_npm_metadata_caches, :object_storage_key, 255
+ end
+
+ def down
+ remove_text_limit :packages_npm_metadata_caches, :object_storage_key
+ end
+end
diff --git a/db/migrate/20230504084524_remove_gitlab_import_source.rb b/db/migrate/20230504084524_remove_gitlab_import_source.rb
new file mode 100644
index 00000000000..287b1cd3139
--- /dev/null
+++ b/db/migrate/20230504084524_remove_gitlab_import_source.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class RemoveGitlabImportSource < Gitlab::Database::Migration[2.1]
+ include Gitlab::Utils::StrongMemoize
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class ApplicationSetting < MigrationRecord
+ end
+
+ def up
+ return if import_sources.empty?
+
+ new_sources = import_sources - ['gitlab']
+
+ ApplicationSetting.update_all(import_sources: new_sources.to_yaml)
+ end
+
+ def down
+ ## a reversion is not needed as the Gitlab.com importer is no longer
+ # a supported import source. Attempting to save it as one will result
+ # in an ActiveRecord error.
+ end
+
+ def import_sources
+ ## the last ApplicationSetting record is used to determine application settings
+ import_sources = ApplicationSetting.last&.import_sources
+ import_sources.nil? ? [] : YAML.safe_load(import_sources)
+ end
+ strong_memoize_attr(:import_sources)
+end
diff --git a/db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb b/db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb
new file mode 100644
index 00000000000..aacb26643b9
--- /dev/null
+++ b/db/migrate/20230504112809_add_anthropic_api_key_application_setting.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddAnthropicApiKeyApplicationSetting < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :encrypted_anthropic_api_key, :binary
+ add_column :application_settings, :encrypted_anthropic_api_key_iv, :binary
+ end
+end
diff --git a/db/migrate/20230505122015_add_lock_version_to_milestones.rb b/db/migrate/20230505122015_add_lock_version_to_milestones.rb
new file mode 100644
index 00000000000..f8e34426c39
--- /dev/null
+++ b/db/migrate/20230505122015_add_lock_version_to_milestones.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddLockVersionToMilestones < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :milestones, :lock_version, :integer, null: false, default: 0
+ end
+end
diff --git a/db/migrate/20230507192028_create_audit_events_google_cloud_logging_configurations.rb b/db/migrate/20230507192028_create_audit_events_google_cloud_logging_configurations.rb
new file mode 100644
index 00000000000..1a32367382a
--- /dev/null
+++ b/db/migrate/20230507192028_create_audit_events_google_cloud_logging_configurations.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class CreateAuditEventsGoogleCloudLoggingConfigurations < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ UNIQUE_INDEX_NAME = "unique_google_cloud_logging_configurations_on_namespace_id"
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ def change
+ create_table :audit_events_google_cloud_logging_configurations do |t|
+ t.references :namespace, index: false, null: false, foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.text :google_project_id_name, null: false, limit: 30
+ t.text :client_email, null: false, limit: 254
+ t.text :log_id_name, default: "audit_events", limit: 511
+ t.binary :encrypted_private_key, null: false
+ t.binary :encrypted_private_key_iv, null: false
+
+ t.index [:namespace_id, :google_project_id_name, :log_id_name], unique: true, name: UNIQUE_INDEX_NAME
+ end
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230508074515_add_google_cloud_logging_configuration_limit_to_plan_limits.rb b/db/migrate/20230508074515_add_google_cloud_logging_configuration_limit_to_plan_limits.rb
new file mode 100644
index 00000000000..a3a54fb55ea
--- /dev/null
+++ b/db/migrate/20230508074515_add_google_cloud_logging_configuration_limit_to_plan_limits.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddGoogleCloudLoggingConfigurationLimitToPlanLimits < Gitlab::Database::Migration[2.1]
+ def change
+ add_column(:plan_limits, :google_cloud_logging_configurations, :integer, default: 5, null: false)
+ end
+end
diff --git a/db/migrate/20230509072635_drop_unused_sequence_by_recreating_vsa_table.rb b/db/migrate/20230509072635_drop_unused_sequence_by_recreating_vsa_table.rb
new file mode 100644
index 00000000000..d1abc9bbda7
--- /dev/null
+++ b/db/migrate/20230509072635_drop_unused_sequence_by_recreating_vsa_table.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class DropUnusedSequenceByRecreatingVsaTable < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ # dropping is OK since we re-add the table in the same transaction
+ drop_table :value_stream_dashboard_aggregations, if_exists: true # rubocop: disable Migration/DropTable
+ create_table :value_stream_dashboard_aggregations, id: false do |t|
+ # Note: default: nil will prevent SEQUENCE creation
+ t.references :namespace, primary_key: true, null: false, index: false, foreign_key: { on_delete: :cascade },
+ default: nil
+ t.datetime_with_timezone :last_run_at
+ t.boolean :enabled, null: false, default: true
+
+ t.index [:last_run_at, :namespace_id], where: 'enabled IS TRUE',
+ name: 'index_on_value_stream_dashboard_aggregations_last_run_at_id'
+ end
+ end
+
+ def down
+ # no-op, we don't want to restore the sequence
+ end
+end
diff --git a/db/migrate/20230509085428_change_organizations_sequence.rb b/db/migrate/20230509085428_change_organizations_sequence.rb
new file mode 100644
index 00000000000..59ec8c6e1ea
--- /dev/null
+++ b/db/migrate/20230509085428_change_organizations_sequence.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class ChangeOrganizationsSequence < Gitlab::Database::Migration[2.1]
+ def up
+ # Modify sequence for organizations.id so id '1' is never automatically taken
+ execute "ALTER SEQUENCE organizations_id_seq START WITH 1000 MINVALUE 1000 RESTART"
+ end
+
+ def down
+ execute "ALTER SEQUENCE organizations_id_seq START WITH 1 MINVALUE 1"
+ end
+end
diff --git a/db/migrate/20230509115525_add_name_to_organization.rb b/db/migrate/20230509115525_add_name_to_organization.rb
new file mode 100644
index 00000000000..d77fa84a70c
--- /dev/null
+++ b/db/migrate/20230509115525_add_name_to_organization.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+# rubocop:disable Migration/AddLimitToTextColumns, Migration/AddIndex
+# limit is added in 20230515111314_add_text_limit_on_organization_name.rb
+class AddNameToOrganization < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'unique_organizations_on_name_lower'
+
+ def up
+ add_column :organizations, :name, :text, null: false, default: ''
+
+ add_index :organizations, 'lower(name)', name: INDEX_NAME, unique: true
+ end
+
+ def down
+ remove_column :organizations, :name, if_exists: true
+ end
+end
+# rubocop:enable Migration/AddLimitToTextColumns, Migration/AddIndex
diff --git a/db/migrate/20230509131736_add_default_organization.rb b/db/migrate/20230509131736_add_default_organization.rb
new file mode 100644
index 00000000000..a63e7171f53
--- /dev/null
+++ b/db/migrate/20230509131736_add_default_organization.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddDefaultOrganization < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class Organization < MigrationRecord
+ end
+
+ def up
+ Organization.create(id: 1, name: 'Default')
+ end
+
+ def down
+ Organization.where(id: 1).delete_all
+ end
+end
diff --git a/db/migrate/20230509144234_delete_drop_older_deployments_worker_queues.rb b/db/migrate/20230509144234_delete_drop_older_deployments_worker_queues.rb
new file mode 100644
index 00000000000..b6e3046e446
--- /dev/null
+++ b/db/migrate/20230509144234_delete_drop_older_deployments_worker_queues.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class DeleteDropOlderDeploymentsWorkerQueues < Gitlab::Database::Migration[2.1]
+ DEPRECATED_JOB_CLASSES = %w[
+ Deployments::DropOlderDeploymentsWorker
+ ]
+
+ disable_ddl_transaction!
+ def up
+ sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ end
+
+ def down
+ # This migration removes any instances of deprecated workers and cannot be undone.
+ end
+end
diff --git a/db/migrate/20230515111314_add_text_limit_on_organization_name.rb b/db/migrate/20230515111314_add_text_limit_on_organization_name.rb
new file mode 100644
index 00000000000..c0b687fab94
--- /dev/null
+++ b/db/migrate/20230515111314_add_text_limit_on_organization_name.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitOnOrganizationName < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :organizations, :name, 255
+ end
+
+ def down
+ remove_text_limit :organizations, :name
+ end
+end