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
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/click_house/main/20230705124511_create_events.sql15
-rw-r--r--db/database_connections/ci.yaml5
-rw-r--r--db/database_connections/main.yaml2
-rw-r--r--db/docs/batched_background_migrations/backfill_missing_ci_cd_settings.yml6
-rw-r--r--db/docs/batched_background_migrations/backfill_uuid_conversion_column_in_vulnerability_occurrences.yml6
-rw-r--r--db/docs/deleted_tables/sbom_vulnerable_component_versions.yml (renamed from db/docs/sbom_vulnerable_component_versions.yml)2
-rw-r--r--db/docs/deleted_tables/u2f_registrations.yml (renamed from db/docs/u2f_registrations.yml)2
-rw-r--r--db/docs/deleted_tables/vulnerability_advisories.yml (renamed from db/docs/vulnerability_advisories.yml)2
-rw-r--r--db/docs/dependency_proxy_packages_settings.yml2
-rw-r--r--db/docs/external_pull_requests.yml2
-rw-r--r--db/docs/group_wiki_repository_states.yml10
-rw-r--r--db/docs/merge_request_review_llm_summaries.yml11
-rw-r--r--db/docs/ml_model_versions.yml10
-rw-r--r--db/docs/ml_models.yml10
-rw-r--r--db/docs/organization_settings.yml10
-rw-r--r--db/docs/organization_users.yml10
-rw-r--r--db/docs/organizations.yml2
-rw-r--r--db/docs/service_access_tokens.yml11
-rw-r--r--db/docs/subscription_user_add_on_assignments.yml10
-rw-r--r--db/docs/system_access_microsoft_applications.yml10
-rw-r--r--db/docs/system_access_microsoft_graph_access_tokens.yml10
-rw-r--r--db/docs/verification_codes.yml3
-rw-r--r--db/gitlab_schemas/gitlab_main_cell.yaml3
-rw-r--r--db/migrate/20230522162742_cleanup_bigint_conversion_for_merge_request_metrics_for_self_hosts.rb31
-rw-r--r--db/migrate/20230523101514_finalize_user_type_migration.rb15
-rw-r--r--db/migrate/20230605125735_add_tracking_columns_to_namespace_limits.rb8
-rw-r--r--db/migrate/20230607124754_create_organization_settings.rb13
-rw-r--r--db/migrate/20230608113106_create_organization_users.rb22
-rw-r--r--db/migrate/20230609065641_initialize_conversion_of_ci_pipeline_variables_pipeline_id.rb16
-rw-r--r--db/migrate/20230612074428_add_name_to_external_audit_event_destination.rb11
-rw-r--r--db/migrate/20230612091526_add_text_limit_to_external_audit_event_destination_name.rb13
-rw-r--r--db/migrate/20230612091747_add_name_to_instance_audit_event_destination.rb11
-rw-r--r--db/migrate/20230612091910_add_text_limit_to_instance_audit_event_destination_name.rb13
-rw-r--r--db/migrate/20230613122211_add_vulnerability_attributes_to_scan_result_policies.rb7
-rw-r--r--db/migrate/20230614180651_add_organization_id_to_namespaces.rb19
-rw-r--r--db/migrate/20230615074515_add_index_to_audit_event_external_destination.rb16
-rw-r--r--db/migrate/20230615074544_add_index_to_instance_audit_event_destination.rb15
-rw-r--r--db/migrate/20230615104902_add_user_id_foreign_key_to_organization_users.rb15
-rw-r--r--db/migrate/20230616164309_create_subscription_user_add_on_assignments.rb17
-rw-r--r--db/migrate/20230616164705_add_foreign_key_add_on_purchase_id_on_subscription_user_add_on_assignments.rb16
-rw-r--r--db/migrate/20230616164731_add_foreign_key_user_id_on_subscription_user_add_on_assignments.rb15
-rw-r--r--db/migrate/20230616200440_create_system_access_microsoft_application.rb19
-rw-r--r--db/migrate/20230616214220_create_system_access_microsoft_graph_access_tokens.rb15
-rw-r--r--db/migrate/20230620101808_change_default_value_for_distro_version.rb13
-rw-r--r--db/migrate/20230620104217_add_organization_id_foreign_key_to_organization_users.rb15
-rw-r--r--db/migrate/20230621065943_add_elasticsearch_requeue_workers_to_application_settings.rb7
-rw-r--r--db/migrate/20230621070810_update_requeue_workers_in_application_settings_for_gitlab_com.rb17
-rw-r--r--db/migrate/20230621072726_add_description_to_ci_variable.rb12
-rw-r--r--db/migrate/20230621074446_add_elasticsearch_number_of_shards_to_application_settings.rb9
-rw-r--r--db/migrate/20230621074611_update_elasticsearch_number_of_shards_in_application_settings_for_gitlab_com.rb19
-rw-r--r--db/migrate/20230621083004_add_description_to_ci_group_variable.rb12
-rw-r--r--db/migrate/20230622044119_create_merge_request_review_llm_summary.rb16
-rw-r--r--db/migrate/20230622051925_add_user_foreign_key_to_merge_request_review_llm_summary.rb15
-rw-r--r--db/migrate/20230622051943_add_review_foreign_key_to_merge_request_review_llm_summary.rb15
-rw-r--r--db/migrate/20230622052015_add_merge_request_diff_foreign_key_to_merge_request_review_llm_summary.rb17
-rw-r--r--db/migrate/20230622093921_remove_deprecated_metric_worker_instances.rb20
-rw-r--r--db/migrate/20230626065725_backfill_instance_audit_event_name.rb18
-rw-r--r--db/migrate/20230626065755_backfill_external_audit_event_name.rb15
-rw-r--r--db/migrate/20230626070959_add_not_null_to_external_audit_event.rb13
-rw-r--r--db/migrate/20230626071100_add_not_null_to_instance_audit_event.rb13
-rw-r--r--db/migrate/20230626113908_add_project_id_to_scan_result_policies.rb11
-rw-r--r--db/migrate/20230626113909_add_index_to_scan_result_policies_on_project_id.rb15
-rw-r--r--db/migrate/20230626113910_add_project_id_foreign_key_to_scan_result_policies.rb16
-rw-r--r--db/migrate/20230629071427_add_last_enforced_at_to_namespace_limits.rb7
-rw-r--r--db/migrate/20230629112833_create_fk_ml_candidates_on_user_id.rb29
-rw-r--r--db/migrate/20230629113029_validate_fk_ml_candidates_on_user_id.rb13
-rw-r--r--db/migrate/20230629113133_remove_old_fk_ml_candidates_on_user_id.rb21
-rw-r--r--db/migrate/20230630101337_add_previous_personal_access_token_to_personal_access_tokens.rb13
-rw-r--r--db/migrate/20230630101342_add_index_to_personal_access_tokens_on_previous_personal_access_token_id.rb15
-rw-r--r--db/migrate/20230630101347_add_fk_to_personal_access_tokens_on_previous_personal_access_token_id.rb19
-rw-r--r--db/migrate/20230630170515_add_state_to_catalog_resources.rb9
-rw-r--r--db/migrate/20230701195315_add_kubernetes_namespace_column_to_environments.rb17
-rw-r--r--db/migrate/20230703115902_add_relay_state_allowlist_application_settings.rb11
-rw-r--r--db/migrate/20230703121859_add_relay_state_allowlist_saml_providers.rb11
-rw-r--r--db/migrate/20230705085223_create_service_access_tokens.rb12
-rw-r--r--db/migrate/20230705092150_create_ml_models.rb19
-rw-r--r--db/migrate/20230705155000_add_group_mention_events_to_integrations.rb8
-rw-r--r--db/migrate/20230706130217_add_column_model_id_to_ml_experiments.rb14
-rw-r--r--db/migrate/20230706192435_remove_debian_process_changes_worker_job_instances.rb15
-rw-r--r--db/migrate/20230707090835_create_ml_model_versions.rb25
-rw-r--r--db/migrate/20230707094002_add_fk_on_ml_model_versions_to_ml_models.rb15
-rw-r--r--db/migrate/20230707094003_add_fk_on_ml_model_versions_to_packages.rb15
-rw-r--r--db/migrate/20230710160232_add_expires_at_to_service_access_tokens.rb11
-rw-r--r--db/migrate/20230710200434_add_emoji_events_to_web_hooks.rb9
-rw-r--r--db/migrate/20230712214613_add_read_dependency_to_member_roles.rb7
-rw-r--r--db/migrate/20230714195649_add_namespace_storage_forks_cost_factor_to_application_settings.rb22
-rw-r--r--db/migrate/20230717200940_create_group_wiki_repository_states.rb43
-rw-r--r--db/post_migrate/20230314094213_remove_foreign_keys_from_u2f_registrations_table.rb15
-rw-r--r--db/post_migrate/20230314094215_drop_u2f_registrations_table.rb23
-rw-r--r--db/post_migrate/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation.rb6
-rw-r--r--db/post_migrate/20230523101514_finalize_user_type_migration.rb22
-rw-r--r--db/post_migrate/20230528203340_drop_message_from_vulnerability_occurrences.rb17
-rw-r--r--db/post_migrate/20230530012406_finalize_backfill_resource_link_events.rb22
-rw-r--r--db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb15
-rw-r--r--db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb15
-rw-r--r--db/post_migrate/20230608145500_add_prepared_at_index_to_merge_requests.rb20
-rw-r--r--db/post_migrate/20230609065942_backfill_ci_pipeline_variables_for_pipeline_id_bigint_conversion.rb16
-rw-r--r--db/post_migrate/20230613192703_ensure_ci_build_needs_big_int_backfill_is_finished_for_self_hosts.rb24
-rw-r--r--db/post_migrate/20230613192802_swap_ci_build_needs_to_big_int_for_self_hosts.rb74
-rw-r--r--db/post_migrate/20230614181310_track_organization_deletions.rb17
-rw-r--r--db/post_migrate/20230614182049_add_index_to_namespaces_organization_id.rb19
-rw-r--r--db/post_migrate/20230615030402_remove_audit_events_group_index.rb40
-rw-r--r--db/post_migrate/20230615113748_replace_ci_job_artifacts_foreign_key_v3.rb20
-rw-r--r--db/post_migrate/20230615113840_replace_ci_running_builds_foreign_key_v3.rb20
-rw-r--r--db/post_migrate/20230615113858_replace_ci_job_variables_foreign_key_v3.rb20
-rw-r--r--db/post_migrate/20230615121103_replace_p_ci_builds_metadata_foreign_key_v3.rb37
-rw-r--r--db/post_migrate/20230615121122_replace_p_ci_runner_machine_builds_foreign_key_v3.rb37
-rw-r--r--db/post_migrate/20230615144627_remove_temporary_container_repository_indexes.rb82
-rw-r--r--db/post_migrate/20230616082958_add_unique_index_for_npm_packages_on_project_id_name_version.rb22
-rw-r--r--db/post_migrate/20230618020202_finish_user_type_migration.rb22
-rw-r--r--db/post_migrate/20230619005223_change_unconfirmed_created_at_index_on_users.rb24
-rw-r--r--db/post_migrate/20230619072744_schedule_index_events_on_project_id_and_id_desc_on_merged_action_for_removal.rb17
-rw-r--r--db/post_migrate/20230619081412_add_index_to_ci_triggers_token.rb15
-rw-r--r--db/post_migrate/20230619123701_schedule_removal_index_job_artifacts_id_and_expire_at.rb16
-rw-r--r--db/post_migrate/20230619134106_prepare_index_for_vulnerability_reads_on_common_project_filters.rb18
-rw-r--r--db/post_migrate/20230620072854_replace_old_fk_ci_build_pending_states_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072856_replace_old_fk_ci_build_trace_chunks_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072900_replace_old_fk_ci_unit_test_failures_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072905_replace_old_fk_ci_sources_pipelines_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072908_replace_old_fk_ci_resources_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072911_replace_old_fk_ci_build_report_results_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072915_replace_old_fk_ci_build_needs_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072917_replace_old_fk_ci_builds_runner_session_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072920_replace_old_fk_ci_pending_builds_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620072925_replace_old_fk_ci_build_trace_metadata_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230620105919_replace_old_fk_ci_job_artifacts_to_builds.rb45
-rw-r--r--db/post_migrate/20230620110004_replace_old_fk_ci_running_builds_to_builds.rb45
-rw-r--r--db/post_migrate/20230620110021_replace_old_fk_ci_job_variables_to_builds.rb45
-rw-r--r--db/post_migrate/20230620134708_validate_user_type_constraint.rb13
-rw-r--r--db/post_migrate/20230620201738_add_index_issues_on_project_health_status_asc_work_item_type.rb18
-rw-r--r--db/post_migrate/20230620201817_add_index_issues_on_project_health_status_desc_work_item_type.rb18
-rw-r--r--db/post_migrate/20230621072848_add_text_limit_to_ci_variable_description.rb16
-rw-r--r--db/post_migrate/20230621083052_add_text_limit_to_ci_group_variable_description.rb16
-rw-r--r--db/post_migrate/20230621102941_replace_old_fk_ci_job_artifacts_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230621103000_replace_old_fk_ci_running_builds_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230621103043_replace_old_fk_ci_job_variables_to_builds_v2.rb37
-rw-r--r--db/post_migrate/20230622052046_remove_ci_pipeline_variables_trigger_and_old_column.rb16
-rw-r--r--db/post_migrate/20230622073752_ensure_backfill_ci_pipelines_bigint_id_is_completed.rb23
-rw-r--r--db/post_migrate/20230623073906_prepare_async_index_for_ci_pipelines_bigint_id.rb15
-rw-r--r--db/post_migrate/20230626070723_drop_unused_sent_notification_columns.rb17
-rw-r--r--db/post_migrate/20230626072436_drop_tmp_index_job_artifacts_id_and_expire_at.rb28
-rw-r--r--db/post_migrate/20230626101519_create_index_for_vulnerability_reads_on_common_project_filters.rb18
-rw-r--r--db/post_migrate/20230626115046_add_temporary_index_on_vulnerability_reads.rb24
-rw-r--r--db/post_migrate/20230627115305_replace_p_ci_builds_metadata_foreign_key_v4.rb40
-rw-r--r--db/post_migrate/20230627140707_async_index_for_vulnerabilities_uuid_type_migration.rb25
-rw-r--r--db/post_migrate/20230627174139_add_index_to_pool_repositories.rb21
-rw-r--r--db/post_migrate/20230628023103_queue_backfill_missing_ci_cd_settings.rb25
-rw-r--r--db/post_migrate/20230629011859_cleanup_bigint_conversion_for_notes_for_gitlab_com.rb28
-rw-r--r--db/post_migrate/20230629024032_ensure_events_bigint_backfill_is_finished_for_gitlab_dot_com.rb29
-rw-r--r--db/post_migrate/20230629024403_events_bigint_create_indexe_async_for_gitlab_dot_com.rb28
-rw-r--r--db/post_migrate/20230629095819_queue_backfill_uuid_conversion_column_in_vulnerability_occurrences.rb25
-rw-r--r--db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb15
-rw-r--r--db/post_migrate/20230703122803_create_vulnerability_uuid_type_migration_index.rb11
-rw-r--r--db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb17
-rw-r--r--db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb16
-rw-r--r--db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb16
-rw-r--r--db/post_migrate/20230704062132_replace_p_ci_builds_metadata_foreign_key_v5.rb26
-rw-r--r--db/post_migrate/20230704062136_replace_p_ci_runner_machine_builds_foreign_key_v4.rb26
-rw-r--r--db/post_migrate/20230704074120_replace_old_fk_p_ci_builds_metadata_to_builds.rb54
-rw-r--r--db/post_migrate/20230704074124_replace_old_fk_p_ci_runner_machine_builds_to_builds.rb54
-rw-r--r--db/post_migrate/20230705115215_remove_user_details_provisioned_by_group_at_column.rb9
-rw-r--r--db/post_migrate/20230705141703_rollback_vulnerability_advisories_foreign_key_on_vulnerable_component_versions.rb17
-rw-r--r--db/post_migrate/20230705141733_rollback_component_version_foreign_key_on_vulnerable_component_versions.rb17
-rw-r--r--db/post_migrate/20230705142241_drop_vulnerable_component_versions.rb22
-rw-r--r--db/post_migrate/20230705142334_drop_vulnerabilities_advisories.rb29
-rw-r--r--db/post_migrate/20230705145827_drop_wrong_index_on_vulnerability_occurrences.rb22
-rw-r--r--db/post_migrate/20230705150100_recreate_type_migration_index_on_vulnerability_occurrences.rb24
-rw-r--r--db/post_migrate/20230706011541_add_user_id_foreign_key_to_ml_experiments.rb31
-rw-r--r--db/post_migrate/20230706073937_remove_index_events_on_project_id_and_id_desc_on_merged_action.rb17
-rw-r--r--db/post_migrate/20230706080234_add_trigger_on_organizations.rb29
-rw-r--r--db/post_migrate/20230707114012_change_project_view_default.rb9
-rw-r--r--db/post_migrate/20230707211358_deduplicate_inactive_alert_integrations.rb40
-rw-r--r--db/post_migrate/20230707211359_change_alert_integrations_unique_index.rb33
-rw-r--r--db/post_migrate/20230707220646_add_index_to_vulnerability_findings_on_uuid_again.rb16
-rw-r--r--db/post_migrate/20230711093010_drop_default_partition_id_value_for_ci_tables.rb39
-rw-r--r--db/post_migrate/20230712020407_remove_temporary_index_from_system_note_metadata.rb18
-rw-r--r--db/post_migrate/20230712064637_replace_old_fk_p_ci_builds_metadata_to_builds_v2.rb54
-rw-r--r--db/post_migrate/20230712064655_replace_old_fk_p_ci_runner_machine_builds_to_builds_v2.rb54
-rw-r--r--db/post_migrate/20230712145323_drop_ci_job_artifacts_partition_id_default.rb24
-rw-r--r--db/post_migrate/20230712145821_drop_ci_stages_partition_id_default.rb24
-rw-r--r--db/post_migrate/20230712145926_drop_ci_build_trace_metadata_partition_id_default.rb24
-rw-r--r--db/post_migrate/20230713020247_change_pm_advisories_urls_constraint.rb17
-rw-r--r--db/post_migrate/20230713100100_drop_ci_pipeline_variable_partition_id_default.rb24
-rw-r--r--db/schema_migrations/202303140942131
-rw-r--r--db/schema_migrations/202303140942151
-rw-r--r--db/schema_migrations/202305221627421
-rw-r--r--db/schema_migrations/202305282033401
-rw-r--r--db/schema_migrations/202305300124061
-rw-r--r--db/schema_migrations/202306012116351
-rw-r--r--db/schema_migrations/202306012137501
-rw-r--r--db/schema_migrations/202306051257351
-rw-r--r--db/schema_migrations/202306071247541
-rw-r--r--db/schema_migrations/202306081131061
-rw-r--r--db/schema_migrations/202306081455001
-rw-r--r--db/schema_migrations/202306090656411
-rw-r--r--db/schema_migrations/202306090659421
-rw-r--r--db/schema_migrations/202306120744281
-rw-r--r--db/schema_migrations/202306120915261
-rw-r--r--db/schema_migrations/202306120917471
-rw-r--r--db/schema_migrations/202306120919101
-rw-r--r--db/schema_migrations/202306131222111
-rw-r--r--db/schema_migrations/202306131927031
-rw-r--r--db/schema_migrations/202306131928021
-rw-r--r--db/schema_migrations/202306141806511
-rw-r--r--db/schema_migrations/202306141813101
-rw-r--r--db/schema_migrations/202306141820491
-rw-r--r--db/schema_migrations/202306150304021
-rw-r--r--db/schema_migrations/202306150745151
-rw-r--r--db/schema_migrations/202306150745441
-rw-r--r--db/schema_migrations/202306151049021
-rw-r--r--db/schema_migrations/202306151137481
-rw-r--r--db/schema_migrations/202306151138401
-rw-r--r--db/schema_migrations/202306151138581
-rw-r--r--db/schema_migrations/202306151211031
-rw-r--r--db/schema_migrations/202306151211221
-rw-r--r--db/schema_migrations/202306151446271
-rw-r--r--db/schema_migrations/202306160829581
-rw-r--r--db/schema_migrations/202306161643091
-rw-r--r--db/schema_migrations/202306161647051
-rw-r--r--db/schema_migrations/202306161647311
-rw-r--r--db/schema_migrations/202306162004401
-rw-r--r--db/schema_migrations/202306162142201
-rw-r--r--db/schema_migrations/202306180202021
-rw-r--r--db/schema_migrations/202306190052231
-rw-r--r--db/schema_migrations/202306190727441
-rw-r--r--db/schema_migrations/202306190814121
-rw-r--r--db/schema_migrations/202306191237011
-rw-r--r--db/schema_migrations/202306191341061
-rw-r--r--db/schema_migrations/202306200728541
-rw-r--r--db/schema_migrations/202306200728561
-rw-r--r--db/schema_migrations/202306200729001
-rw-r--r--db/schema_migrations/202306200729051
-rw-r--r--db/schema_migrations/202306200729081
-rw-r--r--db/schema_migrations/202306200729111
-rw-r--r--db/schema_migrations/202306200729151
-rw-r--r--db/schema_migrations/202306200729171
-rw-r--r--db/schema_migrations/202306200729201
-rw-r--r--db/schema_migrations/202306200729251
-rw-r--r--db/schema_migrations/202306201018081
-rw-r--r--db/schema_migrations/202306201042171
-rw-r--r--db/schema_migrations/202306201059191
-rw-r--r--db/schema_migrations/202306201100041
-rw-r--r--db/schema_migrations/202306201100211
-rw-r--r--db/schema_migrations/202306201347081
-rw-r--r--db/schema_migrations/202306202017381
-rw-r--r--db/schema_migrations/202306202018171
-rw-r--r--db/schema_migrations/202306210659431
-rw-r--r--db/schema_migrations/202306210708101
-rw-r--r--db/schema_migrations/202306210727261
-rw-r--r--db/schema_migrations/202306210728481
-rw-r--r--db/schema_migrations/202306210744461
-rw-r--r--db/schema_migrations/202306210746111
-rw-r--r--db/schema_migrations/202306210830041
-rw-r--r--db/schema_migrations/202306210830521
-rw-r--r--db/schema_migrations/202306211029411
-rw-r--r--db/schema_migrations/202306211030001
-rw-r--r--db/schema_migrations/202306211030431
-rw-r--r--db/schema_migrations/202306220441191
-rw-r--r--db/schema_migrations/202306220519251
-rw-r--r--db/schema_migrations/202306220519431
-rw-r--r--db/schema_migrations/202306220520151
-rw-r--r--db/schema_migrations/202306220520461
-rw-r--r--db/schema_migrations/202306220737521
-rw-r--r--db/schema_migrations/202306220939211
-rw-r--r--db/schema_migrations/202306230739061
-rw-r--r--db/schema_migrations/202306260657251
-rw-r--r--db/schema_migrations/202306260657551
-rw-r--r--db/schema_migrations/202306260707231
-rw-r--r--db/schema_migrations/202306260709591
-rw-r--r--db/schema_migrations/202306260711001
-rw-r--r--db/schema_migrations/202306260724361
-rw-r--r--db/schema_migrations/202306261015191
-rw-r--r--db/schema_migrations/202306261139081
-rw-r--r--db/schema_migrations/202306261139091
-rw-r--r--db/schema_migrations/202306261139101
-rw-r--r--db/schema_migrations/202306261150461
-rw-r--r--db/schema_migrations/202306271153051
-rw-r--r--db/schema_migrations/202306271407071
-rw-r--r--db/schema_migrations/202306271741391
-rw-r--r--db/schema_migrations/202306280231031
-rw-r--r--db/schema_migrations/202306290118591
-rw-r--r--db/schema_migrations/202306290240321
-rw-r--r--db/schema_migrations/202306290244031
-rw-r--r--db/schema_migrations/202306290714271
-rw-r--r--db/schema_migrations/202306290958191
-rw-r--r--db/schema_migrations/202306291128331
-rw-r--r--db/schema_migrations/202306291130291
-rw-r--r--db/schema_migrations/202306291131331
-rw-r--r--db/schema_migrations/202306301013371
-rw-r--r--db/schema_migrations/202306301013421
-rw-r--r--db/schema_migrations/202306301013471
-rw-r--r--db/schema_migrations/202306301705151
-rw-r--r--db/schema_migrations/202307011953151
-rw-r--r--db/schema_migrations/202307030240311
-rw-r--r--db/schema_migrations/202307031159021
-rw-r--r--db/schema_migrations/202307031218591
-rw-r--r--db/schema_migrations/202307031228031
-rw-r--r--db/schema_migrations/202307040423021
-rw-r--r--db/schema_migrations/202307040445411
-rw-r--r--db/schema_migrations/202307040507391
-rw-r--r--db/schema_migrations/202307040621321
-rw-r--r--db/schema_migrations/202307040621361
-rw-r--r--db/schema_migrations/202307040741201
-rw-r--r--db/schema_migrations/202307040741241
-rw-r--r--db/schema_migrations/202307050852231
-rw-r--r--db/schema_migrations/202307050921501
-rw-r--r--db/schema_migrations/202307051152151
-rw-r--r--db/schema_migrations/202307051417031
-rw-r--r--db/schema_migrations/202307051417331
-rw-r--r--db/schema_migrations/202307051422411
-rw-r--r--db/schema_migrations/202307051423341
-rw-r--r--db/schema_migrations/202307051458271
-rw-r--r--db/schema_migrations/202307051501001
-rw-r--r--db/schema_migrations/202307051550001
-rw-r--r--db/schema_migrations/202307060115411
-rw-r--r--db/schema_migrations/202307060739371
-rw-r--r--db/schema_migrations/202307060802341
-rw-r--r--db/schema_migrations/202307061302171
-rw-r--r--db/schema_migrations/202307061924351
-rw-r--r--db/schema_migrations/202307070908351
-rw-r--r--db/schema_migrations/202307070940021
-rw-r--r--db/schema_migrations/202307070940031
-rw-r--r--db/schema_migrations/202307071140121
-rw-r--r--db/schema_migrations/202307072113581
-rw-r--r--db/schema_migrations/202307072113591
-rw-r--r--db/schema_migrations/202307072206461
-rw-r--r--db/schema_migrations/202307101602321
-rw-r--r--db/schema_migrations/202307102004341
-rw-r--r--db/schema_migrations/202307110930101
-rw-r--r--db/schema_migrations/202307120204071
-rw-r--r--db/schema_migrations/202307120646371
-rw-r--r--db/schema_migrations/202307120646551
-rw-r--r--db/schema_migrations/202307121453231
-rw-r--r--db/schema_migrations/202307121458211
-rw-r--r--db/schema_migrations/202307121459261
-rw-r--r--db/schema_migrations/202307122146131
-rw-r--r--db/schema_migrations/202307130202471
-rw-r--r--db/schema_migrations/202307131001001
-rw-r--r--db/schema_migrations/202307141956491
-rw-r--r--db/schema_migrations/202307172009401
-rw-r--r--db/structure.sql676
341 files changed, 4303 insertions, 241 deletions
diff --git a/db/click_house/main/20230705124511_create_events.sql b/db/click_house/main/20230705124511_create_events.sql
new file mode 100644
index 00000000000..45e0139165a
--- /dev/null
+++ b/db/click_house/main/20230705124511_create_events.sql
@@ -0,0 +1,15 @@
+CREATE TABLE events
+(
+ id UInt64 DEFAULT 0,
+ path String DEFAULT '',
+ author_id UInt64 DEFAULT 0,
+ target_id UInt64 DEFAULT 0,
+ target_type LowCardinality(String) DEFAULT '',
+ action UInt8 DEFAULT 0,
+ created_at DateTime64(6, 'UTC') DEFAULT now(),
+ updated_at DateTime64(6, 'UTC') DEFAULT now()
+)
+ENGINE = ReplacingMergeTree(updated_at)
+PRIMARY KEY (id)
+ORDER BY (id)
+PARTITION BY toYear(created_at)
diff --git a/db/database_connections/ci.yaml b/db/database_connections/ci.yaml
index daa155dcb00..5331765214e 100644
--- a/db/database_connections/ci.yaml
+++ b/db/database_connections/ci.yaml
@@ -4,6 +4,11 @@ gitlab_schemas:
- gitlab_internal
- gitlab_shared
- gitlab_ci
+lock_gitlab_schemas:
+ - gitlab_main
+ - gitlab_main_clusterwide
+ - gitlab_main_cell
+ - gitlab_pm
klass: Ci::ApplicationRecord
# if CI database is not configured, use this database
fallback_database: main
diff --git a/db/database_connections/main.yaml b/db/database_connections/main.yaml
index dfdd50eb085..9eadd26ec26 100644
--- a/db/database_connections/main.yaml
+++ b/db/database_connections/main.yaml
@@ -6,6 +6,8 @@ gitlab_schemas:
- gitlab_main
- gitlab_main_cell
- gitlab_pm
+lock_gitlab_schemas:
+ - gitlab_ci
# Note that we use ActiveRecord::Base here and not ApplicationRecord.
# This is deliberate, as:
# - the load balancer must be enabled for _all_ models
diff --git a/db/docs/batched_background_migrations/backfill_missing_ci_cd_settings.yml b/db/docs/batched_background_migrations/backfill_missing_ci_cd_settings.yml
new file mode 100644
index 00000000000..aa6ba2684af
--- /dev/null
+++ b/db/docs/batched_background_migrations/backfill_missing_ci_cd_settings.yml
@@ -0,0 +1,6 @@
+---
+migration_job_name: BackfillMissingCiCdSettings
+description: Backfills ci_cd_settings for projects that do not have them
+feature_category: source_code_management
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/393502
+milestone: 16.2
diff --git a/db/docs/batched_background_migrations/backfill_uuid_conversion_column_in_vulnerability_occurrences.yml b/db/docs/batched_background_migrations/backfill_uuid_conversion_column_in_vulnerability_occurrences.yml
new file mode 100644
index 00000000000..43171193f28
--- /dev/null
+++ b/db/docs/batched_background_migrations/backfill_uuid_conversion_column_in_vulnerability_occurrences.yml
@@ -0,0 +1,6 @@
+---
+migration_job_name: BackfillUuidConversionColumnInVulnerabilityOccurrences
+description: backfill values for `uuid_convert_string_to_uuid` column in vulnerability_occurrences table
+feature_category: vulnerability_management
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124986
+milestone: 16.2
diff --git a/db/docs/sbom_vulnerable_component_versions.yml b/db/docs/deleted_tables/sbom_vulnerable_component_versions.yml
index 8747b6c6588..7642cb5ea53 100644
--- a/db/docs/sbom_vulnerable_component_versions.yml
+++ b/db/docs/deleted_tables/sbom_vulnerable_component_versions.yml
@@ -7,4 +7,6 @@ feature_categories:
description: Stores information about vulnerable SBoM components
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95622
milestone: '15.4'
+removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125426
+removed_in_milestone: '16.2'
gitlab_schema: gitlab_main
diff --git a/db/docs/u2f_registrations.yml b/db/docs/deleted_tables/u2f_registrations.yml
index b1aaa8148bd..a41f0f092b7 100644
--- a/db/docs/u2f_registrations.yml
+++ b/db/docs/deleted_tables/u2f_registrations.yml
@@ -7,4 +7,6 @@ feature_categories:
description: TODO
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/791cc9138be6ea1783e3c3853370cf0290f4d41e
milestone: '8.9'
+removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/114576
+removed_in_milestone: '16.1'
gitlab_schema: gitlab_main
diff --git a/db/docs/vulnerability_advisories.yml b/db/docs/deleted_tables/vulnerability_advisories.yml
index 6ce7f30aa7c..613ab678f35 100644
--- a/db/docs/vulnerability_advisories.yml
+++ b/db/docs/deleted_tables/vulnerability_advisories.yml
@@ -8,4 +8,6 @@ feature_categories:
description: Stores vulnerability advisories
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95622
milestone: '15.4'
+removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125426
+removed_in_milestone: '16.2'
gitlab_schema: gitlab_main
diff --git a/db/docs/dependency_proxy_packages_settings.yml b/db/docs/dependency_proxy_packages_settings.yml
index dcb43553f81..b506848e899 100644
--- a/db/docs/dependency_proxy_packages_settings.yml
+++ b/db/docs/dependency_proxy_packages_settings.yml
@@ -3,7 +3,7 @@ table_name: dependency_proxy_packages_settings
classes:
- DependencyProxy::Packages::Setting
feature_categories:
-- dependency_proxy
+- package_registry
description: Settings for the dependency proxy for packages.
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/120894
milestone: '16.1'
diff --git a/db/docs/external_pull_requests.yml b/db/docs/external_pull_requests.yml
index e3777ae67ba..d0e6bf15eb5 100644
--- a/db/docs/external_pull_requests.yml
+++ b/db/docs/external_pull_requests.yml
@@ -1,7 +1,7 @@
---
table_name: external_pull_requests
classes:
-- ExternalPullRequest
+- Ci::ExternalPullRequest
feature_categories:
- continuous_integration
description: TODO
diff --git a/db/docs/group_wiki_repository_states.yml b/db/docs/group_wiki_repository_states.yml
new file mode 100644
index 00000000000..574224173c9
--- /dev/null
+++ b/db/docs/group_wiki_repository_states.yml
@@ -0,0 +1,10 @@
+---
+table_name: group_wiki_repository_states
+description: Separate table for group wiki verification states
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/126753
+milestone: '16.3'
+feature_categories:
+- geo_replication
+classes:
+- Geo::GroupWikiRepositoryState
+gitlab_schema: gitlab_main
diff --git a/db/docs/merge_request_review_llm_summaries.yml b/db/docs/merge_request_review_llm_summaries.yml
new file mode 100644
index 00000000000..ca8f67cc27b
--- /dev/null
+++ b/db/docs/merge_request_review_llm_summaries.yml
@@ -0,0 +1,11 @@
+---
+table_name: merge_request_review_llm_summaries
+classes:
+- MergeRequest::ReviewLlmSummary
+feature_categories:
+- code_review_workflow
+description: This is the table that stores information about the review summaries
+ produced from different LLM's.
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124402
+milestone: '16.2'
+gitlab_schema: gitlab_main
diff --git a/db/docs/ml_model_versions.yml b/db/docs/ml_model_versions.yml
new file mode 100644
index 00000000000..9e86c9d0bdc
--- /dev/null
+++ b/db/docs/ml_model_versions.yml
@@ -0,0 +1,10 @@
+---
+table_name: ml_model_versions
+classes:
+ - Ml::ModelVersion
+feature_categories:
+ - mlops
+description: A version of a machine learning model for the model registry
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125729
+milestone: '16.2'
+gitlab_schema: gitlab_main
diff --git a/db/docs/ml_models.yml b/db/docs/ml_models.yml
new file mode 100644
index 00000000000..112a1f9263c
--- /dev/null
+++ b/db/docs/ml_models.yml
@@ -0,0 +1,10 @@
+---
+table_name: ml_models
+classes:
+ - Ml::Model
+feature_categories:
+ - mlops
+description: A machine learning model for the model registry
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125302
+milestone: '16.2'
+gitlab_schema: gitlab_main
diff --git a/db/docs/organization_settings.yml b/db/docs/organization_settings.yml
new file mode 100644
index 00000000000..669aafc9ed7
--- /dev/null
+++ b/db/docs/organization_settings.yml
@@ -0,0 +1,10 @@
+---
+table_name: organization_settings
+classes:
+- Organizations::OrganizationSetting
+feature_categories:
+- cell
+description: Settings related to Organizations
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123380
+milestone: '16.2'
+gitlab_schema: gitlab_main
diff --git a/db/docs/organization_users.yml b/db/docs/organization_users.yml
new file mode 100644
index 00000000000..6a1ccb7210b
--- /dev/null
+++ b/db/docs/organization_users.yml
@@ -0,0 +1,10 @@
+---
+table_name: organization_users
+classes:
+- Organizations::OrganizationUser
+feature_categories:
+- cell
+description: User who has joined an organization
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123804
+milestone: '16.2'
+gitlab_schema: gitlab_main_clusterwide
diff --git a/db/docs/organizations.yml b/db/docs/organizations.yml
index ebc7e8b68d1..c0e4697fb37 100644
--- a/db/docs/organizations.yml
+++ b/db/docs/organizations.yml
@@ -7,4 +7,4 @@ feature_categories:
description: Define ownership of namespaces, projects, and users by organizations
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119421
milestone: '16.0'
-gitlab_schema: gitlab_main
+gitlab_schema: gitlab_main_clusterwide
diff --git a/db/docs/service_access_tokens.yml b/db/docs/service_access_tokens.yml
new file mode 100644
index 00000000000..2acd0d33c7d
--- /dev/null
+++ b/db/docs/service_access_tokens.yml
@@ -0,0 +1,11 @@
+---
+table_name: service_access_tokens
+classes:
+- Ai::ServiceAccessToken
+feature_categories:
+- application_performance
+description: Persists JWT tokens for AI features (e.g. Code Suggestions) to authenticate
+ the GitLab instance
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125383
+milestone: '16.2'
+gitlab_schema: gitlab_main
diff --git a/db/docs/subscription_user_add_on_assignments.yml b/db/docs/subscription_user_add_on_assignments.yml
new file mode 100644
index 00000000000..acd9b821115
--- /dev/null
+++ b/db/docs/subscription_user_add_on_assignments.yml
@@ -0,0 +1,10 @@
+---
+table_name: subscription_user_add_on_assignments
+description: Tracks the assignment of an add-on to a user within a namespace
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123967
+milestone: '16.2'
+feature_categories:
+- seat_cost_management
+classes:
+- GitlabSubscriptions::UserAddOnAssignment
+gitlab_schema: gitlab_main
diff --git a/db/docs/system_access_microsoft_applications.yml b/db/docs/system_access_microsoft_applications.yml
new file mode 100644
index 00000000000..e168c9f41e4
--- /dev/null
+++ b/db/docs/system_access_microsoft_applications.yml
@@ -0,0 +1,10 @@
+---
+table_name: system_access_microsoft_applications
+classes:
+ - SystemAccess::MicrosoftApplication
+feature_categories:
+ - system_access
+description: Integration with Microsoft Azure application
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124101
+milestone: '16.2'
+gitlab_schema: gitlab_main
diff --git a/db/docs/system_access_microsoft_graph_access_tokens.yml b/db/docs/system_access_microsoft_graph_access_tokens.yml
new file mode 100644
index 00000000000..a8a81a836ba
--- /dev/null
+++ b/db/docs/system_access_microsoft_graph_access_tokens.yml
@@ -0,0 +1,10 @@
+---
+table_name: system_access_microsoft_graph_access_tokens
+classes:
+ - SystemAccess::MicrosoftGraphAccessToken
+feature_categories:
+ - system_access
+description: Access tokens for the Microsoft Graph API
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124101
+milestone: '16.2'
+gitlab_schema: gitlab_main
diff --git a/db/docs/verification_codes.yml b/db/docs/verification_codes.yml
index b34818070b1..9d0e3f53830 100644
--- a/db/docs/verification_codes.yml
+++ b/db/docs/verification_codes.yml
@@ -1,7 +1,6 @@
---
table_name: verification_codes
-classes:
--
+classes: []
feature_categories:
- jihu
description: Used by the JiHu edition for user verification
diff --git a/db/gitlab_schemas/gitlab_main_cell.yaml b/db/gitlab_schemas/gitlab_main_cell.yaml
index 0f85cfdf5d3..7bc140ffecb 100644
--- a/db/gitlab_schemas/gitlab_main_cell.yaml
+++ b/db/gitlab_schemas/gitlab_main_cell.yaml
@@ -3,9 +3,6 @@ description: Schema for all Cell-local tables, ex. namespaces, projects, etc.
allow_cross_joins:
- gitlab_shared
- gitlab_main
- # Temporarily allow cross-joins between clusterwide and cell schemas
- # This is to be removed once we annotate all cross-joins between those
- - gitlab_main_clusterwide
allow_cross_transactions:
- gitlab_internal
- gitlab_shared
diff --git a/db/migrate/20230522162742_cleanup_bigint_conversion_for_merge_request_metrics_for_self_hosts.rb b/db/migrate/20230522162742_cleanup_bigint_conversion_for_merge_request_metrics_for_self_hosts.rb
new file mode 100644
index 00000000000..5e56f8486f1
--- /dev/null
+++ b/db/migrate/20230522162742_cleanup_bigint_conversion_for_merge_request_metrics_for_self_hosts.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class CleanupBigintConversionForMergeRequestMetricsForSelfHosts < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ enable_lock_retries!
+
+ TABLE = :merge_request_metrics
+
+ def up
+ return if should_skip?
+ return unless column_exists?(TABLE, :id_convert_to_bigint)
+
+ # rubocop:disable Migration/WithLockRetriesDisallowedMethod
+ with_lock_retries do
+ cleanup_conversion_of_integer_to_bigint(TABLE, :id)
+ end
+ # rubocop:enable Migration/WithLockRetriesDisallowedMethod
+ end
+
+ def down
+ return if should_skip?
+ return if column_exists?(TABLE, :id_convert_to_bigint)
+
+ restore_conversion_of_integer_to_bigint(TABLE, :id)
+ end
+
+ def should_skip?
+ com_or_dev_or_test_but_not_jh?
+ end
+end
diff --git a/db/migrate/20230523101514_finalize_user_type_migration.rb b/db/migrate/20230523101514_finalize_user_type_migration.rb
deleted file mode 100644
index f8ae4c7bb2c..00000000000
--- a/db/migrate/20230523101514_finalize_user_type_migration.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-class FinalizeUserTypeMigration < Gitlab::Database::Migration[2.1]
- MIGRATION = 'MigrateHumanUserType'
-
- disable_ddl_transaction!
-
- def up
- finalize_background_migration(MIGRATION)
- end
-
- def down
- # no-op
- end
-end
diff --git a/db/migrate/20230605125735_add_tracking_columns_to_namespace_limits.rb b/db/migrate/20230605125735_add_tracking_columns_to_namespace_limits.rb
new file mode 100644
index 00000000000..68f75ddf767
--- /dev/null
+++ b/db/migrate/20230605125735_add_tracking_columns_to_namespace_limits.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddTrackingColumnsToNamespaceLimits < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :namespace_limits, :pre_enforcement_notification_at, :datetime_with_timezone
+ add_column :namespace_limits, :first_enforced_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20230607124754_create_organization_settings.rb b/db/migrate/20230607124754_create_organization_settings.rb
new file mode 100644
index 00000000000..15d3fa3159f
--- /dev/null
+++ b/db/migrate/20230607124754_create_organization_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CreateOrganizationSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :organization_settings, id: false do |t|
+ t.references :organization, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.jsonb :settings, default: {}, null: false
+ end
+ end
+end
diff --git a/db/migrate/20230608113106_create_organization_users.rb b/db/migrate/20230608113106_create_organization_users.rb
new file mode 100644
index 00000000000..305765bc9df
--- /dev/null
+++ b/db/migrate/20230608113106_create_organization_users.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateOrganizationUsers < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ create_table :organization_users do |t|
+ t.bigint :organization_id,
+ null: false
+ t.bigint :user_id,
+ null: false,
+ index: true
+ t.timestamps_with_timezone null: false
+ t.index 'organization_id, user_id',
+ name: 'index_organization_users_on_organization_id_and_user_id', unique: true
+ end
+ end
+
+ def down
+ drop_table :organization_users
+ end
+end
diff --git a/db/migrate/20230609065641_initialize_conversion_of_ci_pipeline_variables_pipeline_id.rb b/db/migrate/20230609065641_initialize_conversion_of_ci_pipeline_variables_pipeline_id.rb
new file mode 100644
index 00000000000..09dfda68851
--- /dev/null
+++ b/db/migrate/20230609065641_initialize_conversion_of_ci_pipeline_variables_pipeline_id.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class InitializeConversionOfCiPipelineVariablesPipelineId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE = :ci_pipeline_variables
+ COLUMNS = %i[pipeline_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/20230612074428_add_name_to_external_audit_event_destination.rb b/db/migrate/20230612074428_add_name_to_external_audit_event_destination.rb
new file mode 100644
index 00000000000..4fe61c4caad
--- /dev/null
+++ b/db/migrate/20230612074428_add_name_to_external_audit_event_destination.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddNameToExternalAuditEventDestination < Gitlab::Database::Migration[2.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # text limit is added in a 20230612091526_add_text_limit_to_external_audit_event_destination_name.rb migration
+ def change
+ add_column :audit_events_external_audit_event_destinations, :name, :text
+ end
+
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230612091526_add_text_limit_to_external_audit_event_destination_name.rb b/db/migrate/20230612091526_add_text_limit_to_external_audit_event_destination_name.rb
new file mode 100644
index 00000000000..d469c7cc964
--- /dev/null
+++ b/db/migrate/20230612091526_add_text_limit_to_external_audit_event_destination_name.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToExternalAuditEventDestinationName < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :audit_events_external_audit_event_destinations, :name, 72
+ end
+
+ def down
+ remove_text_limit :audit_events_external_audit_event_destinations, :name
+ end
+end
diff --git a/db/migrate/20230612091747_add_name_to_instance_audit_event_destination.rb b/db/migrate/20230612091747_add_name_to_instance_audit_event_destination.rb
new file mode 100644
index 00000000000..7a99654bd66
--- /dev/null
+++ b/db/migrate/20230612091747_add_name_to_instance_audit_event_destination.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddNameToInstanceAuditEventDestination < Gitlab::Database::Migration[2.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # text limit is added in a 20230612091910_add_text_limit_to_instance_audit_event_destination_name.rb migration
+ def change
+ add_column :audit_events_instance_external_audit_event_destinations, :name, :text
+ end
+
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230612091910_add_text_limit_to_instance_audit_event_destination_name.rb b/db/migrate/20230612091910_add_text_limit_to_instance_audit_event_destination_name.rb
new file mode 100644
index 00000000000..0bdfd4baff7
--- /dev/null
+++ b/db/migrate/20230612091910_add_text_limit_to_instance_audit_event_destination_name.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToInstanceAuditEventDestinationName < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :audit_events_instance_external_audit_event_destinations, :name, 72
+ end
+
+ def down
+ remove_text_limit :audit_events_instance_external_audit_event_destinations, :name
+ end
+end
diff --git a/db/migrate/20230613122211_add_vulnerability_attributes_to_scan_result_policies.rb b/db/migrate/20230613122211_add_vulnerability_attributes_to_scan_result_policies.rb
new file mode 100644
index 00000000000..c3467efe4af
--- /dev/null
+++ b/db/migrate/20230613122211_add_vulnerability_attributes_to_scan_result_policies.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddVulnerabilityAttributesToScanResultPolicies < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :scan_result_policies, :vulnerability_attributes, :jsonb, default: {}
+ end
+end
diff --git a/db/migrate/20230614180651_add_organization_id_to_namespaces.rb b/db/migrate/20230614180651_add_organization_id_to_namespaces.rb
new file mode 100644
index 00000000000..6a0048b5fc3
--- /dev/null
+++ b/db/migrate/20230614180651_add_organization_id_to_namespaces.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddOrganizationIdToNamespaces < Gitlab::Database::Migration[2.1]
+ DEFAULT_ORGANIZATION_ID = 1
+
+ enable_lock_retries!
+
+ def up
+ # This column already exists on some environments and it was reverted
+ # in MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122809
+ return if column_exists?(:namespaces, :organization_id)
+
+ add_column :namespaces, :organization_id, :bigint, default: DEFAULT_ORGANIZATION_ID, null: true # rubocop:disable Migration/AddColumnsToWideTables
+ end
+
+ def down
+ remove_column :namespaces, :organization_id
+ end
+end
diff --git a/db/migrate/20230615074515_add_index_to_audit_event_external_destination.rb b/db/migrate/20230615074515_add_index_to_audit_event_external_destination.rb
new file mode 100644
index 00000000000..b1846c8abed
--- /dev/null
+++ b/db/migrate/20230615074515_add_index_to_audit_event_external_destination.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddIndexToAuditEventExternalDestination < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'unique_external_audit_event_destination_namespace_id_and_name'
+
+ def up
+ add_concurrent_index :audit_events_external_audit_event_destinations, [:namespace_id, :name], unique: true,
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :audit_events_external_audit_event_destinations, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230615074544_add_index_to_instance_audit_event_destination.rb b/db/migrate/20230615074544_add_index_to_instance_audit_event_destination.rb
new file mode 100644
index 00000000000..4e14bb537a3
--- /dev/null
+++ b/db/migrate/20230615074544_add_index_to_instance_audit_event_destination.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToInstanceAuditEventDestination < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'unique_instance_audit_event_destination_name'
+
+ def up
+ add_concurrent_index :audit_events_instance_external_audit_event_destinations, :name, unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :audit_events_instance_external_audit_event_destinations, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230615104902_add_user_id_foreign_key_to_organization_users.rb b/db/migrate/20230615104902_add_user_id_foreign_key_to_organization_users.rb
new file mode 100644
index 00000000000..0f8d18ee384
--- /dev/null
+++ b/db/migrate/20230615104902_add_user_id_foreign_key_to_organization_users.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUserIdForeignKeyToOrganizationUsers < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :organization_users, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :organization_users, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230616164309_create_subscription_user_add_on_assignments.rb b/db/migrate/20230616164309_create_subscription_user_add_on_assignments.rb
new file mode 100644
index 00000000000..cb184cd1987
--- /dev/null
+++ b/db/migrate/20230616164309_create_subscription_user_add_on_assignments.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateSubscriptionUserAddOnAssignments < Gitlab::Database::Migration[2.1]
+ UNIQUE_INDEX_NAME = 'uniq_idx_user_add_on_assignments_on_add_on_purchase_and_user'
+
+ def change
+ create_table :subscription_user_add_on_assignments do |t|
+ t.bigint :add_on_purchase_id, null: false
+ t.bigint :user_id, null: false
+
+ t.timestamps_with_timezone null: false
+
+ t.index [:add_on_purchase_id, :user_id], unique: true, name: UNIQUE_INDEX_NAME
+ t.index :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230616164705_add_foreign_key_add_on_purchase_id_on_subscription_user_add_on_assignments.rb b/db/migrate/20230616164705_add_foreign_key_add_on_purchase_id_on_subscription_user_add_on_assignments.rb
new file mode 100644
index 00000000000..d0d89bd5027
--- /dev/null
+++ b/db/migrate/20230616164705_add_foreign_key_add_on_purchase_id_on_subscription_user_add_on_assignments.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddForeignKeyAddOnPurchaseIdOnSubscriptionUserAddOnAssignments < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :subscription_user_add_on_assignments, :subscription_add_on_purchases,
+ column: :add_on_purchase_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :subscription_user_add_on_assignments, column: :add_on_purchase_id
+ end
+ end
+end
diff --git a/db/migrate/20230616164731_add_foreign_key_user_id_on_subscription_user_add_on_assignments.rb b/db/migrate/20230616164731_add_foreign_key_user_id_on_subscription_user_add_on_assignments.rb
new file mode 100644
index 00000000000..a28c798deec
--- /dev/null
+++ b/db/migrate/20230616164731_add_foreign_key_user_id_on_subscription_user_add_on_assignments.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyUserIdOnSubscriptionUserAddOnAssignments < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :subscription_user_add_on_assignments, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :subscription_user_add_on_assignments, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230616200440_create_system_access_microsoft_application.rb b/db/migrate/20230616200440_create_system_access_microsoft_application.rb
new file mode 100644
index 00000000000..d58dd8f88d9
--- /dev/null
+++ b/db/migrate/20230616200440_create_system_access_microsoft_application.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateSystemAccessMicrosoftApplication < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ create_table :system_access_microsoft_applications do |t|
+ t.timestamps_with_timezone null: false
+ t.references :namespace, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.boolean :enabled, null: false, default: false
+ t.text :tenant_xid, null: false, limit: 255
+ t.text :client_xid, null: false, limit: 255
+ t.text :login_endpoint, null: false, limit: 255, default: 'https://login.microsoftonline.com'
+ t.text :graph_endpoint, null: false, limit: 255, default: 'https://graph.microsoft.com'
+ t.binary :encrypted_client_secret, null: false
+ t.binary :encrypted_client_secret_iv, null: false
+ end
+ end
+end
diff --git a/db/migrate/20230616214220_create_system_access_microsoft_graph_access_tokens.rb b/db/migrate/20230616214220_create_system_access_microsoft_graph_access_tokens.rb
new file mode 100644
index 00000000000..df196280d0c
--- /dev/null
+++ b/db/migrate/20230616214220_create_system_access_microsoft_graph_access_tokens.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateSystemAccessMicrosoftGraphAccessTokens < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :system_access_microsoft_graph_access_tokens do |t|
+ t.timestamps_with_timezone null: false
+ t.references :system_access_microsoft_application,
+ index: { name: 'unique_index_sysaccess_ms_access_tokens_on_sysaccess_ms_app_id', unique: true },
+ foreign_key: { on_delete: :cascade }
+ t.integer :expires_in, null: false
+ t.binary :encrypted_token, null: false
+ t.binary :encrypted_token_iv, null: false
+ end
+ end
+end
diff --git a/db/migrate/20230620101808_change_default_value_for_distro_version.rb b/db/migrate/20230620101808_change_default_value_for_distro_version.rb
new file mode 100644
index 00000000000..f0da7cfaba7
--- /dev/null
+++ b/db/migrate/20230620101808_change_default_value_for_distro_version.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ChangeDefaultValueForDistroVersion < Gitlab::Database::Migration[2.1]
+ def up
+ change_column_default :pm_affected_packages, :distro_version, from: nil, to: ''
+ change_column_null :pm_affected_packages, :distro_version, false
+ end
+
+ def down
+ change_column_default :pm_affected_packages, :distro_version, from: '', to: nil
+ change_column_null :pm_affected_packages, :distro_version, true
+ end
+end
diff --git a/db/migrate/20230620104217_add_organization_id_foreign_key_to_organization_users.rb b/db/migrate/20230620104217_add_organization_id_foreign_key_to_organization_users.rb
new file mode 100644
index 00000000000..0a9757d2e14
--- /dev/null
+++ b/db/migrate/20230620104217_add_organization_id_foreign_key_to_organization_users.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddOrganizationIdForeignKeyToOrganizationUsers < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :organization_users, :organizations, column: :organization_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :organization_users, column: :organization_id
+ end
+ end
+end
diff --git a/db/migrate/20230621065943_add_elasticsearch_requeue_workers_to_application_settings.rb b/db/migrate/20230621065943_add_elasticsearch_requeue_workers_to_application_settings.rb
new file mode 100644
index 00000000000..2297cc5cdc2
--- /dev/null
+++ b/db/migrate/20230621065943_add_elasticsearch_requeue_workers_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddElasticsearchRequeueWorkersToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :elasticsearch_requeue_workers, :boolean, null: false, default: false
+ end
+end
diff --git a/db/migrate/20230621070810_update_requeue_workers_in_application_settings_for_gitlab_com.rb b/db/migrate/20230621070810_update_requeue_workers_in_application_settings_for_gitlab_com.rb
new file mode 100644
index 00000000000..9ed9af71066
--- /dev/null
+++ b/db/migrate/20230621070810_update_requeue_workers_in_application_settings_for_gitlab_com.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class UpdateRequeueWorkersInApplicationSettingsForGitlabCom < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ return unless Gitlab.com?
+
+ execute 'UPDATE application_settings SET elasticsearch_requeue_workers = true'
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ execute 'UPDATE application_settings SET elasticsearch_requeue_workers = false'
+ end
+end
diff --git a/db/migrate/20230621072726_add_description_to_ci_variable.rb b/db/migrate/20230621072726_add_description_to_ci_variable.rb
new file mode 100644
index 00000000000..c14afca60bb
--- /dev/null
+++ b/db/migrate/20230621072726_add_description_to_ci_variable.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddDescriptionToCiVariable < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # text limit is added in a 20230621072848_add_text_limit_to_ci_variable_description.rb migration
+ def change
+ add_column(:ci_variables, :description, :text)
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230621074446_add_elasticsearch_number_of_shards_to_application_settings.rb b/db/migrate/20230621074446_add_elasticsearch_number_of_shards_to_application_settings.rb
new file mode 100644
index 00000000000..6eed0f8cf15
--- /dev/null
+++ b/db/migrate/20230621074446_add_elasticsearch_number_of_shards_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddElasticsearchNumberOfShardsToApplicationSettings < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :application_settings, :elasticsearch_worker_number_of_shards, :integer, null: false, default: 2
+ end
+end
diff --git a/db/migrate/20230621074611_update_elasticsearch_number_of_shards_in_application_settings_for_gitlab_com.rb b/db/migrate/20230621074611_update_elasticsearch_number_of_shards_in_application_settings_for_gitlab_com.rb
new file mode 100644
index 00000000000..666d4a2e096
--- /dev/null
+++ b/db/migrate/20230621074611_update_elasticsearch_number_of_shards_in_application_settings_for_gitlab_com.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class UpdateElasticsearchNumberOfShardsInApplicationSettingsForGitlabCom < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ enable_lock_retries!
+
+ def up
+ return unless Gitlab.com?
+
+ execute 'UPDATE application_settings SET elasticsearch_worker_number_of_shards = 16'
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ execute 'UPDATE application_settings SET elasticsearch_worker_number_of_shards = 2'
+ end
+end
diff --git a/db/migrate/20230621083004_add_description_to_ci_group_variable.rb b/db/migrate/20230621083004_add_description_to_ci_group_variable.rb
new file mode 100644
index 00000000000..933c4079c4c
--- /dev/null
+++ b/db/migrate/20230621083004_add_description_to_ci_group_variable.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddDescriptionToCiGroupVariable < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # text limit is added in a 20230621083052_add_text_limit_to_ci_group_variable_description.rb migration
+ def change
+ add_column(:ci_group_variables, :description, :text)
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20230622044119_create_merge_request_review_llm_summary.rb b/db/migrate/20230622044119_create_merge_request_review_llm_summary.rb
new file mode 100644
index 00000000000..19b9cf27d90
--- /dev/null
+++ b/db/migrate/20230622044119_create_merge_request_review_llm_summary.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateMergeRequestReviewLlmSummary < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = "index_merge_request_review_llm_summaries_on_mr_diff_id"
+
+ def change
+ create_table :merge_request_review_llm_summaries do |t|
+ t.references :user, null: true, index: true
+ t.references :review, null: false, index: true
+ t.references :merge_request_diff, 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/20230622051925_add_user_foreign_key_to_merge_request_review_llm_summary.rb b/db/migrate/20230622051925_add_user_foreign_key_to_merge_request_review_llm_summary.rb
new file mode 100644
index 00000000000..1fa19317913
--- /dev/null
+++ b/db/migrate/20230622051925_add_user_foreign_key_to_merge_request_review_llm_summary.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUserForeignKeyToMergeRequestReviewLlmSummary < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_request_review_llm_summaries, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :merge_request_review_llm_summaries, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20230622051943_add_review_foreign_key_to_merge_request_review_llm_summary.rb b/db/migrate/20230622051943_add_review_foreign_key_to_merge_request_review_llm_summary.rb
new file mode 100644
index 00000000000..ec4eb6b3f91
--- /dev/null
+++ b/db/migrate/20230622051943_add_review_foreign_key_to_merge_request_review_llm_summary.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddReviewForeignKeyToMergeRequestReviewLlmSummary < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_request_review_llm_summaries, :reviews, column: :review_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :merge_request_review_llm_summaries, column: :review_id
+ end
+ end
+end
diff --git a/db/migrate/20230622052015_add_merge_request_diff_foreign_key_to_merge_request_review_llm_summary.rb b/db/migrate/20230622052015_add_merge_request_diff_foreign_key_to_merge_request_review_llm_summary.rb
new file mode 100644
index 00000000000..f5409aa48e9
--- /dev/null
+++ b/db/migrate/20230622052015_add_merge_request_diff_foreign_key_to_merge_request_review_llm_summary.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddMergeRequestDiffForeignKeyToMergeRequestReviewLlmSummary < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_request_review_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_review_llm_summaries, column: :merge_request_diff_id
+ end
+ end
+end
diff --git a/db/migrate/20230622093921_remove_deprecated_metric_worker_instances.rb b/db/migrate/20230622093921_remove_deprecated_metric_worker_instances.rb
new file mode 100644
index 00000000000..ac2bc02ec3f
--- /dev/null
+++ b/db/migrate/20230622093921_remove_deprecated_metric_worker_instances.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class RemoveDeprecatedMetricWorkerInstances < Gitlab::Database::Migration[2.1]
+ DEPRECATED_JOB_CLASSES = %w[
+ Clusters::Integrations::CheckPrometheusHealthWorker
+ Metrics::Dashboard::PruneOldAnnotationsWorker
+ Metrics::Dashboard::ScheduleAnnotationsPruneWorker
+ Metrics::Dashboard::SyncDashboardsWorker
+ ]
+
+ 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/20230626065725_backfill_instance_audit_event_name.rb b/db/migrate/20230626065725_backfill_instance_audit_event_name.rb
new file mode 100644
index 00000000000..082a57fcc99
--- /dev/null
+++ b/db/migrate/20230626065725_backfill_instance_audit_event_name.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 BackfillInstanceAuditEventName < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class InstanceDestination < MigrationRecord
+ self.table_name = 'audit_events_instance_external_audit_event_destinations'
+ end
+
+ def change
+ InstanceDestination.update_all("name = 'Destination ' || id")
+ end
+end
diff --git a/db/migrate/20230626065755_backfill_external_audit_event_name.rb b/db/migrate/20230626065755_backfill_external_audit_event_name.rb
new file mode 100644
index 00000000000..1c983e802d8
--- /dev/null
+++ b/db/migrate/20230626065755_backfill_external_audit_event_name.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class BackfillExternalAuditEventName < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class ExternalDestination < MigrationRecord
+ self.table_name = 'audit_events_external_audit_event_destinations'
+ end
+
+ def change
+ ExternalDestination.update_all("name = 'Destination ' || id")
+ end
+end
diff --git a/db/migrate/20230626070959_add_not_null_to_external_audit_event.rb b/db/migrate/20230626070959_add_not_null_to_external_audit_event.rb
new file mode 100644
index 00000000000..e6d75c1dc68
--- /dev/null
+++ b/db/migrate/20230626070959_add_not_null_to_external_audit_event.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddNotNullToExternalAuditEvent < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ change_column_null :audit_events_external_audit_event_destinations, :name, false
+ end
+
+ def down
+ change_column_null :audit_events_external_audit_event_destinations, :name, true
+ end
+end
diff --git a/db/migrate/20230626071100_add_not_null_to_instance_audit_event.rb b/db/migrate/20230626071100_add_not_null_to_instance_audit_event.rb
new file mode 100644
index 00000000000..6a67dcf1a24
--- /dev/null
+++ b/db/migrate/20230626071100_add_not_null_to_instance_audit_event.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddNotNullToInstanceAuditEvent < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ change_column_null :audit_events_instance_external_audit_event_destinations, :name, false
+ end
+
+ def down
+ change_column_null :audit_events_instance_external_audit_event_destinations, :name, true
+ end
+end
diff --git a/db/migrate/20230626113908_add_project_id_to_scan_result_policies.rb b/db/migrate/20230626113908_add_project_id_to_scan_result_policies.rb
new file mode 100644
index 00000000000..6066b945edf
--- /dev/null
+++ b/db/migrate/20230626113908_add_project_id_to_scan_result_policies.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddProjectIdToScanResultPolicies < Gitlab::Database::Migration[2.1]
+ def up
+ add_column :scan_result_policies, :project_id, :bigint
+ end
+
+ def down
+ remove_column :scan_result_policies, :project_id
+ end
+end
diff --git a/db/migrate/20230626113909_add_index_to_scan_result_policies_on_project_id.rb b/db/migrate/20230626113909_add_index_to_scan_result_policies_on_project_id.rb
new file mode 100644
index 00000000000..63416765bfa
--- /dev/null
+++ b/db/migrate/20230626113909_add_index_to_scan_result_policies_on_project_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToScanResultPoliciesOnProjectId < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_scan_result_policies_on_project_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :scan_result_policies, :project_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :scan_result_policies, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230626113910_add_project_id_foreign_key_to_scan_result_policies.rb b/db/migrate/20230626113910_add_project_id_foreign_key_to_scan_result_policies.rb
new file mode 100644
index 00000000000..c5446e17ef3
--- /dev/null
+++ b/db/migrate/20230626113910_add_project_id_foreign_key_to_scan_result_policies.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddProjectIdForeignKeyToScanResultPolicies < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :scan_result_policies,
+ :projects,
+ column: :project_id,
+ on_delete: :cascade
+ end
+
+ def down
+ remove_foreign_key_if_exists :scan_result_policies, column: :project_id
+ end
+end
diff --git a/db/migrate/20230629071427_add_last_enforced_at_to_namespace_limits.rb b/db/migrate/20230629071427_add_last_enforced_at_to_namespace_limits.rb
new file mode 100644
index 00000000000..4f005c42228
--- /dev/null
+++ b/db/migrate/20230629071427_add_last_enforced_at_to_namespace_limits.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddLastEnforcedAtToNamespaceLimits < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :namespace_limits, :last_enforced_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20230629112833_create_fk_ml_candidates_on_user_id.rb b/db/migrate/20230629112833_create_fk_ml_candidates_on_user_id.rb
new file mode 100644
index 00000000000..85545c41529
--- /dev/null
+++ b/db/migrate/20230629112833_create_fk_ml_candidates_on_user_id.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateFkMlCandidatesOnUserId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ NEW_CONSTRAINT_NAME = 'fk_ml_candidates_on_user_id'
+
+ def up
+ add_concurrent_foreign_key(
+ :ml_candidates,
+ :users,
+ column: :user_id,
+ on_delete: :nullify,
+ validate: false,
+ name: NEW_CONSTRAINT_NAME
+ )
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists(
+ :ml_candidates,
+ column: :user_id,
+ on_delete: :nullify,
+ name: NEW_CONSTRAINT_NAME
+ )
+ end
+ end
+end
diff --git a/db/migrate/20230629113029_validate_fk_ml_candidates_on_user_id.rb b/db/migrate/20230629113029_validate_fk_ml_candidates_on_user_id.rb
new file mode 100644
index 00000000000..dce7f8eeb47
--- /dev/null
+++ b/db/migrate/20230629113029_validate_fk_ml_candidates_on_user_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ValidateFkMlCandidatesOnUserId < Gitlab::Database::Migration[2.1]
+ NEW_CONSTRAINT_NAME = 'fk_ml_candidates_on_user_id'
+
+ def up
+ validate_foreign_key(:ml_candidates, :user_id, name: NEW_CONSTRAINT_NAME)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20230629113133_remove_old_fk_ml_candidates_on_user_id.rb b/db/migrate/20230629113133_remove_old_fk_ml_candidates_on_user_id.rb
new file mode 100644
index 00000000000..73ed826ec75
--- /dev/null
+++ b/db/migrate/20230629113133_remove_old_fk_ml_candidates_on_user_id.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveOldFkMlCandidatesOnUserId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ OLD_CONSTRAINT_NAME = 'fk_rails_1b37441fe5'
+
+ def up
+ remove_foreign_key_if_exists(:ml_candidates, column: :user_id, name: OLD_CONSTRAINT_NAME)
+ end
+
+ def down
+ add_concurrent_foreign_key(
+ :ml_candidates,
+ :users,
+ column: :user_id,
+ validate: false,
+ name: OLD_CONSTRAINT_NAME
+ )
+ end
+end
diff --git a/db/migrate/20230630101337_add_previous_personal_access_token_to_personal_access_tokens.rb b/db/migrate/20230630101337_add_previous_personal_access_token_to_personal_access_tokens.rb
new file mode 100644
index 00000000000..870723abea9
--- /dev/null
+++ b/db/migrate/20230630101337_add_previous_personal_access_token_to_personal_access_tokens.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddPreviousPersonalAccessTokenToPersonalAccessTokens < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ add_column :personal_access_tokens, :previous_personal_access_token_id, :bigint, null: true
+ end
+
+ def down
+ remove_column :personal_access_tokens, :previous_personal_access_token_id
+ end
+end
diff --git a/db/migrate/20230630101342_add_index_to_personal_access_tokens_on_previous_personal_access_token_id.rb b/db/migrate/20230630101342_add_index_to_personal_access_tokens_on_previous_personal_access_token_id.rb
new file mode 100644
index 00000000000..9d07d9f4118
--- /dev/null
+++ b/db/migrate/20230630101342_add_index_to_personal_access_tokens_on_previous_personal_access_token_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToPersonalAccessTokensOnPreviousPersonalAccessTokenId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'idx_personal_access_tokens_on_previous_personal_access_token_id'
+
+ def up
+ add_concurrent_index :personal_access_tokens, :previous_personal_access_token_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :personal_access_tokens, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20230630101347_add_fk_to_personal_access_tokens_on_previous_personal_access_token_id.rb b/db/migrate/20230630101347_add_fk_to_personal_access_tokens_on_previous_personal_access_token_id.rb
new file mode 100644
index 00000000000..a740b386e47
--- /dev/null
+++ b/db/migrate/20230630101347_add_fk_to_personal_access_tokens_on_previous_personal_access_token_id.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddFkToPersonalAccessTokensOnPreviousPersonalAccessTokenId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(
+ :personal_access_tokens,
+ :personal_access_tokens,
+ column: :previous_personal_access_token_id,
+ on_delete: :nullify)
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :personal_access_tokens, column: :previous_personal_access_token_id
+ end
+ end
+end
diff --git a/db/migrate/20230630170515_add_state_to_catalog_resources.rb b/db/migrate/20230630170515_add_state_to_catalog_resources.rb
new file mode 100644
index 00000000000..ff0a5fda6c9
--- /dev/null
+++ b/db/migrate/20230630170515_add_state_to_catalog_resources.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddStateToCatalogResources < Gitlab::Database::Migration[2.1]
+ DRAFT = 0
+
+ def change
+ add_column :catalog_resources, :state, :smallint, null: false, limit: 1, default: DRAFT
+ end
+end
diff --git a/db/migrate/20230701195315_add_kubernetes_namespace_column_to_environments.rb b/db/migrate/20230701195315_add_kubernetes_namespace_column_to_environments.rb
new file mode 100644
index 00000000000..e05feca2c64
--- /dev/null
+++ b/db/migrate/20230701195315_add_kubernetes_namespace_column_to_environments.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddKubernetesNamespaceColumnToEnvironments < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :environments, :kubernetes_namespace, :text unless column_exists?(:environments, :kubernetes_namespace)
+ end
+
+ add_text_limit :environments, :kubernetes_namespace, 63
+ end
+
+ def down
+ remove_column :environments, :kubernetes_namespace
+ end
+end
diff --git a/db/migrate/20230703115902_add_relay_state_allowlist_application_settings.rb b/db/migrate/20230703115902_add_relay_state_allowlist_application_settings.rb
new file mode 100644
index 00000000000..3de7470f113
--- /dev/null
+++ b/db/migrate/20230703115902_add_relay_state_allowlist_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddRelayStateAllowlistApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :application_settings, :relay_state_domain_allowlist,
+ :text,
+ array: true,
+ default: [],
+ null: false
+ end
+end
diff --git a/db/migrate/20230703121859_add_relay_state_allowlist_saml_providers.rb b/db/migrate/20230703121859_add_relay_state_allowlist_saml_providers.rb
new file mode 100644
index 00000000000..b05059d1d61
--- /dev/null
+++ b/db/migrate/20230703121859_add_relay_state_allowlist_saml_providers.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddRelayStateAllowlistSamlProviders < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :saml_providers, :relay_state_domain_allowlist,
+ :text,
+ array: true,
+ default: [],
+ null: false
+ end
+end
diff --git a/db/migrate/20230705085223_create_service_access_tokens.rb b/db/migrate/20230705085223_create_service_access_tokens.rb
new file mode 100644
index 00000000000..b934ef5d60a
--- /dev/null
+++ b/db/migrate/20230705085223_create_service_access_tokens.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateServiceAccessTokens < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :service_access_tokens do |t|
+ t.timestamps_with_timezone null: false
+ t.integer :category, limit: 2, null: false, default: 0
+ t.binary :encrypted_token, null: false
+ t.binary :encrypted_token_iv, null: false
+ end
+ end
+end
diff --git a/db/migrate/20230705092150_create_ml_models.rb b/db/migrate/20230705092150_create_ml_models.rb
new file mode 100644
index 00000000000..df8827a781f
--- /dev/null
+++ b/db/migrate/20230705092150_create_ml_models.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateMlModels < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ create_table :ml_models do |t|
+ t.timestamps_with_timezone null: false
+ t.references :project, foreign_key: true, index: true, on_delete: :cascade, null: false
+ t.text :name, limit: 255, null: false
+
+ t.index [:project_id, :name], unique: true
+ end
+ end
+
+ def down
+ drop_table :ml_models
+ end
+end
diff --git a/db/migrate/20230705155000_add_group_mention_events_to_integrations.rb b/db/migrate/20230705155000_add_group_mention_events_to_integrations.rb
new file mode 100644
index 00000000000..82c2c714022
--- /dev/null
+++ b/db/migrate/20230705155000_add_group_mention_events_to_integrations.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddGroupMentionEventsToIntegrations < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :integrations, :group_mention_events, :boolean, null: false, default: false
+ add_column :integrations, :group_confidential_mention_events, :boolean, null: false, default: false
+ end
+end
diff --git a/db/migrate/20230706130217_add_column_model_id_to_ml_experiments.rb b/db/migrate/20230706130217_add_column_model_id_to_ml_experiments.rb
new file mode 100644
index 00000000000..4eab027bc22
--- /dev/null
+++ b/db/migrate/20230706130217_add_column_model_id_to_ml_experiments.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddColumnModelIdToMlExperiments < Gitlab::Database::Migration[2.1]
+ def change
+ # rubocop:disable Migration/AddReference
+ add_reference :ml_experiments,
+ :model,
+ index: true,
+ null: true,
+ unique: true,
+ foreign_key: { on_delete: :cascade, to_table: :ml_models }
+ # rubocop:enable Migration/AddReference
+ end
+end
diff --git a/db/migrate/20230706192435_remove_debian_process_changes_worker_job_instances.rb b/db/migrate/20230706192435_remove_debian_process_changes_worker_job_instances.rb
new file mode 100644
index 00000000000..48c992b5e3c
--- /dev/null
+++ b/db/migrate/20230706192435_remove_debian_process_changes_worker_job_instances.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveDebianProcessChangesWorkerJobInstances < Gitlab::Database::Migration[2.1]
+ DEPRECATED_JOB_CLASSES = %w[Packages::Debian::ProcessChangesWorker]
+
+ 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/20230707090835_create_ml_model_versions.rb b/db/migrate/20230707090835_create_ml_model_versions.rb
new file mode 100644
index 00000000000..f7be6ec4681
--- /dev/null
+++ b/db/migrate/20230707090835_create_ml_model_versions.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class CreateMlModelVersions < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ create_table :ml_model_versions do |t|
+ t.timestamps_with_timezone null: false
+ t.references :project, foreign_key: { on_delete: :cascade }, index: true, null: false
+
+ t.bigint :model_id, null: false # fk cascade
+ t.bigint :package_id, null: true # fk nullify
+
+ t.text :version, limit: 255, null: false
+
+ t.index :model_id
+ t.index :package_id
+ t.index [:project_id, :model_id, :version], unique: true
+ end
+ end
+
+ def down
+ drop_table :ml_model_versions
+ end
+end
diff --git a/db/migrate/20230707094002_add_fk_on_ml_model_versions_to_ml_models.rb b/db/migrate/20230707094002_add_fk_on_ml_model_versions_to_ml_models.rb
new file mode 100644
index 00000000000..04e7b9c2e6a
--- /dev/null
+++ b/db/migrate/20230707094002_add_fk_on_ml_model_versions_to_ml_models.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddFkOnMlModelVersionsToMlModels < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(:ml_model_versions, :ml_models, column: :model_id, on_delete: :cascade)
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists(:ml_model_versions, column: :model_id, on_delete: :cascade)
+ end
+ end
+end
diff --git a/db/migrate/20230707094003_add_fk_on_ml_model_versions_to_packages.rb b/db/migrate/20230707094003_add_fk_on_ml_model_versions_to_packages.rb
new file mode 100644
index 00000000000..03c1af1af66
--- /dev/null
+++ b/db/migrate/20230707094003_add_fk_on_ml_model_versions_to_packages.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddFkOnMlModelVersionsToPackages < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(:ml_model_versions, :packages_packages, column: :package_id, on_delete: :nullify)
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists(:ml_model_versions, column: :package_id, on_delete: :nullify)
+ end
+ end
+end
diff --git a/db/migrate/20230710160232_add_expires_at_to_service_access_tokens.rb b/db/migrate/20230710160232_add_expires_at_to_service_access_tokens.rb
new file mode 100644
index 00000000000..f9e4e014ff4
--- /dev/null
+++ b/db/migrate/20230710160232_add_expires_at_to_service_access_tokens.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddExpiresAtToServiceAccessTokens < Gitlab::Database::Migration[2.1]
+ def change
+ # Code using this table has not been implemented yet.
+ # During we run the migration, the table will be empty.
+ # rubocop:disable Rails/NotNullColumn
+ add_column :service_access_tokens, :expires_at, :datetime_with_timezone, null: false
+ # rubocop:enable Rails/NotNullColumn
+ end
+end
diff --git a/db/migrate/20230710200434_add_emoji_events_to_web_hooks.rb b/db/migrate/20230710200434_add_emoji_events_to_web_hooks.rb
new file mode 100644
index 00000000000..45a6d15cefb
--- /dev/null
+++ b/db/migrate/20230710200434_add_emoji_events_to_web_hooks.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddEmojiEventsToWebHooks < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ add_column :web_hooks, :emoji_events, :boolean, null: false, default: false
+ end
+end
diff --git a/db/migrate/20230712214613_add_read_dependency_to_member_roles.rb b/db/migrate/20230712214613_add_read_dependency_to_member_roles.rb
new file mode 100644
index 00000000000..c6c9f3a0611
--- /dev/null
+++ b/db/migrate/20230712214613_add_read_dependency_to_member_roles.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddReadDependencyToMemberRoles < Gitlab::Database::Migration[2.1]
+ def change
+ add_column :member_roles, :read_dependency, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20230714195649_add_namespace_storage_forks_cost_factor_to_application_settings.rb b/db/migrate/20230714195649_add_namespace_storage_forks_cost_factor_to_application_settings.rb
new file mode 100644
index 00000000000..3388b934668
--- /dev/null
+++ b/db/migrate/20230714195649_add_namespace_storage_forks_cost_factor_to_application_settings.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddNamespaceStorageForksCostFactorToApplicationSettings < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = 'check_app_settings_namespace_storage_forks_cost_factor_range'
+
+ def up
+ with_lock_retries do
+ add_column :application_settings, :namespace_storage_forks_cost_factor,
+ :float, default: 1.0, null: false, if_not_exists: true
+ end
+
+ add_check_constraint :application_settings,
+ 'namespace_storage_forks_cost_factor >= 0 AND namespace_storage_forks_cost_factor <= 1',
+ CONSTRAINT_NAME
+ end
+
+ def down
+ remove_column :application_settings, :namespace_storage_forks_cost_factor
+ end
+end
diff --git a/db/migrate/20230717200940_create_group_wiki_repository_states.rb b/db/migrate/20230717200940_create_group_wiki_repository_states.rb
new file mode 100644
index 00000000000..36b2173ab24
--- /dev/null
+++ b/db/migrate/20230717200940_create_group_wiki_repository_states.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+class CreateGroupWikiRepositoryStates < Gitlab::Database::Migration[2.1]
+ VERIFICATION_STATE_INDEX_NAME = "index_group_wiki_repository_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_group_wiki_repository_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_group_wiki_repository_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_group_wiki_repository_states_needs_verification"
+
+ enable_lock_retries!
+
+ def up
+ create_table :group_wiki_repository_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 :group_wiki_repository,
+ null: false,
+ index: { unique: true },
+ foreign_key: { primary_key: :group_id, 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 :group_wiki_repository_states
+ end
+end
diff --git a/db/post_migrate/20230314094213_remove_foreign_keys_from_u2f_registrations_table.rb b/db/post_migrate/20230314094213_remove_foreign_keys_from_u2f_registrations_table.rb
new file mode 100644
index 00000000000..d6185d6674d
--- /dev/null
+++ b/db/post_migrate/20230314094213_remove_foreign_keys_from_u2f_registrations_table.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveForeignKeysFromU2fRegistrationsTable < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key :u2f_registrations, :users
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key :u2f_registrations, :users, column: :user_id
+ end
+end
diff --git a/db/post_migrate/20230314094215_drop_u2f_registrations_table.rb b/db/post_migrate/20230314094215_drop_u2f_registrations_table.rb
new file mode 100644
index 00000000000..9a57c424592
--- /dev/null
+++ b/db/post_migrate/20230314094215_drop_u2f_registrations_table.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class DropU2fRegistrationsTable < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ drop_table :u2f_registrations
+ end
+
+ def down
+ create_table :u2f_registrations do |t| # rubocop: disable Migration/SchemaAdditionMethodsNoPost
+ t.text :certificate
+ t.string :key_handle
+ t.string :public_key
+ t.integer :counter
+ t.references :user, foreign_key: false
+ t.datetime_with_timezone :created_at, null: false
+ t.datetime_with_timezone :updated_at, null: false
+ t.string :name
+ t.index [:key_handle], name: 'index_u2f_registrations_on_key_handle'
+ end
+ end
+end
diff --git a/db/post_migrate/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation.rb b/db/post_migrate/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation.rb
index 59bff26f964..168354cd946 100644
--- a/db/post_migrate/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation.rb
+++ b/db/post_migrate/20230317004428_migrate_daily_redis_hll_events_to_weekly_aggregation.rb
@@ -3,6 +3,12 @@
class MigrateDailyRedisHllEventsToWeeklyAggregation < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
+ # Due to the feature flag `use_metric_definitions_for_events_list`, this makes a `SELECT` call
+ # so this migration is now considered a DML (data manipulation) migration.
+ # For the time being, we need to specify only `main` database because it is now technically retriving DB data.
+ # Should be removed with <issue link>
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
DAILY_EVENTS =
%w[g_edit_by_web_ide
g_edit_by_sfe
diff --git a/db/post_migrate/20230523101514_finalize_user_type_migration.rb b/db/post_migrate/20230523101514_finalize_user_type_migration.rb
new file mode 100644
index 00000000000..c6533bec587
--- /dev/null
+++ b/db/post_migrate/20230523101514_finalize_user_type_migration.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class FinalizeUserTypeMigration < Gitlab::Database::Migration[2.1]
+ MIGRATION = 'MigrateHumanUserType'
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ disable_ddl_transaction!
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: MIGRATION,
+ table_name: :users,
+ column_name: :id,
+ job_arguments: []
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230528203340_drop_message_from_vulnerability_occurrences.rb b/db/post_migrate/20230528203340_drop_message_from_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..4214ba803f6
--- /dev/null
+++ b/db/post_migrate/20230528203340_drop_message_from_vulnerability_occurrences.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropMessageFromVulnerabilityOccurrences < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ remove_column :vulnerability_occurrences, :message
+ end
+
+ def down
+ unless column_exists?(:vulnerability_occurrences, :message)
+ add_column :vulnerability_occurrences, :message, :text # rubocop:disable Migration/SchemaAdditionMethodsNoPost
+ end
+
+ add_check_constraint(:vulnerability_occurrences, 'char_length(message) <= 3000', 'check_df6dd20219')
+ end
+end
diff --git a/db/post_migrate/20230530012406_finalize_backfill_resource_link_events.rb b/db/post_migrate/20230530012406_finalize_backfill_resource_link_events.rb
new file mode 100644
index 00000000000..c86a341392f
--- /dev/null
+++ b/db/post_migrate/20230530012406_finalize_backfill_resource_link_events.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class FinalizeBackfillResourceLinkEvents < Gitlab::Database::Migration[2.1]
+ MIGRATION = 'BackfillResourceLinkEvents'
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: MIGRATION,
+ table_name: :system_note_metadata,
+ column_name: :id,
+ job_arguments: [],
+ finalize: true
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb b/db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb
new file mode 100644
index 00000000000..e7ccfad1fd3
--- /dev/null
+++ b/db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddDetectedAtIdIndexToVulnerabilities < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_vulnerabilities_on_detected_at_and_id'
+
+ def up
+ add_concurrent_index :vulnerabilities, [:id, :detected_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb b/db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb
new file mode 100644
index 00000000000..f91394eb783
--- /dev/null
+++ b/db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUuidProjectIdStateIdIndexToVulnerabilityReads < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_vulnerability_reads_on_uuid_project_id_and_state'
+
+ def up
+ add_concurrent_index :vulnerability_reads, [:uuid, :project_id, :state], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230608145500_add_prepared_at_index_to_merge_requests.rb b/db/post_migrate/20230608145500_add_prepared_at_index_to_merge_requests.rb
new file mode 100644
index 00000000000..3d3557ce543
--- /dev/null
+++ b/db/post_migrate/20230608145500_add_prepared_at_index_to_merge_requests.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddPreparedAtIndexToMergeRequests < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_merge_requests_on_id_and_prepared_at'
+
+ # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/415721
+
+ def up
+ prepare_async_index(:merge_requests,
+ :id,
+ name: INDEX_NAME,
+ where: "prepared_at IS NULL")
+ end
+
+ def down
+ unprepare_async_index(:merge_requests, :id, name: INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20230609065942_backfill_ci_pipeline_variables_for_pipeline_id_bigint_conversion.rb b/db/post_migrate/20230609065942_backfill_ci_pipeline_variables_for_pipeline_id_bigint_conversion.rb
new file mode 100644
index 00000000000..c09820ad9d4
--- /dev/null
+++ b/db/post_migrate/20230609065942_backfill_ci_pipeline_variables_for_pipeline_id_bigint_conversion.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class BackfillCiPipelineVariablesForPipelineIdBigintConversion < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_ci
+
+ TABLE = :ci_pipeline_variables
+ COLUMNS = %i[pipeline_id]
+
+ def up
+ backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, sub_batch_size: 500)
+ end
+
+ def down
+ revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+end
diff --git a/db/post_migrate/20230613192703_ensure_ci_build_needs_big_int_backfill_is_finished_for_self_hosts.rb b/db/post_migrate/20230613192703_ensure_ci_build_needs_big_int_backfill_is_finished_for_self_hosts.rb
new file mode 100644
index 00000000000..7616944567e
--- /dev/null
+++ b/db/post_migrate/20230613192703_ensure_ci_build_needs_big_int_backfill_is_finished_for_self_hosts.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class EnsureCiBuildNeedsBigIntBackfillIsFinishedForSelfHosts < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_ci
+
+ TABLE_NAME = 'ci_build_needs'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [['id'], ['id_convert_to_bigint']]
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230613192802_swap_ci_build_needs_to_big_int_for_self_hosts.rb b/db/post_migrate/20230613192802_swap_ci_build_needs_to_big_int_for_self_hosts.rb
new file mode 100644
index 00000000000..7533de86a2a
--- /dev/null
+++ b/db/post_migrate/20230613192802_swap_ci_build_needs_to_big_int_for_self_hosts.rb
@@ -0,0 +1,74 @@
+# frozen_string_literal: true
+
+class SwapCiBuildNeedsToBigIntForSelfHosts < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_build_needs'
+
+ def up
+ return if should_skip?
+ return if temporary_column_already_dropped?
+ return if columns_already_swapped?
+
+ swap
+ end
+
+ def down
+ return if should_skip?
+ return if temporary_column_already_dropped?
+ return unless columns_already_swapped?
+
+ swap
+ end
+
+ private
+
+ def swap
+ add_concurrent_index TABLE_NAME, :id_convert_to_bigint, unique: true, name:
+ 'index_ci_build_needs_on_id_convert_to_bigint'
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ execute "LOCK TABLE #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
+
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN id TO id_tmp"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN id_convert_to_bigint TO id"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN id_tmp TO id_convert_to_bigint"
+
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(
+ TABLE_NAME, connection: Ci::ApplicationRecord.connection
+ ).name(
+ :id, :id_convert_to_bigint
+ )
+
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ execute "ALTER SEQUENCE ci_build_needs_id_seq OWNED BY #{TABLE_NAME}.id"
+ change_column_default TABLE_NAME, :id, -> { "nextval('ci_build_needs_id_seq'::regclass)" }
+ change_column_default TABLE_NAME, :id_convert_to_bigint, 0
+
+ execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT ci_build_needs_pkey CASCADE"
+ rename_index TABLE_NAME, 'index_ci_build_needs_on_id_convert_to_bigint', 'ci_build_needs_pkey'
+ execute "ALTER TABLE #{TABLE_NAME} ADD CONSTRAINT ci_build_needs_pkey PRIMARY KEY USING INDEX ci_build_needs_pkey"
+ end
+ end
+
+ def should_skip?
+ com_or_dev_or_test_but_not_jh?
+ end
+
+ def columns_already_swapped?
+ table_columns = columns(TABLE_NAME)
+ column_id = table_columns.find { |c| c.name == 'id' }
+ column_id_convert_to_bigint = table_columns.find { |c| c.name == 'id_convert_to_bigint' }
+
+ column_id.sql_type == 'bigint' && column_id_convert_to_bigint.sql_type == 'integer'
+ end
+
+ def temporary_column_already_dropped?
+ table_columns = columns(TABLE_NAME)
+
+ !table_columns.find { |c| c.name == 'id_convert_to_bigint' }
+ end
+end
diff --git a/db/post_migrate/20230614181310_track_organization_deletions.rb b/db/post_migrate/20230614181310_track_organization_deletions.rb
new file mode 100644
index 00000000000..9e936d6d285
--- /dev/null
+++ b/db/post_migrate/20230614181310_track_organization_deletions.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class TrackOrganizationDeletions < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ # This LFK trigger already exists on some environments and it was reverted
+ # in MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122809
+ track_record_deletions(:organizations) unless has_loose_foreign_key?('organizations')
+ end
+
+ def down
+ untrack_record_deletions(:organizations)
+ end
+end
diff --git a/db/post_migrate/20230614182049_add_index_to_namespaces_organization_id.rb b/db/post_migrate/20230614182049_add_index_to_namespaces_organization_id.rb
new file mode 100644
index 00000000000..edbb0a8b953
--- /dev/null
+++ b/db/post_migrate/20230614182049_add_index_to_namespaces_organization_id.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexToNamespacesOrganizationId < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_namespaces_on_organization_id'
+ TABLE = :namespaces
+
+ disable_ddl_transaction!
+
+ # This index was added on GitLab SaaS in
+ # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/120822
+
+ def up
+ add_concurrent_index TABLE, :organization_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name TABLE, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230615030402_remove_audit_events_group_index.rb b/db/post_migrate/20230615030402_remove_audit_events_group_index.rb
new file mode 100644
index 00000000000..9a77d7a4d0d
--- /dev/null
+++ b/db/post_migrate/20230615030402_remove_audit_events_group_index.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class RemoveAuditEventsGroupIndex < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+
+ TABLE_NAME = :audit_events
+ COLUMN_NAMES = [:entity_id, :entity_type, :created_at, :id]
+ INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type_and_created_at'
+
+ # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/415424
+ def up
+ each_partition(TABLE_NAME) do |partition, partition_index_name|
+ unprepare_async_index_by_name(partition.identifier, partition_index_name)
+ end
+ end
+
+ def down
+ each_partition(TABLE_NAME) do |partition, partition_index_name|
+ prepare_async_index(
+ partition.identifier,
+ COLUMN_NAMES,
+ name: partition_index_name
+ )
+ end
+ end
+
+ private
+
+ def each_partition(table_name)
+ partitioned_table = find_partitioned_table(table_name)
+ partitioned_table.postgres_partitions.order(:name).each do |partition|
+ partition_index_name = generated_index_name(partition.identifier, INDEX_NAME)
+
+ yield partition, partition_index_name
+ end
+ end
+end
diff --git a/db/post_migrate/20230615113748_replace_ci_job_artifacts_foreign_key_v3.rb b/db/post_migrate/20230615113748_replace_ci_job_artifacts_foreign_key_v3.rb
new file mode 100644
index 00000000000..92b3008ff00
--- /dev/null
+++ b/db/post_migrate/20230615113748_replace_ci_job_artifacts_foreign_key_v3.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class ReplaceCiJobArtifactsForeignKeyV3 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ci_job_artifacts, :p_ci_builds,
+ name: 'temp_fk_rails_c5137cb2c1_p',
+ column: [:partition_id, :job_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+ end
+
+ def down
+ remove_foreign_key_if_exists :ci_job_artifacts, name: 'temp_fk_rails_c5137cb2c1_p'
+ end
+end
diff --git a/db/post_migrate/20230615113840_replace_ci_running_builds_foreign_key_v3.rb b/db/post_migrate/20230615113840_replace_ci_running_builds_foreign_key_v3.rb
new file mode 100644
index 00000000000..ef8f252bbf7
--- /dev/null
+++ b/db/post_migrate/20230615113840_replace_ci_running_builds_foreign_key_v3.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class ReplaceCiRunningBuildsForeignKeyV3 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ci_running_builds, :p_ci_builds,
+ name: 'temp_fk_rails_da45cfa165_p',
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+ end
+
+ def down
+ remove_foreign_key_if_exists :ci_running_builds, name: 'temp_fk_rails_da45cfa165_p'
+ end
+end
diff --git a/db/post_migrate/20230615113858_replace_ci_job_variables_foreign_key_v3.rb b/db/post_migrate/20230615113858_replace_ci_job_variables_foreign_key_v3.rb
new file mode 100644
index 00000000000..76c83c90ad0
--- /dev/null
+++ b/db/post_migrate/20230615113858_replace_ci_job_variables_foreign_key_v3.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class ReplaceCiJobVariablesForeignKeyV3 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ci_job_variables, :p_ci_builds,
+ name: 'temp_fk_rails_fbf3b34792_p',
+ column: [:partition_id, :job_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+ end
+
+ def down
+ remove_foreign_key_if_exists :ci_job_variables, name: 'temp_fk_rails_fbf3b34792_p'
+ end
+end
diff --git a/db/post_migrate/20230615121103_replace_p_ci_builds_metadata_foreign_key_v3.rb b/db/post_migrate/20230615121103_replace_p_ci_builds_metadata_foreign_key_v3.rb
new file mode 100644
index 00000000000..dca891fc064
--- /dev/null
+++ b/db/post_migrate/20230615121103_replace_p_ci_builds_metadata_foreign_key_v3.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplacePCiBuildsMetadataForeignKeyV3 < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+
+ add_concurrent_partitioned_foreign_key :p_ci_builds_metadata, :p_ci_builds,
+ name: :temp_fk_e20479742e_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+ end
+
+ def down
+ return unless should_run?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_builds_metadata, :p_ci_builds,
+ name: :temp_fk_e20479742e_p,
+ reverse_lock_order: true
+ end
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_builds_metadata, :ci_builds)
+ end
+end
diff --git a/db/post_migrate/20230615121122_replace_p_ci_runner_machine_builds_foreign_key_v3.rb b/db/post_migrate/20230615121122_replace_p_ci_runner_machine_builds_foreign_key_v3.rb
new file mode 100644
index 00000000000..854d7358e5e
--- /dev/null
+++ b/db/post_migrate/20230615121122_replace_p_ci_runner_machine_builds_foreign_key_v3.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplacePCiRunnerMachineBuildsForeignKeyV3 < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+
+ add_concurrent_partitioned_foreign_key :p_ci_runner_machine_builds, :p_ci_builds,
+ name: :temp_fk_bb490f12fe_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+ end
+
+ def down
+ return unless should_run?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_runner_machine_builds, :p_ci_builds,
+ name: :temp_fk_bb490f12fe_p,
+ reverse_lock_order: true
+ end
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_builds)
+ end
+end
diff --git a/db/post_migrate/20230615144627_remove_temporary_container_repository_indexes.rb b/db/post_migrate/20230615144627_remove_temporary_container_repository_indexes.rb
new file mode 100644
index 00000000000..c4d01f35607
--- /dev/null
+++ b/db/post_migrate/20230615144627_remove_temporary_container_repository_indexes.rb
@@ -0,0 +1,82 @@
+# frozen_string_literal: true
+
+class RemoveTemporaryContainerRepositoryIndexes < Gitlab::Database::Migration[2.1]
+ INDEX_CONTAINER_REPOS_ON_NON_MIGRATED = 'tmp_index_container_repos_on_non_migrated'
+ INDEX_CONTAINER_REPOSITORIES_ON_ID_MIGRATION_STATE = 'tmp_index_container_repositories_on_id_migration_state'
+ INDEX_MIGRATED_CONTAINER_REGISTRIES = 'tmp_index_migrated_container_registries'
+ INDEX_CONTAINER_REPOS_ON_IMPORT_STARTED_AT_WHEN_IMPORTING = 'idx_container_repos_on_import_started_at_when_importing'
+ INDEX_CONTAINER_REPOS_ON_MIGRATION_STATE_MIGRATION_PLAN_CREATED =
+ 'idx_container_repos_on_migration_state_migration_plan_created'
+ INDEX_CONTAINER_REPOS_ON_PRE_IMPORT_DONE_AT_WHEN_PRE_IMPORT_DONE =
+ 'idx_container_repos_on_pre_import_done_at_when_pre_import_done'
+ INDEX_CONTAINER_REPOS_ON_PRE_IMPORT_STARTED_AT_WHEN_PRE_IMPORTING =
+ 'idx_container_repos_on_pre_import_started_at_when_pre_importing'
+ INDEX_CONTAINER_REPOSITORIES_ON_GREATEST_COMPLETED_AT = 'index_container_repositories_on_greatest_completed_at'
+ INDEX_CONTAINER_REPOSITORIES_ON_MIGRATION_STATE_IMPORT_DONE_AT =
+ 'index_container_repositories_on_migration_state_import_done_at'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :container_repositories, INDEX_CONTAINER_REPOS_ON_NON_MIGRATED
+ remove_concurrent_index_by_name :container_repositories, INDEX_CONTAINER_REPOSITORIES_ON_ID_MIGRATION_STATE
+ remove_concurrent_index_by_name :container_repositories, INDEX_MIGRATED_CONTAINER_REGISTRIES
+ remove_concurrent_index_by_name :container_repositories, INDEX_CONTAINER_REPOS_ON_IMPORT_STARTED_AT_WHEN_IMPORTING
+ remove_concurrent_index_by_name :container_repositories,
+ INDEX_CONTAINER_REPOS_ON_MIGRATION_STATE_MIGRATION_PLAN_CREATED
+ remove_concurrent_index_by_name :container_repositories,
+ INDEX_CONTAINER_REPOS_ON_PRE_IMPORT_DONE_AT_WHEN_PRE_IMPORT_DONE
+ remove_concurrent_index_by_name :container_repositories,
+ INDEX_CONTAINER_REPOS_ON_PRE_IMPORT_STARTED_AT_WHEN_PRE_IMPORTING
+ remove_concurrent_index_by_name :container_repositories, INDEX_CONTAINER_REPOSITORIES_ON_GREATEST_COMPLETED_AT
+ remove_concurrent_index_by_name :container_repositories,
+ INDEX_CONTAINER_REPOSITORIES_ON_MIGRATION_STATE_IMPORT_DONE_AT
+ end
+
+ def down
+ add_concurrent_index :container_repositories,
+ [:project_id, :id],
+ name: INDEX_CONTAINER_REPOS_ON_NON_MIGRATED,
+ where: "migration_state != 'import_done'"
+
+ add_concurrent_index :container_repositories,
+ [:id, :migration_state],
+ name: INDEX_CONTAINER_REPOSITORIES_ON_ID_MIGRATION_STATE
+
+ add_concurrent_index :container_repositories,
+ [:project_id],
+ name: INDEX_MIGRATED_CONTAINER_REGISTRIES,
+ where: "migration_state = 'import_done' OR created_at >= '2022-01-23'"
+
+ add_concurrent_index :container_repositories,
+ [:migration_import_started_at],
+ name: INDEX_CONTAINER_REPOS_ON_IMPORT_STARTED_AT_WHEN_IMPORTING,
+ where: "migration_state = 'importing'::text"
+
+ add_concurrent_index :container_repositories,
+ [:migration_state, :migration_plan, :created_at],
+ name: INDEX_CONTAINER_REPOS_ON_MIGRATION_STATE_MIGRATION_PLAN_CREATED
+
+ add_concurrent_index :container_repositories,
+ [:migration_pre_import_done_at],
+ name: INDEX_CONTAINER_REPOS_ON_PRE_IMPORT_DONE_AT_WHEN_PRE_IMPORT_DONE,
+ where: "migration_state = 'pre_import_done'::text"
+
+ add_concurrent_index :container_repositories,
+ [:migration_pre_import_started_at],
+ name: INDEX_CONTAINER_REPOS_ON_PRE_IMPORT_STARTED_AT_WHEN_PRE_IMPORTING,
+ where: "migration_state = 'pre_importing'::text"
+
+ execute(
+ <<-SQL
+ CREATE INDEX CONCURRENTLY #{INDEX_CONTAINER_REPOSITORIES_ON_GREATEST_COMPLETED_AT} ON container_repositories
+ USING btree (GREATEST(migration_pre_import_done_at, migration_import_done_at, migration_aborted_at, migration_skipped_at))
+ WHERE (migration_state = ANY (ARRAY['import_done'::text, 'pre_import_done'::text, 'import_aborted'::text, 'import_skipped'::text]));
+ SQL
+ )
+
+ add_concurrent_index :container_repositories,
+ [:migration_state, :migration_import_done_at],
+ name: INDEX_CONTAINER_REPOSITORIES_ON_MIGRATION_STATE_IMPORT_DONE_AT
+ end
+end
diff --git a/db/post_migrate/20230616082958_add_unique_index_for_npm_packages_on_project_id_name_version.rb b/db/post_migrate/20230616082958_add_unique_index_for_npm_packages_on_project_id_name_version.rb
new file mode 100644
index 00000000000..646bbf414e2
--- /dev/null
+++ b/db/post_migrate/20230616082958_add_unique_index_for_npm_packages_on_project_id_name_version.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexForNpmPackagesOnProjectIdNameVersion < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'idx_packages_on_project_id_name_version_unique_when_npm'
+ PACKAGE_TYPE_NPM = 2
+
+ def up
+ add_concurrent_index(
+ :packages_packages,
+ %i[project_id name version],
+ name: INDEX_NAME,
+ unique: true,
+ where: "package_type = #{PACKAGE_TYPE_NPM} AND status <> 4"
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_packages, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230618020202_finish_user_type_migration.rb b/db/post_migrate/20230618020202_finish_user_type_migration.rb
new file mode 100644
index 00000000000..4a729d5d408
--- /dev/null
+++ b/db/post_migrate/20230618020202_finish_user_type_migration.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class FinishUserTypeMigration < Gitlab::Database::Migration[2.1]
+ MIGRATION = 'MigrateHumanUserType'
+
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: MIGRATION,
+ table_name: :users,
+ column_name: :id,
+ job_arguments: []
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230619005223_change_unconfirmed_created_at_index_on_users.rb b/db/post_migrate/20230619005223_change_unconfirmed_created_at_index_on_users.rb
new file mode 100644
index 00000000000..5b9b4e36512
--- /dev/null
+++ b/db/post_migrate/20230619005223_change_unconfirmed_created_at_index_on_users.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class ChangeUnconfirmedCreatedAtIndexOnUsers < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ OLD_INDEX_NAME = 'index_users_on_unconfirmed_and_created_at_for_active_humans'
+ NEW_INDEX_NAME = 'index_users_on_unconfirmed_created_at_active_type_sign_in_count'
+
+ def up
+ add_concurrent_index :users, [:created_at, :id],
+ name: NEW_INDEX_NAME,
+ where: "confirmed_at IS NULL AND state = 'active' AND user_type IN (0) AND sign_in_count = 0"
+
+ remove_concurrent_index_by_name :users, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :users, [:created_at, :id],
+ name: OLD_INDEX_NAME,
+ where: "confirmed_at IS NULL AND state = 'active' AND user_type IN (0)"
+
+ remove_concurrent_index_by_name :users, NEW_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230619072744_schedule_index_events_on_project_id_and_id_desc_on_merged_action_for_removal.rb b/db/post_migrate/20230619072744_schedule_index_events_on_project_id_and_id_desc_on_merged_action_for_removal.rb
new file mode 100644
index 00000000000..b73ddfffad6
--- /dev/null
+++ b/db/post_migrate/20230619072744_schedule_index_events_on_project_id_and_id_desc_on_merged_action_for_removal.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ScheduleIndexEventsOnProjectIdAndIdDescOnMergedActionForRemoval < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_events_on_project_id_and_id_desc_on_merged_action'
+
+ # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/415091
+
+ def up
+ prepare_async_index_removal :events, [:project_id, :id], order: { id: :desc },
+ where: "action = 7", name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :events, [:project_id, :id], order: { id: :desc },
+ where: "action = 7", name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230619081412_add_index_to_ci_triggers_token.rb b/db/post_migrate/20230619081412_add_index_to_ci_triggers_token.rb
new file mode 100644
index 00000000000..861c9eafd9f
--- /dev/null
+++ b/db/post_migrate/20230619081412_add_index_to_ci_triggers_token.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToCiTriggersToken < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_triggers_on_token'
+
+ def up
+ add_concurrent_index :ci_triggers, :token, unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name(:ci_triggers, INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20230619123701_schedule_removal_index_job_artifacts_id_and_expire_at.rb b/db/post_migrate/20230619123701_schedule_removal_index_job_artifacts_id_and_expire_at.rb
new file mode 100644
index 00000000000..0473032bb98
--- /dev/null
+++ b/db/post_migrate/20230619123701_schedule_removal_index_job_artifacts_id_and_expire_at.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ScheduleRemovalIndexJobArtifactsIdAndExpireAt < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = :tmp_index_ci_job_artifacts_on_id_expire_at_file_type_trace
+ TABLE_NAME = :ci_job_artifacts
+ COLUMN = :id
+
+ # Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/368979
+ def up
+ prepare_async_index_removal(TABLE_NAME, COLUMN, name: INDEX_NAME)
+ end
+
+ def down
+ unprepare_async_index(TABLE_NAME, COLUMN, name: INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20230619134106_prepare_index_for_vulnerability_reads_on_common_project_filters.rb b/db/post_migrate/20230619134106_prepare_index_for_vulnerability_reads_on_common_project_filters.rb
new file mode 100644
index 00000000000..60335f572d5
--- /dev/null
+++ b/db/post_migrate/20230619134106_prepare_index_for_vulnerability_reads_on_common_project_filters.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class PrepareIndexForVulnerabilityReadsOnCommonProjectFilters < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_project_vulnerability_reads_common_finder_query_desc'
+
+ def up
+ prepare_async_index :vulnerability_reads,
+ [:project_id, :state, :report_type, :severity, :vulnerability_id],
+ order: { severity: :desc, vulnerability_id: :desc },
+ name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230620072854_replace_old_fk_ci_build_pending_states_to_builds_v2.rb b/db/post_migrate/20230620072854_replace_old_fk_ci_build_pending_states_to_builds_v2.rb
new file mode 100644
index 00000000000..dd6acb8a365
--- /dev/null
+++ b/db/post_migrate/20230620072854_replace_old_fk_ci_build_pending_states_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiBuildPendingStatesToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_build_pending_states, :ci_builds,
+ name: :fk_861cd17da3_p, reverse_lock_order: true
+
+ rename_constraint :ci_build_pending_states, :temp_fk_861cd17da3_p, :fk_861cd17da3_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_build_pending_states, :ci_builds,
+ name: :temp_fk_861cd17da3_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_build_pending_states, :fk_861cd17da3_p, :temp_fk_861cd17da3_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_build_pending_states, :p_ci_builds, name: :fk_861cd17da3_p)
+ end
+end
diff --git a/db/post_migrate/20230620072856_replace_old_fk_ci_build_trace_chunks_to_builds_v2.rb b/db/post_migrate/20230620072856_replace_old_fk_ci_build_trace_chunks_to_builds_v2.rb
new file mode 100644
index 00000000000..d715ba11500
--- /dev/null
+++ b/db/post_migrate/20230620072856_replace_old_fk_ci_build_trace_chunks_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiBuildTraceChunksToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_build_trace_chunks, :ci_builds,
+ name: :fk_89e29fa5ee_p, reverse_lock_order: true
+
+ rename_constraint :ci_build_trace_chunks, :temp_fk_89e29fa5ee_p, :fk_89e29fa5ee_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_build_trace_chunks, :ci_builds,
+ name: :temp_fk_89e29fa5ee_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_build_trace_chunks, :fk_89e29fa5ee_p, :temp_fk_89e29fa5ee_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_build_trace_chunks, :p_ci_builds, name: :fk_89e29fa5ee_p)
+ end
+end
diff --git a/db/post_migrate/20230620072900_replace_old_fk_ci_unit_test_failures_to_builds_v2.rb b/db/post_migrate/20230620072900_replace_old_fk_ci_unit_test_failures_to_builds_v2.rb
new file mode 100644
index 00000000000..fe305ccd29d
--- /dev/null
+++ b/db/post_migrate/20230620072900_replace_old_fk_ci_unit_test_failures_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiUnitTestFailuresToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_unit_test_failures, :ci_builds,
+ name: :fk_9e0fc58930_p, reverse_lock_order: true
+
+ rename_constraint :ci_unit_test_failures, :temp_fk_9e0fc58930_p, :fk_9e0fc58930_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_unit_test_failures, :ci_builds,
+ name: :temp_fk_9e0fc58930_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_unit_test_failures, :fk_9e0fc58930_p, :temp_fk_9e0fc58930_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_unit_test_failures, :p_ci_builds, name: :fk_9e0fc58930_p)
+ end
+end
diff --git a/db/post_migrate/20230620072905_replace_old_fk_ci_sources_pipelines_to_builds_v2.rb b/db/post_migrate/20230620072905_replace_old_fk_ci_sources_pipelines_to_builds_v2.rb
new file mode 100644
index 00000000000..44a24182382
--- /dev/null
+++ b/db/post_migrate/20230620072905_replace_old_fk_ci_sources_pipelines_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiSourcesPipelinesToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_sources_pipelines, :ci_builds,
+ name: :fk_be5624bf37_p, reverse_lock_order: true
+
+ rename_constraint :ci_sources_pipelines, :temp_fk_be5624bf37_p, :fk_be5624bf37_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_sources_pipelines, :ci_builds,
+ name: :temp_fk_be5624bf37_p,
+ column: [:source_partition_id, :source_job_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_sources_pipelines, :fk_be5624bf37_p, :temp_fk_be5624bf37_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_sources_pipelines, :p_ci_builds, name: :fk_be5624bf37_p)
+ end
+end
diff --git a/db/post_migrate/20230620072908_replace_old_fk_ci_resources_to_builds_v2.rb b/db/post_migrate/20230620072908_replace_old_fk_ci_resources_to_builds_v2.rb
new file mode 100644
index 00000000000..ad4773f5b9d
--- /dev/null
+++ b/db/post_migrate/20230620072908_replace_old_fk_ci_resources_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiResourcesToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_resources, :ci_builds,
+ name: :fk_e169a8e3d5_p, reverse_lock_order: true
+
+ rename_constraint :ci_resources, :temp_fk_e169a8e3d5_p, :fk_e169a8e3d5_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_resources, :ci_builds,
+ name: :temp_fk_e169a8e3d5_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :nullify,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_resources, :fk_e169a8e3d5_p, :temp_fk_e169a8e3d5_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_resources, :p_ci_builds, name: :fk_e169a8e3d5_p)
+ end
+end
diff --git a/db/post_migrate/20230620072911_replace_old_fk_ci_build_report_results_to_builds_v2.rb b/db/post_migrate/20230620072911_replace_old_fk_ci_build_report_results_to_builds_v2.rb
new file mode 100644
index 00000000000..f7d5e703e61
--- /dev/null
+++ b/db/post_migrate/20230620072911_replace_old_fk_ci_build_report_results_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiBuildReportResultsToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_build_report_results, :ci_builds,
+ name: :fk_rails_16cb1ff064_p, reverse_lock_order: true
+
+ rename_constraint :ci_build_report_results, :temp_fk_rails_16cb1ff064_p, :fk_rails_16cb1ff064_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_build_report_results, :ci_builds,
+ name: :temp_fk_rails_16cb1ff064_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_build_report_results, :fk_rails_16cb1ff064_p, :temp_fk_rails_16cb1ff064_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_build_report_results, :p_ci_builds, name: :fk_rails_16cb1ff064_p)
+ end
+end
diff --git a/db/post_migrate/20230620072915_replace_old_fk_ci_build_needs_to_builds_v2.rb b/db/post_migrate/20230620072915_replace_old_fk_ci_build_needs_to_builds_v2.rb
new file mode 100644
index 00000000000..a6f93eee035
--- /dev/null
+++ b/db/post_migrate/20230620072915_replace_old_fk_ci_build_needs_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiBuildNeedsToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_build_needs, :ci_builds,
+ name: :fk_rails_3cf221d4ed_p, reverse_lock_order: true
+
+ rename_constraint :ci_build_needs, :temp_fk_rails_3cf221d4ed_p, :fk_rails_3cf221d4ed_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_build_needs, :ci_builds,
+ name: :temp_fk_rails_3cf221d4ed_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_build_needs, :fk_rails_3cf221d4ed_p, :temp_fk_rails_3cf221d4ed_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_build_needs, :p_ci_builds, name: :fk_rails_3cf221d4ed_p)
+ end
+end
diff --git a/db/post_migrate/20230620072917_replace_old_fk_ci_builds_runner_session_to_builds_v2.rb b/db/post_migrate/20230620072917_replace_old_fk_ci_builds_runner_session_to_builds_v2.rb
new file mode 100644
index 00000000000..01b9bbee633
--- /dev/null
+++ b/db/post_migrate/20230620072917_replace_old_fk_ci_builds_runner_session_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiBuildsRunnerSessionToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_builds_runner_session, :ci_builds,
+ name: :fk_rails_70707857d3_p, reverse_lock_order: true
+
+ rename_constraint :ci_builds_runner_session, :temp_fk_rails_70707857d3_p, :fk_rails_70707857d3_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_builds_runner_session, :ci_builds,
+ name: :temp_fk_rails_70707857d3_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_builds_runner_session, :fk_rails_70707857d3_p, :temp_fk_rails_70707857d3_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_builds_runner_session, :p_ci_builds, name: :fk_rails_70707857d3_p)
+ end
+end
diff --git a/db/post_migrate/20230620072920_replace_old_fk_ci_pending_builds_to_builds_v2.rb b/db/post_migrate/20230620072920_replace_old_fk_ci_pending_builds_to_builds_v2.rb
new file mode 100644
index 00000000000..4861bb646f5
--- /dev/null
+++ b/db/post_migrate/20230620072920_replace_old_fk_ci_pending_builds_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiPendingBuildsToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_pending_builds, :ci_builds,
+ name: :fk_rails_725a2644a3_p, reverse_lock_order: true
+
+ rename_constraint :ci_pending_builds, :temp_fk_rails_725a2644a3_p, :fk_rails_725a2644a3_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_pending_builds, :ci_builds,
+ name: :temp_fk_rails_725a2644a3_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_pending_builds, :fk_rails_725a2644a3_p, :temp_fk_rails_725a2644a3_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_pending_builds, :p_ci_builds, name: :fk_rails_725a2644a3_p)
+ end
+end
diff --git a/db/post_migrate/20230620072925_replace_old_fk_ci_build_trace_metadata_to_builds_v2.rb b/db/post_migrate/20230620072925_replace_old_fk_ci_build_trace_metadata_to_builds_v2.rb
new file mode 100644
index 00000000000..be004eb5121
--- /dev/null
+++ b/db/post_migrate/20230620072925_replace_old_fk_ci_build_trace_metadata_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiBuildTraceMetadataToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_build_trace_metadata, :ci_builds,
+ name: :fk_rails_aebc78111f_p, reverse_lock_order: true
+
+ rename_constraint :ci_build_trace_metadata, :temp_fk_rails_aebc78111f_p, :fk_rails_aebc78111f_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_build_trace_metadata, :ci_builds,
+ name: :temp_fk_rails_aebc78111f_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_build_trace_metadata, :fk_rails_aebc78111f_p, :temp_fk_rails_aebc78111f_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_build_trace_metadata, :p_ci_builds, name: :fk_rails_aebc78111f_p)
+ end
+end
diff --git a/db/post_migrate/20230620105919_replace_old_fk_ci_job_artifacts_to_builds.rb b/db/post_migrate/20230620105919_replace_old_fk_ci_job_artifacts_to_builds.rb
new file mode 100644
index 00000000000..33aca3bc858
--- /dev/null
+++ b/db/post_migrate/20230620105919_replace_old_fk_ci_job_artifacts_to_builds.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiJobArtifactsToBuilds < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_job_artifacts, :ci_builds,
+ name: :fk_rails_c5137cb2c1_p, reverse_lock_order: true
+
+ rename_constraint :ci_job_artifacts, :temp_fk_rails_c5137cb2c1_p, :fk_rails_c5137cb2c1_p
+ end
+ end
+
+ def down
+ return unless should_run?
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_job_artifacts, :ci_builds,
+ name: :temp_fk_rails_c5137cb2c1_p,
+ column: [:partition_id, :job_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_job_artifacts, :fk_rails_c5137cb2c1_p, :temp_fk_rails_c5137cb2c1_p
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_job_artifacts, :ci_builds)
+ end
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_job_artifacts, :p_ci_builds, name: :fk_rails_c5137cb2c1_p)
+ end
+end
diff --git a/db/post_migrate/20230620110004_replace_old_fk_ci_running_builds_to_builds.rb b/db/post_migrate/20230620110004_replace_old_fk_ci_running_builds_to_builds.rb
new file mode 100644
index 00000000000..77a6e24f4fa
--- /dev/null
+++ b/db/post_migrate/20230620110004_replace_old_fk_ci_running_builds_to_builds.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiRunningBuildsToBuilds < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_running_builds, :ci_builds,
+ name: :fk_rails_da45cfa165_p, reverse_lock_order: true
+
+ rename_constraint :ci_running_builds, :temp_fk_rails_da45cfa165_p, :fk_rails_da45cfa165_p
+ end
+ end
+
+ def down
+ return unless should_run?
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_running_builds, :ci_builds,
+ name: :temp_fk_rails_da45cfa165_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_running_builds, :fk_rails_da45cfa165_p, :temp_fk_rails_da45cfa165_p
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_running_builds, :ci_builds)
+ end
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_running_builds, :p_ci_builds, name: :fk_rails_da45cfa165_p)
+ end
+end
diff --git a/db/post_migrate/20230620110021_replace_old_fk_ci_job_variables_to_builds.rb b/db/post_migrate/20230620110021_replace_old_fk_ci_job_variables_to_builds.rb
new file mode 100644
index 00000000000..9d90c03d38a
--- /dev/null
+++ b/db/post_migrate/20230620110021_replace_old_fk_ci_job_variables_to_builds.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiJobVariablesToBuilds < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_job_variables, :ci_builds,
+ name: :fk_rails_fbf3b34792_p, reverse_lock_order: true
+
+ rename_constraint :ci_job_variables, :temp_fk_rails_fbf3b34792_p, :fk_rails_fbf3b34792_p
+ end
+ end
+
+ def down
+ return unless should_run?
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_job_variables, :ci_builds,
+ name: :temp_fk_rails_fbf3b34792_p,
+ column: [:partition_id, :job_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_job_variables, :fk_rails_fbf3b34792_p, :temp_fk_rails_fbf3b34792_p
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_job_variables, :ci_builds)
+ end
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_job_variables, :p_ci_builds, name: :fk_rails_fbf3b34792_p)
+ end
+end
diff --git a/db/post_migrate/20230620134708_validate_user_type_constraint.rb b/db/post_migrate/20230620134708_validate_user_type_constraint.rb
new file mode 100644
index 00000000000..cf06e3562d5
--- /dev/null
+++ b/db/post_migrate/20230620134708_validate_user_type_constraint.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ValidateUserTypeConstraint < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ validate_not_null_constraint(:users, :user_type)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230620201738_add_index_issues_on_project_health_status_asc_work_item_type.rb b/db/post_migrate/20230620201738_add_index_issues_on_project_health_status_asc_work_item_type.rb
new file mode 100644
index 00000000000..a1777baa1c2
--- /dev/null
+++ b/db/post_migrate/20230620201738_add_index_issues_on_project_health_status_asc_work_item_type.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexIssuesOnProjectHealthStatusAscWorkItemType < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_issues_on_project_health_status_asc_work_item_type'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :issues,
+ [:project_id, :health_status, :id, :state_id, :work_item_type_id],
+ order: { health_status: 'ASC NULLS LAST', id: :desc },
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230620201817_add_index_issues_on_project_health_status_desc_work_item_type.rb b/db/post_migrate/20230620201817_add_index_issues_on_project_health_status_desc_work_item_type.rb
new file mode 100644
index 00000000000..7eaa85bff56
--- /dev/null
+++ b/db/post_migrate/20230620201817_add_index_issues_on_project_health_status_desc_work_item_type.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexIssuesOnProjectHealthStatusDescWorkItemType < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_issues_on_project_health_status_desc_work_item_type'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :issues,
+ [:project_id, :health_status, :id, :state_id, :work_item_type_id],
+ order: { health_status: 'DESC NULLS LAST', id: :desc },
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230621072848_add_text_limit_to_ci_variable_description.rb b/db/post_migrate/20230621072848_add_text_limit_to_ci_variable_description.rb
new file mode 100644
index 00000000000..485ac8bae61
--- /dev/null
+++ b/db/post_migrate/20230621072848_add_text_limit_to_ci_variable_description.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTextLimitToCiVariableDescription < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE_NAME = :ci_variables
+ COLUMN_NAME = :description
+
+ def up
+ add_text_limit(TABLE_NAME, COLUMN_NAME, 255)
+ end
+
+ def down
+ remove_text_limit(TABLE_NAME, COLUMN_NAME)
+ end
+end
diff --git a/db/post_migrate/20230621083052_add_text_limit_to_ci_group_variable_description.rb b/db/post_migrate/20230621083052_add_text_limit_to_ci_group_variable_description.rb
new file mode 100644
index 00000000000..b0a5a3d539b
--- /dev/null
+++ b/db/post_migrate/20230621083052_add_text_limit_to_ci_group_variable_description.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTextLimitToCiGroupVariableDescription < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE_NAME = :ci_group_variables
+ COLUMN_NAME = :description
+
+ def up
+ add_text_limit(TABLE_NAME, COLUMN_NAME, 255)
+ end
+
+ def down
+ remove_text_limit(TABLE_NAME, COLUMN_NAME)
+ end
+end
diff --git a/db/post_migrate/20230621102941_replace_old_fk_ci_job_artifacts_to_builds_v2.rb b/db/post_migrate/20230621102941_replace_old_fk_ci_job_artifacts_to_builds_v2.rb
new file mode 100644
index 00000000000..416b1c629c0
--- /dev/null
+++ b/db/post_migrate/20230621102941_replace_old_fk_ci_job_artifacts_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiJobArtifactsToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_job_artifacts, :ci_builds,
+ name: :fk_rails_c5137cb2c1_p, reverse_lock_order: true
+
+ rename_constraint :ci_job_artifacts, :temp_fk_rails_c5137cb2c1_p, :fk_rails_c5137cb2c1_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_job_artifacts, :ci_builds,
+ name: :temp_fk_rails_c5137cb2c1_p,
+ column: [:partition_id, :job_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_job_artifacts, :fk_rails_c5137cb2c1_p, :temp_fk_rails_c5137cb2c1_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_job_artifacts, :p_ci_builds, name: :fk_rails_c5137cb2c1_p)
+ end
+end
diff --git a/db/post_migrate/20230621103000_replace_old_fk_ci_running_builds_to_builds_v2.rb b/db/post_migrate/20230621103000_replace_old_fk_ci_running_builds_to_builds_v2.rb
new file mode 100644
index 00000000000..32702eceb17
--- /dev/null
+++ b/db/post_migrate/20230621103000_replace_old_fk_ci_running_builds_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiRunningBuildsToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_running_builds, :ci_builds,
+ name: :fk_rails_da45cfa165_p, reverse_lock_order: true
+
+ rename_constraint :ci_running_builds, :temp_fk_rails_da45cfa165_p, :fk_rails_da45cfa165_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_running_builds, :ci_builds,
+ name: :temp_fk_rails_da45cfa165_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_running_builds, :fk_rails_da45cfa165_p, :temp_fk_rails_da45cfa165_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_running_builds, :p_ci_builds, name: :fk_rails_da45cfa165_p)
+ end
+end
diff --git a/db/post_migrate/20230621103043_replace_old_fk_ci_job_variables_to_builds_v2.rb b/db/post_migrate/20230621103043_replace_old_fk_ci_job_variables_to_builds_v2.rb
new file mode 100644
index 00000000000..68ae3dc56af
--- /dev/null
+++ b/db/post_migrate/20230621103043_replace_old_fk_ci_job_variables_to_builds_v2.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkCiJobVariablesToBuildsV2 < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :ci_job_variables, :ci_builds,
+ name: :fk_rails_fbf3b34792_p, reverse_lock_order: true
+
+ rename_constraint :ci_job_variables, :temp_fk_rails_fbf3b34792_p, :fk_rails_fbf3b34792_p
+ end
+ end
+
+ def down
+ return unless new_foreign_key_exists?
+
+ add_concurrent_foreign_key :ci_job_variables, :ci_builds,
+ name: :temp_fk_rails_fbf3b34792_p,
+ column: [:partition_id, :job_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :ci_job_variables, :fk_rails_fbf3b34792_p, :temp_fk_rails_fbf3b34792_p
+ end
+
+ private
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:ci_job_variables, :p_ci_builds, name: :fk_rails_fbf3b34792_p)
+ end
+end
diff --git a/db/post_migrate/20230622052046_remove_ci_pipeline_variables_trigger_and_old_column.rb b/db/post_migrate/20230622052046_remove_ci_pipeline_variables_trigger_and_old_column.rb
new file mode 100644
index 00000000000..81ce42c3aab
--- /dev/null
+++ b/db/post_migrate/20230622052046_remove_ci_pipeline_variables_trigger_and_old_column.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class RemoveCiPipelineVariablesTriggerAndOldColumn < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ TABLE = :ci_pipeline_variables
+ COLUMNS = [:id]
+
+ def up
+ cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+end
diff --git a/db/post_migrate/20230622073752_ensure_backfill_ci_pipelines_bigint_id_is_completed.rb b/db/post_migrate/20230622073752_ensure_backfill_ci_pipelines_bigint_id_is_completed.rb
new file mode 100644
index 00000000000..56aeafc0a66
--- /dev/null
+++ b/db/post_migrate/20230622073752_ensure_backfill_ci_pipelines_bigint_id_is_completed.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class EnsureBackfillCiPipelinesBigintIdIsCompleted < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_ci
+ disable_ddl_transaction!
+
+ TABLE_NAME = :ci_pipelines
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [['id'], ['id_convert_to_bigint']]
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230623073906_prepare_async_index_for_ci_pipelines_bigint_id.rb b/db/post_migrate/20230623073906_prepare_async_index_for_ci_pipelines_bigint_id.rb
new file mode 100644
index 00000000000..57d4e37ca7c
--- /dev/null
+++ b/db/post_migrate/20230623073906_prepare_async_index_for_ci_pipelines_bigint_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class PrepareAsyncIndexForCiPipelinesBigintId < Gitlab::Database::Migration[2.1]
+ TABLE_NAME = :ci_pipelines
+ INDEX_NAME = "index_#{TABLE_NAME}_on_id_convert_to_bigint"
+
+ # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/397000
+ def up
+ prepare_async_index TABLE_NAME, :id_convert_to_bigint, unique: true, name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index TABLE_NAME, :id_convert_to_bigint, unique: true, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230626070723_drop_unused_sent_notification_columns.rb b/db/post_migrate/20230626070723_drop_unused_sent_notification_columns.rb
new file mode 100644
index 00000000000..82a125c1ff5
--- /dev/null
+++ b/db/post_migrate/20230626070723_drop_unused_sent_notification_columns.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropUnusedSentNotificationColumns < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ remove_column :sent_notifications, :line_code
+ remove_column :sent_notifications, :note_type
+ remove_column :sent_notifications, :position
+ end
+
+ def down
+ add_column :sent_notifications, :line_code, :string
+ add_column :sent_notifications, :note_type, :string
+ add_column :sent_notifications, :position, :text
+ end
+end
diff --git a/db/post_migrate/20230626072436_drop_tmp_index_job_artifacts_id_and_expire_at.rb b/db/post_migrate/20230626072436_drop_tmp_index_job_artifacts_id_and_expire_at.rb
new file mode 100644
index 00000000000..3b986a0dc5d
--- /dev/null
+++ b/db/post_migrate/20230626072436_drop_tmp_index_job_artifacts_id_and_expire_at.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class DropTmpIndexJobArtifactsIdAndExpireAt < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE_NAME = :ci_job_artifacts
+ INDEX_NAME = :tmp_index_ci_job_artifacts_on_id_expire_at_file_type_trace
+
+ EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE = <<~SQL
+ (EXTRACT(day FROM timezone('UTC', expire_at)) IN (21, 22, 23)
+ AND EXTRACT(minute FROM timezone('UTC', expire_at)) IN (0, 30, 45)
+ AND EXTRACT(second FROM timezone('UTC', expire_at)) = 0)
+ OR file_type = 3
+ SQL
+
+ def up
+ remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(
+ TABLE_NAME,
+ :id,
+ where: EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE,
+ name: INDEX_NAME
+ )
+ end
+end
diff --git a/db/post_migrate/20230626101519_create_index_for_vulnerability_reads_on_common_project_filters.rb b/db/post_migrate/20230626101519_create_index_for_vulnerability_reads_on_common_project_filters.rb
new file mode 100644
index 00000000000..209a2295f22
--- /dev/null
+++ b/db/post_migrate/20230626101519_create_index_for_vulnerability_reads_on_common_project_filters.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateIndexForVulnerabilityReadsOnCommonProjectFilters < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_project_vulnerability_reads_common_finder_query_desc'
+
+ def up
+ add_concurrent_index :vulnerability_reads,
+ [:project_id, :state, :report_type, :severity, :vulnerability_id],
+ order: { severity: :desc, vulnerability_id: :desc },
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230626115046_add_temporary_index_on_vulnerability_reads.rb b/db/post_migrate/20230626115046_add_temporary_index_on_vulnerability_reads.rb
new file mode 100644
index 00000000000..8aa5cff2b96
--- /dev/null
+++ b/db/post_migrate/20230626115046_add_temporary_index_on_vulnerability_reads.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddTemporaryIndexOnVulnerabilityReads < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = "tmp_idx_vuln_reads_where_dismissal_reason_null"
+ DISMISSED_STATE = 2
+
+ def up
+ add_concurrent_index(
+ :vulnerability_reads,
+ %i[id],
+ where: "state = #{DISMISSED_STATE} AND dismissal_reason IS NULL",
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name(
+ :vulnerability_reads,
+ INDEX_NAME
+ )
+ end
+end
diff --git a/db/post_migrate/20230627115305_replace_p_ci_builds_metadata_foreign_key_v4.rb b/db/post_migrate/20230627115305_replace_p_ci_builds_metadata_foreign_key_v4.rb
new file mode 100644
index 00000000000..cb5a5c96b3c
--- /dev/null
+++ b/db/post_migrate/20230627115305_replace_p_ci_builds_metadata_foreign_key_v4.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+class ReplacePCiBuildsMetadataForeignKeyV4 < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if foreign_key_exists?(:p_ci_builds_metadata, :p_ci_builds, name: :temp_fk_e20479742e_p)
+
+ with_lock_retries do
+ execute(<<~SQL.squish)
+ LOCK TABLE ci_builds, p_ci_builds, p_ci_builds_metadata IN ACCESS EXCLUSIVE MODE;
+
+ ALTER TABLE p_ci_builds_metadata
+ ADD CONSTRAINT temp_fk_e20479742e_p
+ FOREIGN KEY (partition_id, build_id)
+ REFERENCES p_ci_builds (partition_id, id)
+ ON UPDATE CASCADE ON DELETE CASCADE;
+ SQL
+ end
+ end
+
+ def down
+ return unless should_run?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_builds_metadata, :p_ci_builds,
+ name: :temp_fk_e20479742e_p,
+ reverse_lock_order: true
+ end
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_builds_metadata, :ci_builds)
+ end
+end
diff --git a/db/post_migrate/20230627140707_async_index_for_vulnerabilities_uuid_type_migration.rb b/db/post_migrate/20230627140707_async_index_for_vulnerabilities_uuid_type_migration.rb
new file mode 100644
index 00000000000..cfca60eb02c
--- /dev/null
+++ b/db/post_migrate/20230627140707_async_index_for_vulnerabilities_uuid_type_migration.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AsyncIndexForVulnerabilitiesUuidTypeMigration < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = "tmp_idx_vulns_on_converted_uuid"
+ WHERE_CLAUSE = "uuid_convert_string_to_uuid = '00000000-0000-0000-0000-000000000000'::uuid"
+
+ def up
+ prepare_async_index(
+ :vulnerability_occurrences,
+ %i[id uuid_convert_string_to_uuid],
+ name: INDEX_NAME,
+ where: WHERE_CLAUSE
+ )
+ end
+
+ def down
+ unprepare_async_index(
+ :vulnerability_occurrences,
+ %i[id uuid_convert_string_to_uuid],
+ name: INDEX_NAME
+ )
+ end
+end
diff --git a/db/post_migrate/20230627174139_add_index_to_pool_repositories.rb b/db/post_migrate/20230627174139_add_index_to_pool_repositories.rb
new file mode 100644
index 00000000000..bb0ea0609da
--- /dev/null
+++ b/db/post_migrate/20230627174139_add_index_to_pool_repositories.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddIndexToPoolRepositories < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLE_NAME = :pool_repositories
+ OLD_INDEX_NAME = :index_pool_repositories_on_disk_path
+ NEW_INDEX_NAME = :unique_pool_repositories_on_disk_path_and_shard_id
+
+ def up
+ add_concurrent_index(TABLE_NAME, [:disk_path, :shard_id], name: NEW_INDEX_NAME, unique: true)
+
+ remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(TABLE_NAME, [:disk_path], name: OLD_INDEX_NAME, unique: true)
+
+ remove_concurrent_index_by_name(TABLE_NAME, NEW_INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20230628023103_queue_backfill_missing_ci_cd_settings.rb b/db/post_migrate/20230628023103_queue_backfill_missing_ci_cd_settings.rb
new file mode 100644
index 00000000000..0fc39e96e18
--- /dev/null
+++ b/db/post_migrate/20230628023103_queue_backfill_missing_ci_cd_settings.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class QueueBackfillMissingCiCdSettings < Gitlab::Database::Migration[2.1]
+ MIGRATION = "BackfillMissingCiCdSettings"
+ DELAY_INTERVAL = 2.minutes
+ BATCH_SIZE = 10_000
+ SUB_BATCH_SIZE = 500
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :projects,
+ :id,
+ job_interval: DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :projects, :id, [])
+ end
+end
diff --git a/db/post_migrate/20230629011859_cleanup_bigint_conversion_for_notes_for_gitlab_com.rb b/db/post_migrate/20230629011859_cleanup_bigint_conversion_for_notes_for_gitlab_com.rb
new file mode 100644
index 00000000000..5b99f4e4778
--- /dev/null
+++ b/db/post_migrate/20230629011859_cleanup_bigint_conversion_for_notes_for_gitlab_com.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class CleanupBigintConversionForNotesForGitlabCom < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ enable_lock_retries!
+
+ TABLE = :notes
+ COLUMNS = [:id]
+
+ def up
+ return unless should_run?
+
+ cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ return unless should_run?
+
+ restore_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ private
+
+ def should_run?
+ com_or_dev_or_test_but_not_jh?
+ end
+end
diff --git a/db/post_migrate/20230629024032_ensure_events_bigint_backfill_is_finished_for_gitlab_dot_com.rb b/db/post_migrate/20230629024032_ensure_events_bigint_backfill_is_finished_for_gitlab_dot_com.rb
new file mode 100644
index 00000000000..236b785c163
--- /dev/null
+++ b/db/post_migrate/20230629024032_ensure_events_bigint_backfill_is_finished_for_gitlab_dot_com.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class EnsureEventsBigintBackfillIsFinishedForGitlabDotCom < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: 'events',
+ column_name: 'id',
+ job_arguments: [['target_id'], ['target_id_convert_to_bigint']]
+ )
+ end
+
+ def down
+ # no-op
+ end
+
+ private
+
+ def should_run?
+ com_or_dev_or_test_but_not_jh?
+ end
+end
diff --git a/db/post_migrate/20230629024403_events_bigint_create_indexe_async_for_gitlab_dot_com.rb b/db/post_migrate/20230629024403_events_bigint_create_indexe_async_for_gitlab_dot_com.rb
new file mode 100644
index 00000000000..13691034fd7
--- /dev/null
+++ b/db/post_migrate/20230629024403_events_bigint_create_indexe_async_for_gitlab_dot_com.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class EventsBigintCreateIndexeAsyncForGitlabDotCom < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ def up
+ return unless should_run?
+
+ prepare_async_index :events,
+ [:target_type, :target_id_convert_to_bigint, :fingerprint],
+ name: :index_events_on_target_type_and_target_id_bigint_fingerprint,
+ unique: true
+ end
+
+ def down
+ return unless should_run?
+
+ unprepare_async_index :events,
+ [:target_type, :target_id_convert_to_bigint, :fingerprint],
+ name: :index_events_on_target_type_and_target_id_bigint_fingerprint
+ end
+
+ private
+
+ def should_run?
+ com_or_dev_or_test_but_not_jh?
+ end
+end
diff --git a/db/post_migrate/20230629095819_queue_backfill_uuid_conversion_column_in_vulnerability_occurrences.rb b/db/post_migrate/20230629095819_queue_backfill_uuid_conversion_column_in_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..0ea7e2da38c
--- /dev/null
+++ b/db/post_migrate/20230629095819_queue_backfill_uuid_conversion_column_in_vulnerability_occurrences.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class QueueBackfillUuidConversionColumnInVulnerabilityOccurrences < Gitlab::Database::Migration[2.1]
+ MIGRATION = "BackfillUuidConversionColumnInVulnerabilityOccurrences"
+ DELAY_INTERVAL = 2.minutes
+ BATCH_SIZE = 10_000
+ SUB_BATCH_SIZE = 1000
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :vulnerability_occurrences,
+ :id,
+ job_interval: DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :vulnerability_occurrences, :id, [])
+ end
+end
diff --git a/db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb b/db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb
new file mode 100644
index 00000000000..cb7fc04166f
--- /dev/null
+++ b/db/post_migrate/20230703024031_cleanup_project_pipeline_status_key.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CleanupProjectPipelineStatusKey < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ MIGRATION_WORKER_CLASS = 'BackfillProjectPipelineStatusTtl'
+
+ def up
+ queue_redis_migration_job(MIGRATION_WORKER_CLASS)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230703122803_create_vulnerability_uuid_type_migration_index.rb b/db/post_migrate/20230703122803_create_vulnerability_uuid_type_migration_index.rb
new file mode 100644
index 00000000000..f5ac2c2d0b9
--- /dev/null
+++ b/db/post_migrate/20230703122803_create_vulnerability_uuid_type_migration_index.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityUuidTypeMigrationIndex < Gitlab::Database::Migration[2.1]
+ def up
+ # no-op due to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/15983
+ end
+
+ def down
+ # no-op due to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/15983
+ end
+end
diff --git a/db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb b/db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb
new file mode 100644
index 00000000000..77ddd909215
--- /dev/null
+++ b/db/post_migrate/20230704042302_prepare_removal_index_deployments_on_project_id_sha.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class PrepareRemovalIndexDeploymentsOnProjectIdSha < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_deployments_on_project_id_sha'
+
+ # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/402512
+ def up
+ prepare_async_index_removal :deployments, %i[project_id sha], name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :deployments, %i[project_id sha], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb b/db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb
new file mode 100644
index 00000000000..0c9a292eb8c
--- /dev/null
+++ b/db/post_migrate/20230704044541_prepare_removal_index_deployments_on_project_id_and_status.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class PrepareRemovalIndexDeploymentsOnProjectIdAndStatus < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_deployments_on_project_id_and_status'
+
+ def up
+ prepare_async_index_removal :deployments, %i[project_id status], name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :deployments, %i[project_id status], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb b/db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb
new file mode 100644
index 00000000000..6171b58ac53
--- /dev/null
+++ b/db/post_migrate/20230704050739_prepare_removal_index_deployments_on_environment_id_and_iid_and_project_id.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class PrepareRemovalIndexDeploymentsOnEnvironmentIdAndIidAndProjectId < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_deployments_on_environment_id_and_iid_and_project_id'
+
+ def up
+ prepare_async_index_removal :deployments, %i[environment_id iid project_id], name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :deployments, %i[environment_id iid project_id], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230704062132_replace_p_ci_builds_metadata_foreign_key_v5.rb b/db/post_migrate/20230704062132_replace_p_ci_builds_metadata_foreign_key_v5.rb
new file mode 100644
index 00000000000..c535c54b022
--- /dev/null
+++ b/db/post_migrate/20230704062132_replace_p_ci_builds_metadata_foreign_key_v5.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class ReplacePCiBuildsMetadataForeignKeyV5 < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_partitioned_foreign_key :p_ci_builds_metadata, :p_ci_builds,
+ name: :temp_fk_e20479742e_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_builds_metadata, :p_ci_builds,
+ name: :temp_fk_e20479742e_p,
+ reverse_lock_order: true
+ end
+ end
+end
diff --git a/db/post_migrate/20230704062136_replace_p_ci_runner_machine_builds_foreign_key_v4.rb b/db/post_migrate/20230704062136_replace_p_ci_runner_machine_builds_foreign_key_v4.rb
new file mode 100644
index 00000000000..6cb8440bee8
--- /dev/null
+++ b/db/post_migrate/20230704062136_replace_p_ci_runner_machine_builds_foreign_key_v4.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class ReplacePCiRunnerMachineBuildsForeignKeyV4 < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_partitioned_foreign_key :p_ci_runner_machine_builds, :p_ci_builds,
+ name: :temp_fk_bb490f12fe_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_runner_machine_builds, :p_ci_builds,
+ name: :temp_fk_bb490f12fe_p,
+ reverse_lock_order: true
+ end
+ end
+end
diff --git a/db/post_migrate/20230704074120_replace_old_fk_p_ci_builds_metadata_to_builds.rb b/db/post_migrate/20230704074120_replace_old_fk_p_ci_builds_metadata_to_builds.rb
new file mode 100644
index 00000000000..49f2066d7bf
--- /dev/null
+++ b/db/post_migrate/20230704074120_replace_old_fk_p_ci_builds_metadata_to_builds.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkPCiBuildsMetadataToBuilds < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_builds_metadata, :ci_builds,
+ name: :fk_e20479742e_p, reverse_lock_order: true
+
+ rename_constraint :p_ci_builds_metadata, :temp_fk_e20479742e_p, :fk_e20479742e_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_builds_metadata) do |partition|
+ rename_constraint partition.identifier, :temp_fk_e20479742e_p, :fk_e20479742e_p
+ end
+ end
+ end
+
+ def down
+ return unless should_run?
+ return unless new_foreign_key_exists?
+
+ add_concurrent_partitioned_foreign_key :p_ci_builds_metadata, :ci_builds,
+ name: :temp_fk_e20479742e_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :p_ci_builds_metadata, :fk_e20479742e_p, :temp_fk_e20479742e_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_builds_metadata) do |partition|
+ switch_constraint_names partition.identifier, :fk_e20479742e_p, :temp_fk_e20479742e_p
+ end
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_builds_metadata, :ci_builds)
+ end
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:p_ci_builds_metadata, :p_ci_builds, name: :fk_e20479742e_p)
+ end
+end
diff --git a/db/post_migrate/20230704074124_replace_old_fk_p_ci_runner_machine_builds_to_builds.rb b/db/post_migrate/20230704074124_replace_old_fk_p_ci_runner_machine_builds_to_builds.rb
new file mode 100644
index 00000000000..b1d58058cef
--- /dev/null
+++ b/db/post_migrate/20230704074124_replace_old_fk_p_ci_runner_machine_builds_to_builds.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkPCiRunnerMachineBuildsToBuilds < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_runner_machine_builds, :ci_builds,
+ name: :fk_bb490f12fe_p, reverse_lock_order: true
+
+ rename_constraint :p_ci_runner_machine_builds, :temp_fk_bb490f12fe_p, :fk_bb490f12fe_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_runner_machine_builds) do |partition|
+ rename_constraint partition.identifier, :temp_fk_bb490f12fe_p, :fk_bb490f12fe_p
+ end
+ end
+ end
+
+ def down
+ return unless should_run?
+ return unless new_foreign_key_exists?
+
+ add_concurrent_partitioned_foreign_key :p_ci_runner_machine_builds, :ci_builds,
+ name: :temp_fk_bb490f12fe_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :p_ci_runner_machine_builds, :fk_bb490f12fe_p, :temp_fk_bb490f12fe_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_runner_machine_builds) do |partition|
+ switch_constraint_names partition.identifier, :fk_bb490f12fe_p, :temp_fk_bb490f12fe_p
+ end
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_builds)
+ end
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:p_ci_runner_machine_builds, :p_ci_builds, name: :fk_bb490f12fe_p)
+ end
+end
diff --git a/db/post_migrate/20230705115215_remove_user_details_provisioned_by_group_at_column.rb b/db/post_migrate/20230705115215_remove_user_details_provisioned_by_group_at_column.rb
new file mode 100644
index 00000000000..33844f6714e
--- /dev/null
+++ b/db/post_migrate/20230705115215_remove_user_details_provisioned_by_group_at_column.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class RemoveUserDetailsProvisionedByGroupAtColumn < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ remove_column :user_details, :provisioned_by_group_at, :datetime_with_timezone
+ end
+end
diff --git a/db/post_migrate/20230705141703_rollback_vulnerability_advisories_foreign_key_on_vulnerable_component_versions.rb b/db/post_migrate/20230705141703_rollback_vulnerability_advisories_foreign_key_on_vulnerable_component_versions.rb
new file mode 100644
index 00000000000..92feca76511
--- /dev/null
+++ b/db/post_migrate/20230705141703_rollback_vulnerability_advisories_foreign_key_on_vulnerable_component_versions.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RollbackVulnerabilityAdvisoriesForeignKeyOnVulnerableComponentVersions < Gitlab::Database::Migration[2.1]
+ SOURCE_TABLE = :sbom_vulnerable_component_versions
+ TARGET_TABLE = :vulnerability_advisories
+ COLUMN = :vulnerability_advisory_id
+
+ disable_ddl_transaction!
+
+ def up
+ # Foreign key is removed when the table is dropped in the next migration.
+ end
+
+ def down
+ add_concurrent_foreign_key SOURCE_TABLE, TARGET_TABLE, column: COLUMN, on_delete: :cascade
+ end
+end
diff --git a/db/post_migrate/20230705141733_rollback_component_version_foreign_key_on_vulnerable_component_versions.rb b/db/post_migrate/20230705141733_rollback_component_version_foreign_key_on_vulnerable_component_versions.rb
new file mode 100644
index 00000000000..c54d4ebd1e3
--- /dev/null
+++ b/db/post_migrate/20230705141733_rollback_component_version_foreign_key_on_vulnerable_component_versions.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RollbackComponentVersionForeignKeyOnVulnerableComponentVersions < Gitlab::Database::Migration[2.1]
+ SOURCE_TABLE = :sbom_vulnerable_component_versions
+ TARGET_TABLE = :sbom_component_versions
+ COLUMN = :sbom_component_version_id
+
+ disable_ddl_transaction!
+
+ def up
+ # Foreign key is removed when the table is dropped in the next migration.
+ end
+
+ def down
+ add_concurrent_foreign_key SOURCE_TABLE, TARGET_TABLE, column: COLUMN, on_delete: :cascade
+ end
+end
diff --git a/db/post_migrate/20230705142241_drop_vulnerable_component_versions.rb b/db/post_migrate/20230705142241_drop_vulnerable_component_versions.rb
new file mode 100644
index 00000000000..10432f6b515
--- /dev/null
+++ b/db/post_migrate/20230705142241_drop_vulnerable_component_versions.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class DropVulnerableComponentVersions < Gitlab::Database::Migration[2.1]
+ ADVISORY_INDEX_NAME = "index_vulnerable_component_versions_on_vulnerability_advisory"
+ SBOM_COMPONENT_INDEX_NAME = "index_vulnerable_component_versions_on_sbom_component_version"
+
+ def up
+ drop_table :sbom_vulnerable_component_versions
+ end
+
+ def down
+ create_table :sbom_vulnerable_component_versions do |t|
+ t.references :vulnerability_advisory,
+ index: { name: ADVISORY_INDEX_NAME }
+
+ t.references :sbom_component_version,
+ index: { name: SBOM_COMPONENT_INDEX_NAME }
+
+ t.timestamps_with_timezone null: false
+ end
+ end
+end
diff --git a/db/post_migrate/20230705142334_drop_vulnerabilities_advisories.rb b/db/post_migrate/20230705142334_drop_vulnerabilities_advisories.rb
new file mode 100644
index 00000000000..e6bee52eb0c
--- /dev/null
+++ b/db/post_migrate/20230705142334_drop_vulnerabilities_advisories.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class DropVulnerabilitiesAdvisories < Gitlab::Database::Migration[2.1]
+ def up
+ drop_table :vulnerability_advisories
+ end
+
+ def down
+ create_table :vulnerability_advisories, id: false do |t|
+ t.uuid :uuid, null: false
+ t.timestamps_with_timezone null: false
+ t.primary_key :id
+ t.date :created_date, null: false
+ t.date :published_date, null: false
+ t.text :description, limit: 2048
+ t.text :title, limit: 2048
+ t.text :component_name, limit: 2048
+ t.text :solution, limit: 2048
+ t.text :not_impacted, limit: 2048
+ t.text :cvss_v2, limit: 128
+ t.text :cvss_v3, limit: 128
+ t.text :affected_range, limit: 32
+ t.text :identifiers, array: true, default: []
+ t.text :fixed_versions, array: true, default: []
+ t.text :urls, array: true, default: []
+ t.text :links, array: true, default: []
+ end
+ end
+end
diff --git a/db/post_migrate/20230705145827_drop_wrong_index_on_vulnerability_occurrences.rb b/db/post_migrate/20230705145827_drop_wrong_index_on_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..6b4089f72fe
--- /dev/null
+++ b/db/post_migrate/20230705145827_drop_wrong_index_on_vulnerability_occurrences.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class DropWrongIndexOnVulnerabilityOccurrences < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'tmp_idx_vulns_on_converted_uuid'
+
+ def up
+ # We do not want to drop this from Gitlab.com
+ # because it was created correctly there
+ return if Gitlab.com? && !Gitlab.dev_or_test_env?
+
+ remove_concurrent_index_by_name(
+ :vulnerability_occurrences,
+ INDEX_NAME
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230705150100_recreate_type_migration_index_on_vulnerability_occurrences.rb b/db/post_migrate/20230705150100_recreate_type_migration_index_on_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..9e426c61874
--- /dev/null
+++ b/db/post_migrate/20230705150100_recreate_type_migration_index_on_vulnerability_occurrences.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class RecreateTypeMigrationIndexOnVulnerabilityOccurrences < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'tmp_idx_vulns_on_converted_uuid'
+ WHERE_CLAUSE = "uuid_convert_string_to_uuid = '00000000-0000-0000-0000-000000000000'::uuid"
+
+ def up
+ add_concurrent_index(
+ :vulnerability_occurrences,
+ %i[id uuid_convert_string_to_uuid],
+ name: INDEX_NAME,
+ where: WHERE_CLAUSE
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name(
+ :vulnerability_occurrences,
+ INDEX_NAME
+ )
+ end
+end
diff --git a/db/post_migrate/20230706011541_add_user_id_foreign_key_to_ml_experiments.rb b/db/post_migrate/20230706011541_add_user_id_foreign_key_to_ml_experiments.rb
new file mode 100644
index 00000000000..77059d89d30
--- /dev/null
+++ b/db/post_migrate/20230706011541_add_user_id_foreign_key_to_ml_experiments.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class AddUserIdForeignKeyToMlExperiments < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ NEW_FK_NAME = 'fk_ml_experiments_on_user_id'
+ OLD_FK_NAME = 'fk_rails_1fbc5e001f'
+
+ def up
+ add_concurrent_foreign_key(:ml_experiments, :users, column: :user_id, on_delete: :nullify,
+ name: NEW_FK_NAME, validate: true)
+
+ with_lock_retries do
+ remove_foreign_key_if_exists(:ml_experiments, name: OLD_FK_NAME)
+ end
+ end
+
+ def down
+ unless foreign_key_exists?(:ml_experiments, :users, name: OLD_FK_NAME)
+ with_lock_retries do
+ execute(<<~SQL.squish)
+ ALTER TABLE ml_experiments ADD CONSTRAINT #{OLD_FK_NAME} FOREIGN KEY (user_id) REFERENCES users (id)
+ SQL
+ end
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists(:ml_experiments, name: NEW_FK_NAME)
+ end
+ end
+end
diff --git a/db/post_migrate/20230706073937_remove_index_events_on_project_id_and_id_desc_on_merged_action.rb b/db/post_migrate/20230706073937_remove_index_events_on_project_id_and_id_desc_on_merged_action.rb
new file mode 100644
index 00000000000..4d7cdc000d5
--- /dev/null
+++ b/db/post_migrate/20230706073937_remove_index_events_on_project_id_and_id_desc_on_merged_action.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RemoveIndexEventsOnProjectIdAndIdDescOnMergedAction < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_events_on_project_id_and_id_desc_on_merged_action'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index(:events, [:project_id, :id], order: { id: :desc },
+ where: "action = 7", name: INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:events, [:project_id, :id], order: { id: :desc },
+ where: "action = 7", name: INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20230706080234_add_trigger_on_organizations.rb b/db/post_migrate/20230706080234_add_trigger_on_organizations.rb
new file mode 100644
index 00000000000..e21a5e0eb23
--- /dev/null
+++ b/db/post_migrate/20230706080234_add_trigger_on_organizations.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddTriggerOnOrganizations < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::SchemaHelpers
+
+ TABLE_NAME = 'organizations'
+ FUNCTION_NAME = 'prevent_delete_of_default_organization'
+ TRIGGER_NAME = 'prevent_delete_of_default_organization_before_destroy'
+
+ def up
+ default_org_id = Organizations::Organization::DEFAULT_ORGANIZATION_ID
+
+ create_trigger_function(FUNCTION_NAME) do
+ <<~SQL
+ IF OLD.id = #{default_org_id} THEN
+ RAISE EXCEPTION 'Deletion of the default Organization is not allowed.';
+ END IF;
+ RETURN OLD;
+ SQL
+ end
+
+ create_trigger(TABLE_NAME, TRIGGER_NAME, FUNCTION_NAME, fires: 'BEFORE DELETE')
+ end
+
+ def down
+ drop_trigger(TABLE_NAME, TRIGGER_NAME)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/post_migrate/20230707114012_change_project_view_default.rb b/db/post_migrate/20230707114012_change_project_view_default.rb
new file mode 100644
index 00000000000..6437a650261
--- /dev/null
+++ b/db/post_migrate/20230707114012_change_project_view_default.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class ChangeProjectViewDefault < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def change
+ change_column_default(:users, :project_view, from: 0, to: 2)
+ end
+end
diff --git a/db/post_migrate/20230707211358_deduplicate_inactive_alert_integrations.rb b/db/post_migrate/20230707211358_deduplicate_inactive_alert_integrations.rb
new file mode 100644
index 00000000000..041ce659da6
--- /dev/null
+++ b/db/post_migrate/20230707211358_deduplicate_inactive_alert_integrations.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+class DeduplicateInactiveAlertIntegrations < Gitlab::Database::Migration[2.1]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class HttpIntegration < MigrationRecord
+ self.table_name = 'alert_management_http_integrations'
+ end
+
+ # Existing unique index ensures that all active integrations are already unique.
+ # Any non-unique records must be inactive by definition, but dups are unlikely.
+ # At time of writing, gitlab.com has 0 records in this state.
+ # Of the ~1600 integrations, only ~100 are even inactive.
+ def up
+ duplicated_identifiers.each do |(project_id, endpoint_identifier)|
+ find_inactive_integrations(project_id, endpoint_identifier).delete_all
+ end
+ end
+
+ def down
+ # no-op -> unable to identify duplicates retroactively
+ end
+
+ private
+
+ def duplicated_identifiers
+ HttpIntegration
+ .group(:project_id, :endpoint_identifier)
+ .having('count(id) > 1')
+ .pluck(:project_id, :endpoint_identifier)
+ end
+
+ def find_inactive_integrations(project_id, endpoint_identifier)
+ HttpIntegration.where(
+ project_id: project_id,
+ endpoint_identifier: endpoint_identifier,
+ active: false
+ )
+ end
+end
diff --git a/db/post_migrate/20230707211359_change_alert_integrations_unique_index.rb b/db/post_migrate/20230707211359_change_alert_integrations_unique_index.rb
new file mode 100644
index 00000000000..eac5d057b40
--- /dev/null
+++ b/db/post_migrate/20230707211359_change_alert_integrations_unique_index.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+# Swaps the unique index for AlertManagement::HttpIntegration to include
+# inactive integrations, making performance optimizations easier.
+#
+# At time of writing, gitlab.com has 0 records which would be invalidated
+# by the new index. Of the ~1600 integrations, only ~100 are inactive, so the
+# size of the index will not significantly change.
+class ChangeAlertIntegrationsUniqueIndex < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ UNIQUE_INDEX_NAME = 'index_http_integrations_on_project_and_endpoint'
+ OLD_INDEX_NAME = 'index_http_integrations_on_active_and_project_and_endpoint'
+
+ def up
+ add_concurrent_index :alert_management_http_integrations,
+ [:project_id, :endpoint_identifier],
+ name: UNIQUE_INDEX_NAME,
+ unique: true
+
+ remove_concurrent_index_by_name :alert_management_http_integrations, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :alert_management_http_integrations,
+ [:active, :project_id, :endpoint_identifier],
+ unique: true,
+ name: OLD_INDEX_NAME,
+ where: 'active'
+
+ remove_concurrent_index_by_name :alert_management_http_integrations, UNIQUE_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230707220646_add_index_to_vulnerability_findings_on_uuid_again.rb b/db/post_migrate/20230707220646_add_index_to_vulnerability_findings_on_uuid_again.rb
new file mode 100644
index 00000000000..06d0117d50e
--- /dev/null
+++ b/db/post_migrate/20230707220646_add_index_to_vulnerability_findings_on_uuid_again.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddIndexToVulnerabilityFindingsOnUuidAgain < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_vuln_findings_on_uuid_including_vuln_id'
+
+ def up
+ Gitlab::Database::AsyncIndexes::PostgresAsyncIndex.where(name: INDEX_NAME).find_each do |record|
+ record.definition = record.definition.strip
+ record.save!
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230711093010_drop_default_partition_id_value_for_ci_tables.rb b/db/post_migrate/20230711093010_drop_default_partition_id_value_for_ci_tables.rb
new file mode 100644
index 00000000000..733cab057f6
--- /dev/null
+++ b/db/post_migrate/20230711093010_drop_default_partition_id_value_for_ci_tables.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+class DropDefaultPartitionIdValueForCiTables < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLES = {
+ ci_build_needs: [:partition_id],
+ ci_build_pending_states: [:partition_id],
+ ci_build_report_results: [:partition_id],
+ ci_build_trace_chunks: [:partition_id],
+ ci_builds_runner_session: [:partition_id],
+ ci_job_variables: [:partition_id],
+ ci_pending_builds: [:partition_id],
+ ci_pipelines: [:partition_id],
+ ci_running_builds: [:partition_id],
+ ci_sources_pipelines: [:partition_id, :source_partition_id],
+ ci_unit_test_failures: [:partition_id]
+ }
+
+ def up
+ TABLES.each do |table_name, columns|
+ with_lock_retries do
+ columns.each do |column_name| # rubocop:disable Migration/WithLockRetriesDisallowedMethod
+ change_column_default(table_name, column_name, from: 100, to: nil)
+ end
+ end
+ end
+ end
+
+ def down
+ TABLES.each do |table_name, columns|
+ with_lock_retries do
+ columns.each do |column_name| # rubocop:disable Migration/WithLockRetriesDisallowedMethod
+ change_column_default(table_name, column_name, from: nil, to: 100)
+ end
+ end
+ end
+ end
+end
diff --git a/db/post_migrate/20230712020407_remove_temporary_index_from_system_note_metadata.rb b/db/post_migrate/20230712020407_remove_temporary_index_from_system_note_metadata.rb
new file mode 100644
index 00000000000..9000ef208d6
--- /dev/null
+++ b/db/post_migrate/20230712020407_remove_temporary_index_from_system_note_metadata.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveTemporaryIndexFromSystemNoteMetadata < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'tmp_index_for_backfilling_resource_link_events'
+ CONDITION = "action='relate_to_parent' OR action='unrelate_from_parent'"
+
+ def up
+ remove_concurrent_index_by_name :system_note_metadata, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :system_note_metadata, :id,
+ where: CONDITION,
+ name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230712064637_replace_old_fk_p_ci_builds_metadata_to_builds_v2.rb b/db/post_migrate/20230712064637_replace_old_fk_p_ci_builds_metadata_to_builds_v2.rb
new file mode 100644
index 00000000000..6165029d855
--- /dev/null
+++ b/db/post_migrate/20230712064637_replace_old_fk_p_ci_builds_metadata_to_builds_v2.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkPCiBuildsMetadataToBuildsV2 < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_builds_metadata, :ci_builds,
+ name: :fk_e20479742e_p, reverse_lock_order: true
+
+ rename_constraint :p_ci_builds_metadata, :temp_fk_e20479742e_p, :fk_e20479742e_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_builds_metadata) do |partition|
+ rename_constraint partition.identifier, :temp_fk_e20479742e_p, :fk_e20479742e_p
+ end
+ end
+ end
+
+ def down
+ return unless should_run?
+ return unless new_foreign_key_exists?
+
+ add_concurrent_partitioned_foreign_key :p_ci_builds_metadata, :ci_builds,
+ name: :temp_fk_e20479742e_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :p_ci_builds_metadata, :fk_e20479742e_p, :temp_fk_e20479742e_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_builds_metadata) do |partition|
+ switch_constraint_names partition.identifier, :fk_e20479742e_p, :temp_fk_e20479742e_p
+ end
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_builds_metadata, :ci_builds)
+ end
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:p_ci_builds_metadata, :p_ci_builds, name: :fk_e20479742e_p)
+ end
+end
diff --git a/db/post_migrate/20230712064655_replace_old_fk_p_ci_runner_machine_builds_to_builds_v2.rb b/db/post_migrate/20230712064655_replace_old_fk_p_ci_runner_machine_builds_to_builds_v2.rb
new file mode 100644
index 00000000000..8f1c1872e04
--- /dev/null
+++ b/db/post_migrate/20230712064655_replace_old_fk_p_ci_runner_machine_builds_to_builds_v2.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+class ReplaceOldFkPCiRunnerMachineBuildsToBuildsV2 < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::PartitioningMigrationHelpers
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+ return if new_foreign_key_exists?
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :p_ci_runner_machine_builds, :ci_builds,
+ name: :fk_bb490f12fe_p, reverse_lock_order: true
+
+ rename_constraint :p_ci_runner_machine_builds, :temp_fk_bb490f12fe_p, :fk_bb490f12fe_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_runner_machine_builds) do |partition|
+ rename_constraint partition.identifier, :temp_fk_bb490f12fe_p, :fk_bb490f12fe_p
+ end
+ end
+ end
+
+ def down
+ return unless should_run?
+ return unless new_foreign_key_exists?
+
+ add_concurrent_partitioned_foreign_key :p_ci_runner_machine_builds, :ci_builds,
+ name: :temp_fk_bb490f12fe_p,
+ column: [:partition_id, :build_id],
+ target_column: [:partition_id, :id],
+ on_update: :cascade,
+ on_delete: :cascade,
+ validate: true,
+ reverse_lock_order: true
+
+ switch_constraint_names :p_ci_runner_machine_builds, :fk_bb490f12fe_p, :temp_fk_bb490f12fe_p
+
+ Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_runner_machine_builds) do |partition|
+ switch_constraint_names partition.identifier, :fk_bb490f12fe_p, :temp_fk_bb490f12fe_p
+ end
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(:ci_builds)
+ end
+
+ def new_foreign_key_exists?
+ foreign_key_exists?(:p_ci_runner_machine_builds, :p_ci_builds, name: :fk_bb490f12fe_p)
+ end
+end
diff --git a/db/post_migrate/20230712145323_drop_ci_job_artifacts_partition_id_default.rb b/db/post_migrate/20230712145323_drop_ci_job_artifacts_partition_id_default.rb
new file mode 100644
index 00000000000..af475ba62d0
--- /dev/null
+++ b/db/post_migrate/20230712145323_drop_ci_job_artifacts_partition_id_default.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class DropCiJobArtifactsPartitionIdDefault < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ enable_lock_retries!
+
+ TABLE_NAME = :ci_job_artifacts
+ COLUMN_NAME = :partition_id
+
+ def up
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: 100, to: nil) if should_run?
+ end
+
+ def down
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: nil, to: 100) if should_run?
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(TABLE_NAME)
+ end
+end
diff --git a/db/post_migrate/20230712145821_drop_ci_stages_partition_id_default.rb b/db/post_migrate/20230712145821_drop_ci_stages_partition_id_default.rb
new file mode 100644
index 00000000000..a7c23ac35d2
--- /dev/null
+++ b/db/post_migrate/20230712145821_drop_ci_stages_partition_id_default.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class DropCiStagesPartitionIdDefault < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ enable_lock_retries!
+
+ TABLE_NAME = :ci_stages
+ COLUMN_NAME = :partition_id
+
+ def up
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: 100, to: nil) if should_run?
+ end
+
+ def down
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: nil, to: 100) if should_run?
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(TABLE_NAME)
+ end
+end
diff --git a/db/post_migrate/20230712145926_drop_ci_build_trace_metadata_partition_id_default.rb b/db/post_migrate/20230712145926_drop_ci_build_trace_metadata_partition_id_default.rb
new file mode 100644
index 00000000000..dad647246a5
--- /dev/null
+++ b/db/post_migrate/20230712145926_drop_ci_build_trace_metadata_partition_id_default.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class DropCiBuildTraceMetadataPartitionIdDefault < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ enable_lock_retries!
+
+ TABLE_NAME = :ci_build_trace_metadata
+ COLUMN_NAME = :partition_id
+
+ def up
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: 100, to: nil) if should_run?
+ end
+
+ def down
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: nil, to: 100) if should_run?
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(TABLE_NAME)
+ end
+end
diff --git a/db/post_migrate/20230713020247_change_pm_advisories_urls_constraint.rb b/db/post_migrate/20230713020247_change_pm_advisories_urls_constraint.rb
new file mode 100644
index 00000000000..4611f657d0d
--- /dev/null
+++ b/db/post_migrate/20230713020247_change_pm_advisories_urls_constraint.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ChangePmAdvisoriesUrlsConstraint < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = "chk_rails_e73af9de76"
+
+ def up
+ remove_check_constraint :pm_advisories, CONSTRAINT_NAME
+ add_check_constraint :pm_advisories, "CARDINALITY(urls) <= 20", CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :pm_advisories, CONSTRAINT_NAME
+ add_check_constraint :pm_advisories, "CARDINALITY(urls) <= 10", CONSTRAINT_NAME
+ end
+end
diff --git a/db/post_migrate/20230713100100_drop_ci_pipeline_variable_partition_id_default.rb b/db/post_migrate/20230713100100_drop_ci_pipeline_variable_partition_id_default.rb
new file mode 100644
index 00000000000..5ef3a2caa82
--- /dev/null
+++ b/db/post_migrate/20230713100100_drop_ci_pipeline_variable_partition_id_default.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class DropCiPipelineVariablePartitionIdDefault < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
+
+ enable_lock_retries!
+
+ TABLE_NAME = :ci_pipeline_variables
+ COLUMN_NAME = :partition_id
+
+ def up
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: 100, to: nil) if should_run?
+ end
+
+ def down
+ change_column_default(TABLE_NAME, COLUMN_NAME, from: nil, to: 100) if should_run?
+ end
+
+ private
+
+ def should_run?
+ can_execute_on?(TABLE_NAME)
+ end
+end
diff --git a/db/schema_migrations/20230314094213 b/db/schema_migrations/20230314094213
new file mode 100644
index 00000000000..e2741f5ea30
--- /dev/null
+++ b/db/schema_migrations/20230314094213
@@ -0,0 +1 @@
+ccf7548dc1916a60da14f9545039d7ac3666e44e96ccd59c0f6db4117b15515a \ No newline at end of file
diff --git a/db/schema_migrations/20230314094215 b/db/schema_migrations/20230314094215
new file mode 100644
index 00000000000..a030527fac4
--- /dev/null
+++ b/db/schema_migrations/20230314094215
@@ -0,0 +1 @@
+5549548b53710624294aed31af6ed8aeb26263e538d2e2d7eac254a5c105d08a \ No newline at end of file
diff --git a/db/schema_migrations/20230522162742 b/db/schema_migrations/20230522162742
new file mode 100644
index 00000000000..ba41bc2a54d
--- /dev/null
+++ b/db/schema_migrations/20230522162742
@@ -0,0 +1 @@
+ae56cc5feed51f3b48bf2f2d51bb32bf140e2ade7d7bdbfec16bb5ce2fead5c1 \ No newline at end of file
diff --git a/db/schema_migrations/20230528203340 b/db/schema_migrations/20230528203340
new file mode 100644
index 00000000000..27e5d44f480
--- /dev/null
+++ b/db/schema_migrations/20230528203340
@@ -0,0 +1 @@
+0503c864e706c1255a9dbb27d7d83fe2be7e9b8690bb26bbbe327654a090cc90 \ No newline at end of file
diff --git a/db/schema_migrations/20230530012406 b/db/schema_migrations/20230530012406
new file mode 100644
index 00000000000..ec6210939c5
--- /dev/null
+++ b/db/schema_migrations/20230530012406
@@ -0,0 +1 @@
+bef78410f5088ab1e230ff21118dae186f363ee215f1cdab7cbff4e223bf20ec \ No newline at end of file
diff --git a/db/schema_migrations/20230601211635 b/db/schema_migrations/20230601211635
new file mode 100644
index 00000000000..a92c327bce6
--- /dev/null
+++ b/db/schema_migrations/20230601211635
@@ -0,0 +1 @@
+c987632b4c7628e5fef9d5c6c0876ae2af7a34db2bdd87df8560c82adbdb604f \ No newline at end of file
diff --git a/db/schema_migrations/20230601213750 b/db/schema_migrations/20230601213750
new file mode 100644
index 00000000000..494b48356ca
--- /dev/null
+++ b/db/schema_migrations/20230601213750
@@ -0,0 +1 @@
+f3e1bffc9586ee332497c3b6a72f86a8678b171c8a3eb538df4c4a5147bec04b \ No newline at end of file
diff --git a/db/schema_migrations/20230605125735 b/db/schema_migrations/20230605125735
new file mode 100644
index 00000000000..7592cd8ffa1
--- /dev/null
+++ b/db/schema_migrations/20230605125735
@@ -0,0 +1 @@
+348128b62afecd48dc65f1cf2c4f5ad37e98e837aca183c1283189283e074890 \ No newline at end of file
diff --git a/db/schema_migrations/20230607124754 b/db/schema_migrations/20230607124754
new file mode 100644
index 00000000000..2c49744ec26
--- /dev/null
+++ b/db/schema_migrations/20230607124754
@@ -0,0 +1 @@
+3aca70a09ce278454f38740817bba4e88501b8e68d719b9ef3f922cb09b7c7d3 \ No newline at end of file
diff --git a/db/schema_migrations/20230608113106 b/db/schema_migrations/20230608113106
new file mode 100644
index 00000000000..82a65911642
--- /dev/null
+++ b/db/schema_migrations/20230608113106
@@ -0,0 +1 @@
+137039d31d0e8b4abce8260f067783334538787c3f22c638d5c65c8b7016aad7 \ No newline at end of file
diff --git a/db/schema_migrations/20230608145500 b/db/schema_migrations/20230608145500
new file mode 100644
index 00000000000..ddf0ac83819
--- /dev/null
+++ b/db/schema_migrations/20230608145500
@@ -0,0 +1 @@
+e8070bd79c6c523fe5565951877f2f44ff25c6f7e0ce8713ac9887cd1296f087 \ No newline at end of file
diff --git a/db/schema_migrations/20230609065641 b/db/schema_migrations/20230609065641
new file mode 100644
index 00000000000..31bfe4d1d94
--- /dev/null
+++ b/db/schema_migrations/20230609065641
@@ -0,0 +1 @@
+8dbbe0c959e263ba04e2b68dd4b868fb4f5e4809c0724fe1c14aebee6e924132 \ No newline at end of file
diff --git a/db/schema_migrations/20230609065942 b/db/schema_migrations/20230609065942
new file mode 100644
index 00000000000..5b6454c7cf1
--- /dev/null
+++ b/db/schema_migrations/20230609065942
@@ -0,0 +1 @@
+08b97855a2d1bfe7f1cb2118744b6968eb117eda2521e2287ec5b201114e9eec \ No newline at end of file
diff --git a/db/schema_migrations/20230612074428 b/db/schema_migrations/20230612074428
new file mode 100644
index 00000000000..a763ffafa46
--- /dev/null
+++ b/db/schema_migrations/20230612074428
@@ -0,0 +1 @@
+65df1d9bfc31a41210d9a18a63786d35bde456d0fd94520be186e8eb06214d7e \ No newline at end of file
diff --git a/db/schema_migrations/20230612091526 b/db/schema_migrations/20230612091526
new file mode 100644
index 00000000000..04fa44523f9
--- /dev/null
+++ b/db/schema_migrations/20230612091526
@@ -0,0 +1 @@
+f03f81f50c0777502aeb1040f5e2805b296d77979760156f5e2e1e184792d503 \ No newline at end of file
diff --git a/db/schema_migrations/20230612091747 b/db/schema_migrations/20230612091747
new file mode 100644
index 00000000000..fbc9998118a
--- /dev/null
+++ b/db/schema_migrations/20230612091747
@@ -0,0 +1 @@
+ca928191459eeeeed6c10b444053eedb5e7236e94403a36ee8aa86a448d352c6 \ No newline at end of file
diff --git a/db/schema_migrations/20230612091910 b/db/schema_migrations/20230612091910
new file mode 100644
index 00000000000..8446746db36
--- /dev/null
+++ b/db/schema_migrations/20230612091910
@@ -0,0 +1 @@
+6e534b91092c00e405dd621ea4d05b732b075007563f776b1fb88087f7edeaf9 \ No newline at end of file
diff --git a/db/schema_migrations/20230613122211 b/db/schema_migrations/20230613122211
new file mode 100644
index 00000000000..ccdecf69019
--- /dev/null
+++ b/db/schema_migrations/20230613122211
@@ -0,0 +1 @@
+da2cc429052e2db307e8eff2de61049ce93db4a7f6321a265889edeff1e7897d \ No newline at end of file
diff --git a/db/schema_migrations/20230613192703 b/db/schema_migrations/20230613192703
new file mode 100644
index 00000000000..0b4525d8e2c
--- /dev/null
+++ b/db/schema_migrations/20230613192703
@@ -0,0 +1 @@
+9a59cadd56d144591e828f8b64a7aa7887c156e86c75e1d57cc1e83fb8afbd01 \ No newline at end of file
diff --git a/db/schema_migrations/20230613192802 b/db/schema_migrations/20230613192802
new file mode 100644
index 00000000000..5184009df5c
--- /dev/null
+++ b/db/schema_migrations/20230613192802
@@ -0,0 +1 @@
+3cf9c170bd70e70f0eef49c13317dcfbf79630d166417a61c6a2029ae40490c9 \ No newline at end of file
diff --git a/db/schema_migrations/20230614180651 b/db/schema_migrations/20230614180651
new file mode 100644
index 00000000000..6aa4a30f5e4
--- /dev/null
+++ b/db/schema_migrations/20230614180651
@@ -0,0 +1 @@
+e29861e9c43ad7b225a077f1026fe2cbf569b8caebd5c9949200220cb2b68fd6 \ No newline at end of file
diff --git a/db/schema_migrations/20230614181310 b/db/schema_migrations/20230614181310
new file mode 100644
index 00000000000..6bdfc2ccb8f
--- /dev/null
+++ b/db/schema_migrations/20230614181310
@@ -0,0 +1 @@
+4433251c5085ac4e9c74a3dedc08a153cad82e8c6e7484e47538948a0d28185a \ No newline at end of file
diff --git a/db/schema_migrations/20230614182049 b/db/schema_migrations/20230614182049
new file mode 100644
index 00000000000..6454c1c88df
--- /dev/null
+++ b/db/schema_migrations/20230614182049
@@ -0,0 +1 @@
+0154e8ee8108b47dd1ff6913f3697e996e6c98a41b5b9a04c660086f5d1a31d7 \ No newline at end of file
diff --git a/db/schema_migrations/20230615030402 b/db/schema_migrations/20230615030402
new file mode 100644
index 00000000000..1139ca531f1
--- /dev/null
+++ b/db/schema_migrations/20230615030402
@@ -0,0 +1 @@
+47b6c521709eb4b514965fa6e59eb10ff93a31ce4a56debc81e8959f04e32b15 \ No newline at end of file
diff --git a/db/schema_migrations/20230615074515 b/db/schema_migrations/20230615074515
new file mode 100644
index 00000000000..22f8ca20d74
--- /dev/null
+++ b/db/schema_migrations/20230615074515
@@ -0,0 +1 @@
+bfbb49d6b6b263be1fc669807ceb5f2e6cedb0e68221cb17a9e4fe5c2bedb439 \ No newline at end of file
diff --git a/db/schema_migrations/20230615074544 b/db/schema_migrations/20230615074544
new file mode 100644
index 00000000000..f9079d090a8
--- /dev/null
+++ b/db/schema_migrations/20230615074544
@@ -0,0 +1 @@
+45c76efa0091f7b63ce476cd7d6909d3c11aec2d96e51087f44060d5192b76a5 \ No newline at end of file
diff --git a/db/schema_migrations/20230615104902 b/db/schema_migrations/20230615104902
new file mode 100644
index 00000000000..9d52b635ff0
--- /dev/null
+++ b/db/schema_migrations/20230615104902
@@ -0,0 +1 @@
+f96102edb32531bda4828af85709f7510f730617aea6c80859da697595c96fcc \ No newline at end of file
diff --git a/db/schema_migrations/20230615113748 b/db/schema_migrations/20230615113748
new file mode 100644
index 00000000000..63fd03faa08
--- /dev/null
+++ b/db/schema_migrations/20230615113748
@@ -0,0 +1 @@
+886e52579245dc9d3dafbfca97bb7398c776fa343946f38d58c7b10d081752e1 \ No newline at end of file
diff --git a/db/schema_migrations/20230615113840 b/db/schema_migrations/20230615113840
new file mode 100644
index 00000000000..073f6870397
--- /dev/null
+++ b/db/schema_migrations/20230615113840
@@ -0,0 +1 @@
+703e63f9a84e94ed87938f47952d661a626f156aa8325322abab8f9a9b9fcb8f \ No newline at end of file
diff --git a/db/schema_migrations/20230615113858 b/db/schema_migrations/20230615113858
new file mode 100644
index 00000000000..338d26a7f62
--- /dev/null
+++ b/db/schema_migrations/20230615113858
@@ -0,0 +1 @@
+c115e35b6b8f6e422bc1832671016f5956b524709aec36bb6d4d1707545d20d5 \ No newline at end of file
diff --git a/db/schema_migrations/20230615121103 b/db/schema_migrations/20230615121103
new file mode 100644
index 00000000000..9c77e1512c1
--- /dev/null
+++ b/db/schema_migrations/20230615121103
@@ -0,0 +1 @@
+37634ac8f82ed0fa043036b1aab2dffbd7a4f9a2fc51f18d53511f8a834eb312 \ No newline at end of file
diff --git a/db/schema_migrations/20230615121122 b/db/schema_migrations/20230615121122
new file mode 100644
index 00000000000..0704b5d0c8d
--- /dev/null
+++ b/db/schema_migrations/20230615121122
@@ -0,0 +1 @@
+7014d18db20d925d1bc41b4104b1ce57f2033f7c8debed8fd31e6afbba8efd78 \ No newline at end of file
diff --git a/db/schema_migrations/20230615144627 b/db/schema_migrations/20230615144627
new file mode 100644
index 00000000000..2baac116d9b
--- /dev/null
+++ b/db/schema_migrations/20230615144627
@@ -0,0 +1 @@
+1d9bf54e8214caefcc0a5f851c2a644df97f047b4cc9d3e7fe6e7ca34fef8f41 \ No newline at end of file
diff --git a/db/schema_migrations/20230616082958 b/db/schema_migrations/20230616082958
new file mode 100644
index 00000000000..6def484b012
--- /dev/null
+++ b/db/schema_migrations/20230616082958
@@ -0,0 +1 @@
+2155cb2efd8a43c774f48b4d87dddf9f6d5a33fb9c0ee804590e12b3713cc4dd \ No newline at end of file
diff --git a/db/schema_migrations/20230616164309 b/db/schema_migrations/20230616164309
new file mode 100644
index 00000000000..b9fbdc7d33e
--- /dev/null
+++ b/db/schema_migrations/20230616164309
@@ -0,0 +1 @@
+f3b14748f1702972e7f5069edd9ed25d9896dfb11f4fc4a4386ca9c94533e10a \ No newline at end of file
diff --git a/db/schema_migrations/20230616164705 b/db/schema_migrations/20230616164705
new file mode 100644
index 00000000000..1bcb723524b
--- /dev/null
+++ b/db/schema_migrations/20230616164705
@@ -0,0 +1 @@
+75310614bb98a598b8425aa87a0a4a6561fa1b166461d55329c21aff849d71fc \ No newline at end of file
diff --git a/db/schema_migrations/20230616164731 b/db/schema_migrations/20230616164731
new file mode 100644
index 00000000000..2588271d9ac
--- /dev/null
+++ b/db/schema_migrations/20230616164731
@@ -0,0 +1 @@
+e6308ee437b6e57da16e1b8aff1d6a571ef849c4c7cccafe940710c799fa6eea \ No newline at end of file
diff --git a/db/schema_migrations/20230616200440 b/db/schema_migrations/20230616200440
new file mode 100644
index 00000000000..b67a9da8a99
--- /dev/null
+++ b/db/schema_migrations/20230616200440
@@ -0,0 +1 @@
+de2c254df58e13ffba7fef9bbf4fff2e244aa46ce58f8245646ed7ce4ab51770 \ No newline at end of file
diff --git a/db/schema_migrations/20230616214220 b/db/schema_migrations/20230616214220
new file mode 100644
index 00000000000..7f006c6e985
--- /dev/null
+++ b/db/schema_migrations/20230616214220
@@ -0,0 +1 @@
+29cf1dfb1429cb177f5b6cb2fae2a0bc388c0c6cbda5c4405456afcee8374a54 \ No newline at end of file
diff --git a/db/schema_migrations/20230618020202 b/db/schema_migrations/20230618020202
new file mode 100644
index 00000000000..f07ea0b2994
--- /dev/null
+++ b/db/schema_migrations/20230618020202
@@ -0,0 +1 @@
+aedea1ec886b1831a94831185aa493e42c777c8c1614f6541580cdaa4f76946e \ No newline at end of file
diff --git a/db/schema_migrations/20230619005223 b/db/schema_migrations/20230619005223
new file mode 100644
index 00000000000..ce79f7ceed0
--- /dev/null
+++ b/db/schema_migrations/20230619005223
@@ -0,0 +1 @@
+e728befa42eb6749929e758ece0f29ec57cd7614a378b8c5e4dc24f134f39185 \ No newline at end of file
diff --git a/db/schema_migrations/20230619072744 b/db/schema_migrations/20230619072744
new file mode 100644
index 00000000000..ba71e5cd392
--- /dev/null
+++ b/db/schema_migrations/20230619072744
@@ -0,0 +1 @@
+6bf4fa6d2e43f1b589204f3b58323f32d9db2344882507e14bc487913cbe6f8e \ No newline at end of file
diff --git a/db/schema_migrations/20230619081412 b/db/schema_migrations/20230619081412
new file mode 100644
index 00000000000..e3a200aad1c
--- /dev/null
+++ b/db/schema_migrations/20230619081412
@@ -0,0 +1 @@
+31e437da1c65308037bace06492ac1995979abf061717aadb84dca22708dccff \ No newline at end of file
diff --git a/db/schema_migrations/20230619123701 b/db/schema_migrations/20230619123701
new file mode 100644
index 00000000000..f1bee23e3b9
--- /dev/null
+++ b/db/schema_migrations/20230619123701
@@ -0,0 +1 @@
+44dba614ff8883e5f8446e4c5f05964bb8ab7915d9caa06c908a9c24dd1dc1b1 \ No newline at end of file
diff --git a/db/schema_migrations/20230619134106 b/db/schema_migrations/20230619134106
new file mode 100644
index 00000000000..a23db7839fa
--- /dev/null
+++ b/db/schema_migrations/20230619134106
@@ -0,0 +1 @@
+248e7dabf83e225c5f5ee0de87e0842e8c3ec13f6098720830ce3b817a4d36a8 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072854 b/db/schema_migrations/20230620072854
new file mode 100644
index 00000000000..dd1b2f51792
--- /dev/null
+++ b/db/schema_migrations/20230620072854
@@ -0,0 +1 @@
+2cfb38d13f843e13b770e1598bb221555e09c05b785c30989626857a0dc396e8 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072856 b/db/schema_migrations/20230620072856
new file mode 100644
index 00000000000..614eb900d50
--- /dev/null
+++ b/db/schema_migrations/20230620072856
@@ -0,0 +1 @@
+f7917d437de6d3cc76c183c6682bf18b545ed5b10c2c1212dac46be6f5dfa505 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072900 b/db/schema_migrations/20230620072900
new file mode 100644
index 00000000000..e6f7bfe614d
--- /dev/null
+++ b/db/schema_migrations/20230620072900
@@ -0,0 +1 @@
+cdd264bae9968d1a54cdbd2a848161070c91e4fd25b55de072b4822d99bf9b09 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072905 b/db/schema_migrations/20230620072905
new file mode 100644
index 00000000000..14a8b5db052
--- /dev/null
+++ b/db/schema_migrations/20230620072905
@@ -0,0 +1 @@
+c846d009e014869a969ba637440bc7d8ea9482aac12a567e888dd69582c8467e \ No newline at end of file
diff --git a/db/schema_migrations/20230620072908 b/db/schema_migrations/20230620072908
new file mode 100644
index 00000000000..01a4fc67810
--- /dev/null
+++ b/db/schema_migrations/20230620072908
@@ -0,0 +1 @@
+39c8125b1d159ff84627cd897830dcbe7be87fe0675b6f6582380019de7d05e5 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072911 b/db/schema_migrations/20230620072911
new file mode 100644
index 00000000000..4010199d8fa
--- /dev/null
+++ b/db/schema_migrations/20230620072911
@@ -0,0 +1 @@
+d16c032a8dfaecb6fc61f00b273b539cf0ba6a27b36e6b8119e66c9ee323f4a1 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072915 b/db/schema_migrations/20230620072915
new file mode 100644
index 00000000000..9e8d8f80b0c
--- /dev/null
+++ b/db/schema_migrations/20230620072915
@@ -0,0 +1 @@
+c0a830c3fac01580d2e938fbbd618d6b28fba7f721bffb7861d4c2ac0206e862 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072917 b/db/schema_migrations/20230620072917
new file mode 100644
index 00000000000..ef80924ff25
--- /dev/null
+++ b/db/schema_migrations/20230620072917
@@ -0,0 +1 @@
+9ae676e0670c484b7ba385901d654eb6d05a9cedc550ee124121f0974158e2b3 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072920 b/db/schema_migrations/20230620072920
new file mode 100644
index 00000000000..37ee5e05783
--- /dev/null
+++ b/db/schema_migrations/20230620072920
@@ -0,0 +1 @@
+1fb33bd7af08a6213447e1f87531d4e285b69092ff5181276de0dfa9d1f40cc0 \ No newline at end of file
diff --git a/db/schema_migrations/20230620072925 b/db/schema_migrations/20230620072925
new file mode 100644
index 00000000000..46a5ca4c776
--- /dev/null
+++ b/db/schema_migrations/20230620072925
@@ -0,0 +1 @@
+fa58b6885924405f9556340ffc2625da5f94f4b68942bcca4927adc0fc74ebd7 \ No newline at end of file
diff --git a/db/schema_migrations/20230620101808 b/db/schema_migrations/20230620101808
new file mode 100644
index 00000000000..ecb74b18870
--- /dev/null
+++ b/db/schema_migrations/20230620101808
@@ -0,0 +1 @@
+8c797f079ce4536559bbe73b9c18540f5793dc725eb970ac23bfeb1578f8adc2 \ No newline at end of file
diff --git a/db/schema_migrations/20230620104217 b/db/schema_migrations/20230620104217
new file mode 100644
index 00000000000..f07e758bdbd
--- /dev/null
+++ b/db/schema_migrations/20230620104217
@@ -0,0 +1 @@
+cd2692308d23e12450ff96bf7a0cde9866b8d920babc1187e9e4b50fa5b2d43a \ No newline at end of file
diff --git a/db/schema_migrations/20230620105919 b/db/schema_migrations/20230620105919
new file mode 100644
index 00000000000..b5922e4afc3
--- /dev/null
+++ b/db/schema_migrations/20230620105919
@@ -0,0 +1 @@
+fa1729c74f96263143b15e9a08fd4bf723dd55a75ee295ff7390020030fc1355 \ No newline at end of file
diff --git a/db/schema_migrations/20230620110004 b/db/schema_migrations/20230620110004
new file mode 100644
index 00000000000..4bfe9bdc623
--- /dev/null
+++ b/db/schema_migrations/20230620110004
@@ -0,0 +1 @@
+ca9564bcb051593478180c42c107be4f49a31df4a15ada3cba52a5779754b812 \ No newline at end of file
diff --git a/db/schema_migrations/20230620110021 b/db/schema_migrations/20230620110021
new file mode 100644
index 00000000000..646362e1905
--- /dev/null
+++ b/db/schema_migrations/20230620110021
@@ -0,0 +1 @@
+2ba72a003cb2a6560caa1351dc46113f370a59767c629127da6f7bfe43b8cbde \ No newline at end of file
diff --git a/db/schema_migrations/20230620134708 b/db/schema_migrations/20230620134708
new file mode 100644
index 00000000000..2a5da955fe1
--- /dev/null
+++ b/db/schema_migrations/20230620134708
@@ -0,0 +1 @@
+5380771d2c97c44978ff78a310f682b185d97c56d80620ccda4322a22d000978 \ No newline at end of file
diff --git a/db/schema_migrations/20230620201738 b/db/schema_migrations/20230620201738
new file mode 100644
index 00000000000..1bc9933c362
--- /dev/null
+++ b/db/schema_migrations/20230620201738
@@ -0,0 +1 @@
+99ee0372604bb5cd0778407b4af5ff2971136583166e90aba37fadd8e90e4109 \ No newline at end of file
diff --git a/db/schema_migrations/20230620201817 b/db/schema_migrations/20230620201817
new file mode 100644
index 00000000000..04ab99b2d9b
--- /dev/null
+++ b/db/schema_migrations/20230620201817
@@ -0,0 +1 @@
+a4b69d82118f3cacd310a3dc369769e5ea767e763852ac4a27c138bccd500990 \ No newline at end of file
diff --git a/db/schema_migrations/20230621065943 b/db/schema_migrations/20230621065943
new file mode 100644
index 00000000000..4c918e07f34
--- /dev/null
+++ b/db/schema_migrations/20230621065943
@@ -0,0 +1 @@
+f51d14579ace7c0b843c1371086218770c2c2083fec5d1088a49bf9bd6c6e572 \ No newline at end of file
diff --git a/db/schema_migrations/20230621070810 b/db/schema_migrations/20230621070810
new file mode 100644
index 00000000000..e080764583d
--- /dev/null
+++ b/db/schema_migrations/20230621070810
@@ -0,0 +1 @@
+87393271016f643e4df201322e26f703ce9cf74d2189f0e0e586ff48697f994a \ No newline at end of file
diff --git a/db/schema_migrations/20230621072726 b/db/schema_migrations/20230621072726
new file mode 100644
index 00000000000..333aeda18b3
--- /dev/null
+++ b/db/schema_migrations/20230621072726
@@ -0,0 +1 @@
+56bf488ec781f8db5ec1723c6a749c0d80140781a1eb3a07984abeddd7d6e88e \ No newline at end of file
diff --git a/db/schema_migrations/20230621072848 b/db/schema_migrations/20230621072848
new file mode 100644
index 00000000000..0c69a850bd5
--- /dev/null
+++ b/db/schema_migrations/20230621072848
@@ -0,0 +1 @@
+4add5ff0aacac0f287e7aad63a5c0361091d9467bbabc03117750fdbd83681b5 \ No newline at end of file
diff --git a/db/schema_migrations/20230621074446 b/db/schema_migrations/20230621074446
new file mode 100644
index 00000000000..6344e8a2153
--- /dev/null
+++ b/db/schema_migrations/20230621074446
@@ -0,0 +1 @@
+f40ca52d92fd6c2c3a64b5b3c46c46f1f690b67b5320e84f55f62d4723c7d7e6 \ No newline at end of file
diff --git a/db/schema_migrations/20230621074611 b/db/schema_migrations/20230621074611
new file mode 100644
index 00000000000..4a7ac63ed34
--- /dev/null
+++ b/db/schema_migrations/20230621074611
@@ -0,0 +1 @@
+b44a08db74d15671a63afff9c41da67c0486c57bb893dc147ae073d78541457c \ No newline at end of file
diff --git a/db/schema_migrations/20230621083004 b/db/schema_migrations/20230621083004
new file mode 100644
index 00000000000..9cf899b3495
--- /dev/null
+++ b/db/schema_migrations/20230621083004
@@ -0,0 +1 @@
+e5b653b4cdee96f1160950ca6885609f393d49f9b7a4cdd3be3e1dac07fc3add \ No newline at end of file
diff --git a/db/schema_migrations/20230621083052 b/db/schema_migrations/20230621083052
new file mode 100644
index 00000000000..edd3c6df2fe
--- /dev/null
+++ b/db/schema_migrations/20230621083052
@@ -0,0 +1 @@
+7aa6e43678d3e7421fc80c6705daab68c219fa715b8a18ef6c9fdc5df304f8c0 \ No newline at end of file
diff --git a/db/schema_migrations/20230621102941 b/db/schema_migrations/20230621102941
new file mode 100644
index 00000000000..10d052d6055
--- /dev/null
+++ b/db/schema_migrations/20230621102941
@@ -0,0 +1 @@
+d7e664cb16c66f72c409a5738a48f06a5b56d52409cd41095dedab7f5e9ea065 \ No newline at end of file
diff --git a/db/schema_migrations/20230621103000 b/db/schema_migrations/20230621103000
new file mode 100644
index 00000000000..1d0aee1217e
--- /dev/null
+++ b/db/schema_migrations/20230621103000
@@ -0,0 +1 @@
+9d96b459795c8850ada522769855e2ab6c554ea774a78272baf1db873589f556 \ No newline at end of file
diff --git a/db/schema_migrations/20230621103043 b/db/schema_migrations/20230621103043
new file mode 100644
index 00000000000..707105b67c4
--- /dev/null
+++ b/db/schema_migrations/20230621103043
@@ -0,0 +1 @@
+b1c7f95cfa972fb23c536d5607b9b1d067e0e8af9e8036170cba6ca913a9c9e0 \ No newline at end of file
diff --git a/db/schema_migrations/20230622044119 b/db/schema_migrations/20230622044119
new file mode 100644
index 00000000000..31c5297f030
--- /dev/null
+++ b/db/schema_migrations/20230622044119
@@ -0,0 +1 @@
+b95691099886021c131b3ef04ce21a5610a31a635e9a95eee1d31a558b7dae8b \ No newline at end of file
diff --git a/db/schema_migrations/20230622051925 b/db/schema_migrations/20230622051925
new file mode 100644
index 00000000000..54d986fde1d
--- /dev/null
+++ b/db/schema_migrations/20230622051925
@@ -0,0 +1 @@
+c171fb3fd46cd8b015bc173e94e3e413aefb9a2afa58d556e357454717978313 \ No newline at end of file
diff --git a/db/schema_migrations/20230622051943 b/db/schema_migrations/20230622051943
new file mode 100644
index 00000000000..206327d89c2
--- /dev/null
+++ b/db/schema_migrations/20230622051943
@@ -0,0 +1 @@
+be537d6f8024b067c302cd96429d1bccca410c13c9ea4392c0642af4ddd4eb19 \ No newline at end of file
diff --git a/db/schema_migrations/20230622052015 b/db/schema_migrations/20230622052015
new file mode 100644
index 00000000000..d25ccb2099e
--- /dev/null
+++ b/db/schema_migrations/20230622052015
@@ -0,0 +1 @@
+6d6e5a996e7a7abcf5f1b6e019a8e86a3d4e9aab0052c6f7620ff02091527229 \ No newline at end of file
diff --git a/db/schema_migrations/20230622052046 b/db/schema_migrations/20230622052046
new file mode 100644
index 00000000000..7faab404d2b
--- /dev/null
+++ b/db/schema_migrations/20230622052046
@@ -0,0 +1 @@
+2649850f5ea46578753c4b6d30cbc64e40d1b0f85d24b1de58791d21d1837379 \ No newline at end of file
diff --git a/db/schema_migrations/20230622073752 b/db/schema_migrations/20230622073752
new file mode 100644
index 00000000000..5dcd11379dc
--- /dev/null
+++ b/db/schema_migrations/20230622073752
@@ -0,0 +1 @@
+0bf41a90a42bd448727459b22f94b24f78e933fc2f5d1f4b27cf37c40cc7bbe6 \ No newline at end of file
diff --git a/db/schema_migrations/20230622093921 b/db/schema_migrations/20230622093921
new file mode 100644
index 00000000000..696104cce80
--- /dev/null
+++ b/db/schema_migrations/20230622093921
@@ -0,0 +1 @@
+1947fe30ac91f67fc863879e4adbc46dbe6ef84c9daa7de8133a81a15eb0e6ce \ No newline at end of file
diff --git a/db/schema_migrations/20230623073906 b/db/schema_migrations/20230623073906
new file mode 100644
index 00000000000..0783428a741
--- /dev/null
+++ b/db/schema_migrations/20230623073906
@@ -0,0 +1 @@
+d76cadfee80a039889d8abe1a0d62f37db683d7c82f7b2bc9a5882af6c65cdf9 \ No newline at end of file
diff --git a/db/schema_migrations/20230626065725 b/db/schema_migrations/20230626065725
new file mode 100644
index 00000000000..5e0d178a73b
--- /dev/null
+++ b/db/schema_migrations/20230626065725
@@ -0,0 +1 @@
+1f9cc4c9d10fa666d5c30dcf7752cac335878565b8e49084960a9fc137be98fc \ No newline at end of file
diff --git a/db/schema_migrations/20230626065755 b/db/schema_migrations/20230626065755
new file mode 100644
index 00000000000..491f61fe3ec
--- /dev/null
+++ b/db/schema_migrations/20230626065755
@@ -0,0 +1 @@
+1284418dccf0e96d281f9ffea3048fc74d145be9ea1f20e443c91707559105d9 \ No newline at end of file
diff --git a/db/schema_migrations/20230626070723 b/db/schema_migrations/20230626070723
new file mode 100644
index 00000000000..c0528c8a9b5
--- /dev/null
+++ b/db/schema_migrations/20230626070723
@@ -0,0 +1 @@
+3154c7f63689ab430342229b526380cdc02ab9e11f855cf914cb382ba2850ab1 \ No newline at end of file
diff --git a/db/schema_migrations/20230626070959 b/db/schema_migrations/20230626070959
new file mode 100644
index 00000000000..3445b9e6f2e
--- /dev/null
+++ b/db/schema_migrations/20230626070959
@@ -0,0 +1 @@
+fe4406579d2f6be5e422ce359cf7995d4d601088c85d04b9c0d7b95d41111e23 \ No newline at end of file
diff --git a/db/schema_migrations/20230626071100 b/db/schema_migrations/20230626071100
new file mode 100644
index 00000000000..60c3b5c045d
--- /dev/null
+++ b/db/schema_migrations/20230626071100
@@ -0,0 +1 @@
+4cab810df6576b2daf0264b961180cffb581c6b421c53d88c69ebfa4ecd90bc5 \ No newline at end of file
diff --git a/db/schema_migrations/20230626072436 b/db/schema_migrations/20230626072436
new file mode 100644
index 00000000000..1800699ff54
--- /dev/null
+++ b/db/schema_migrations/20230626072436
@@ -0,0 +1 @@
+7169f6ef838ca3992d32b92a8cda4063d147c7ffe64cc382d69ae92eca525d0b \ No newline at end of file
diff --git a/db/schema_migrations/20230626101519 b/db/schema_migrations/20230626101519
new file mode 100644
index 00000000000..874d3eec0ee
--- /dev/null
+++ b/db/schema_migrations/20230626101519
@@ -0,0 +1 @@
+7060d1ed7be6fce2e398d9ac042d6e67826742e639df8eee43245d66b8b87ea3 \ No newline at end of file
diff --git a/db/schema_migrations/20230626113908 b/db/schema_migrations/20230626113908
new file mode 100644
index 00000000000..2d3f3205189
--- /dev/null
+++ b/db/schema_migrations/20230626113908
@@ -0,0 +1 @@
+542e2345a171e46512d793cc764fdbb279d9bf40e65e021d249953b29ff66dcb \ No newline at end of file
diff --git a/db/schema_migrations/20230626113909 b/db/schema_migrations/20230626113909
new file mode 100644
index 00000000000..2edeec73a10
--- /dev/null
+++ b/db/schema_migrations/20230626113909
@@ -0,0 +1 @@
+633753a79a9d4f251c89b7fdbbf5fa17d2c85ceba091c450d377ab4e50bd9bce \ No newline at end of file
diff --git a/db/schema_migrations/20230626113910 b/db/schema_migrations/20230626113910
new file mode 100644
index 00000000000..ee86f5c77c4
--- /dev/null
+++ b/db/schema_migrations/20230626113910
@@ -0,0 +1 @@
+a702fd86f25c3044e7eb8195349aec6f0627e258946c996164880c0f72998176 \ No newline at end of file
diff --git a/db/schema_migrations/20230626115046 b/db/schema_migrations/20230626115046
new file mode 100644
index 00000000000..f33fe2cb20d
--- /dev/null
+++ b/db/schema_migrations/20230626115046
@@ -0,0 +1 @@
+ebc346341318ad1c6f3d10876d2a7ee1943f8795a407f0048d4cc92b4efba431 \ No newline at end of file
diff --git a/db/schema_migrations/20230627115305 b/db/schema_migrations/20230627115305
new file mode 100644
index 00000000000..148cbb9c6a9
--- /dev/null
+++ b/db/schema_migrations/20230627115305
@@ -0,0 +1 @@
+7c2149b427416d98e8fdacf703b4c100d135546bf700fbc06561c7dd74a60918 \ No newline at end of file
diff --git a/db/schema_migrations/20230627140707 b/db/schema_migrations/20230627140707
new file mode 100644
index 00000000000..39739131a93
--- /dev/null
+++ b/db/schema_migrations/20230627140707
@@ -0,0 +1 @@
+9568e3084ed45c6a818dbf4aa9d88b9489beac706f15e470e022cde38b97a327 \ No newline at end of file
diff --git a/db/schema_migrations/20230627174139 b/db/schema_migrations/20230627174139
new file mode 100644
index 00000000000..af37ba0baaa
--- /dev/null
+++ b/db/schema_migrations/20230627174139
@@ -0,0 +1 @@
+22ab53f5c190f37f37a3e3e57742b1dde3c0c724492b63f938bfdcb7c2a09fa1 \ No newline at end of file
diff --git a/db/schema_migrations/20230628023103 b/db/schema_migrations/20230628023103
new file mode 100644
index 00000000000..57a9e342467
--- /dev/null
+++ b/db/schema_migrations/20230628023103
@@ -0,0 +1 @@
+59e4b358359514dbb49b2b73c829a99f646100442f02aa36287935d6e8fa76ab \ No newline at end of file
diff --git a/db/schema_migrations/20230629011859 b/db/schema_migrations/20230629011859
new file mode 100644
index 00000000000..310d898c2ed
--- /dev/null
+++ b/db/schema_migrations/20230629011859
@@ -0,0 +1 @@
+ad9a274264ce640df6c8d3c035b34de960766b7ff71095c6ad63e882cc4a3d5a \ No newline at end of file
diff --git a/db/schema_migrations/20230629024032 b/db/schema_migrations/20230629024032
new file mode 100644
index 00000000000..f1ca84565e1
--- /dev/null
+++ b/db/schema_migrations/20230629024032
@@ -0,0 +1 @@
+5d66f87307ec80cd7695646b69a2002b4f78d892d8ce30f9de7d2583a6233ae7 \ No newline at end of file
diff --git a/db/schema_migrations/20230629024403 b/db/schema_migrations/20230629024403
new file mode 100644
index 00000000000..24d68f7c38a
--- /dev/null
+++ b/db/schema_migrations/20230629024403
@@ -0,0 +1 @@
+3de2d94ddd3f3df3ba8d0aefb4ad137c586abcc4fef065074c4087d866a0420d \ No newline at end of file
diff --git a/db/schema_migrations/20230629071427 b/db/schema_migrations/20230629071427
new file mode 100644
index 00000000000..6312e130669
--- /dev/null
+++ b/db/schema_migrations/20230629071427
@@ -0,0 +1 @@
+4f11acd2381e999cf81c7fe05a75f718a4ef735b7ada01140af67a5a1282e909 \ No newline at end of file
diff --git a/db/schema_migrations/20230629095819 b/db/schema_migrations/20230629095819
new file mode 100644
index 00000000000..13c1b53ca4b
--- /dev/null
+++ b/db/schema_migrations/20230629095819
@@ -0,0 +1 @@
+4e169ac2e0dd9df9f3f8ebf6041189ccdde1d683d9e64ced6743abdcc22eea7b \ No newline at end of file
diff --git a/db/schema_migrations/20230629112833 b/db/schema_migrations/20230629112833
new file mode 100644
index 00000000000..f147e88a01d
--- /dev/null
+++ b/db/schema_migrations/20230629112833
@@ -0,0 +1 @@
+90b19651bc3f69a2e104a94ec4b9c4a758b4e258b49dad19b9795d1574c51946 \ No newline at end of file
diff --git a/db/schema_migrations/20230629113029 b/db/schema_migrations/20230629113029
new file mode 100644
index 00000000000..b0908feca28
--- /dev/null
+++ b/db/schema_migrations/20230629113029
@@ -0,0 +1 @@
+1cca0c19cc117465e14bf52ad8aadbf61c4c6e4c3fbc17a77138dd1f40fad902 \ No newline at end of file
diff --git a/db/schema_migrations/20230629113133 b/db/schema_migrations/20230629113133
new file mode 100644
index 00000000000..56f6c7e167e
--- /dev/null
+++ b/db/schema_migrations/20230629113133
@@ -0,0 +1 @@
+fc7195a78541583e95a007594b393d0cd67f942c275efb8a43c6953128e8b4ec \ No newline at end of file
diff --git a/db/schema_migrations/20230630101337 b/db/schema_migrations/20230630101337
new file mode 100644
index 00000000000..1473c1bf651
--- /dev/null
+++ b/db/schema_migrations/20230630101337
@@ -0,0 +1 @@
+53020e29ac265baaca73fe0b5e861d3bafbadc7cc082ac49f766ba7f4e5ae912 \ No newline at end of file
diff --git a/db/schema_migrations/20230630101342 b/db/schema_migrations/20230630101342
new file mode 100644
index 00000000000..a8fdc05fabc
--- /dev/null
+++ b/db/schema_migrations/20230630101342
@@ -0,0 +1 @@
+6b3518efb850118b371ae2806557201ba3fa657a6d631d1225feaf77fe6dff85 \ No newline at end of file
diff --git a/db/schema_migrations/20230630101347 b/db/schema_migrations/20230630101347
new file mode 100644
index 00000000000..aa87ba3ebf9
--- /dev/null
+++ b/db/schema_migrations/20230630101347
@@ -0,0 +1 @@
+f1413f18b4efc28d0f23582a7a6bc0f27b1bb44eb44d471561cf6447410158cf \ No newline at end of file
diff --git a/db/schema_migrations/20230630170515 b/db/schema_migrations/20230630170515
new file mode 100644
index 00000000000..7c0f42235af
--- /dev/null
+++ b/db/schema_migrations/20230630170515
@@ -0,0 +1 @@
+838865785ae99586e6c4017b5c51dee845208501a66fd4a3890641be0c076dfc \ No newline at end of file
diff --git a/db/schema_migrations/20230701195315 b/db/schema_migrations/20230701195315
new file mode 100644
index 00000000000..fab65f8edb9
--- /dev/null
+++ b/db/schema_migrations/20230701195315
@@ -0,0 +1 @@
+5aa32c9cc47402adbb622bb7e8a2cd4f7714973d25a5b787c1156f3dee517433 \ No newline at end of file
diff --git a/db/schema_migrations/20230703024031 b/db/schema_migrations/20230703024031
new file mode 100644
index 00000000000..4e68e593e67
--- /dev/null
+++ b/db/schema_migrations/20230703024031
@@ -0,0 +1 @@
+bfbb862d6d7c54ebfa110a6266c99b9c264f4ae2d4c3b9cf07d47beb642bbb2b \ No newline at end of file
diff --git a/db/schema_migrations/20230703115902 b/db/schema_migrations/20230703115902
new file mode 100644
index 00000000000..471eb5becbb
--- /dev/null
+++ b/db/schema_migrations/20230703115902
@@ -0,0 +1 @@
+8a16b05cd573528b6e8baa2d86e761a2b431584c026918e3eda9a630b30ec727 \ No newline at end of file
diff --git a/db/schema_migrations/20230703121859 b/db/schema_migrations/20230703121859
new file mode 100644
index 00000000000..f72e3201352
--- /dev/null
+++ b/db/schema_migrations/20230703121859
@@ -0,0 +1 @@
+149cdb7863460246fb89d02d3c8e1709bdb1d38378304d44c9a916c4bd4ee4ed \ No newline at end of file
diff --git a/db/schema_migrations/20230703122803 b/db/schema_migrations/20230703122803
new file mode 100644
index 00000000000..18e7e752956
--- /dev/null
+++ b/db/schema_migrations/20230703122803
@@ -0,0 +1 @@
+af0a79450261909c0280ea5a7c747c5ec997062f33c0f2bc75891c2e99f61da8 \ No newline at end of file
diff --git a/db/schema_migrations/20230704042302 b/db/schema_migrations/20230704042302
new file mode 100644
index 00000000000..0a016cd7bb2
--- /dev/null
+++ b/db/schema_migrations/20230704042302
@@ -0,0 +1 @@
+d4c93417aef4587ba892f81b0339c5213cd6b5270478edcb1378138fd74e2787 \ No newline at end of file
diff --git a/db/schema_migrations/20230704044541 b/db/schema_migrations/20230704044541
new file mode 100644
index 00000000000..1d0765f22b4
--- /dev/null
+++ b/db/schema_migrations/20230704044541
@@ -0,0 +1 @@
+a10daabd1b354eaea1a6fb6c4b709d137e096c6aa667dea16f82661f20b716a3 \ No newline at end of file
diff --git a/db/schema_migrations/20230704050739 b/db/schema_migrations/20230704050739
new file mode 100644
index 00000000000..b19ba35fc6e
--- /dev/null
+++ b/db/schema_migrations/20230704050739
@@ -0,0 +1 @@
+93c012068f6f6f025cc2ed1c5670f0704010e13f1eec1bff6c5fb917ec6549a0 \ No newline at end of file
diff --git a/db/schema_migrations/20230704062132 b/db/schema_migrations/20230704062132
new file mode 100644
index 00000000000..807788250b0
--- /dev/null
+++ b/db/schema_migrations/20230704062132
@@ -0,0 +1 @@
+b103d237ee15e12602d656dca33abde5e6849ac4e81df606ba5578db9023f890 \ No newline at end of file
diff --git a/db/schema_migrations/20230704062136 b/db/schema_migrations/20230704062136
new file mode 100644
index 00000000000..62964934621
--- /dev/null
+++ b/db/schema_migrations/20230704062136
@@ -0,0 +1 @@
+74a1d7edb1319534d2853fc94726dae0e28944395c2fb30e0fc4597eb5ba1330 \ No newline at end of file
diff --git a/db/schema_migrations/20230704074120 b/db/schema_migrations/20230704074120
new file mode 100644
index 00000000000..c411bda0d73
--- /dev/null
+++ b/db/schema_migrations/20230704074120
@@ -0,0 +1 @@
+ec9cd530b8fe033c16865adf6494cc3e568c4bfa513e616398da737a68291cb5 \ No newline at end of file
diff --git a/db/schema_migrations/20230704074124 b/db/schema_migrations/20230704074124
new file mode 100644
index 00000000000..d672b7db2ef
--- /dev/null
+++ b/db/schema_migrations/20230704074124
@@ -0,0 +1 @@
+d7f3642897ee44f18c2b809f3936a951c715f3021454349117e22e387d18945a \ No newline at end of file
diff --git a/db/schema_migrations/20230705085223 b/db/schema_migrations/20230705085223
new file mode 100644
index 00000000000..cdbed593c44
--- /dev/null
+++ b/db/schema_migrations/20230705085223
@@ -0,0 +1 @@
+dd4cb988fa1451dfac5f6c4ae0990be05472d1a8beee05fdd18a9bc137f07ee2 \ No newline at end of file
diff --git a/db/schema_migrations/20230705092150 b/db/schema_migrations/20230705092150
new file mode 100644
index 00000000000..96e51e689e2
--- /dev/null
+++ b/db/schema_migrations/20230705092150
@@ -0,0 +1 @@
+5954829dd244b4536beeb9b92a157539feb5207bc1309e177310895f269f54d8 \ No newline at end of file
diff --git a/db/schema_migrations/20230705115215 b/db/schema_migrations/20230705115215
new file mode 100644
index 00000000000..ec12c32117d
--- /dev/null
+++ b/db/schema_migrations/20230705115215
@@ -0,0 +1 @@
+3035da4873093dd7c8cee94398c3b4a70a696e1e765d102cfe657b53e3b65be9 \ No newline at end of file
diff --git a/db/schema_migrations/20230705141703 b/db/schema_migrations/20230705141703
new file mode 100644
index 00000000000..51c3cd350c1
--- /dev/null
+++ b/db/schema_migrations/20230705141703
@@ -0,0 +1 @@
+dafb3395a28180da275eceddb87af4deb0008b2d0793dd0ea3f34d2ae8bd5c10 \ No newline at end of file
diff --git a/db/schema_migrations/20230705141733 b/db/schema_migrations/20230705141733
new file mode 100644
index 00000000000..2b5870f2ba5
--- /dev/null
+++ b/db/schema_migrations/20230705141733
@@ -0,0 +1 @@
+2cea22d62a5a08a643b3043bea1e14e4965f57201db559995cab8616d7586f55 \ No newline at end of file
diff --git a/db/schema_migrations/20230705142241 b/db/schema_migrations/20230705142241
new file mode 100644
index 00000000000..4d4ee24d798
--- /dev/null
+++ b/db/schema_migrations/20230705142241
@@ -0,0 +1 @@
+ae094cd61e252b30c1ebe0e5369ff2c061aa96079bbc1addde160003e2263886 \ No newline at end of file
diff --git a/db/schema_migrations/20230705142334 b/db/schema_migrations/20230705142334
new file mode 100644
index 00000000000..ace38aed2f7
--- /dev/null
+++ b/db/schema_migrations/20230705142334
@@ -0,0 +1 @@
+33de9f678eb493070ceaae0e50461cffbcdbb5a542740b9fc595cba2c8c32808 \ No newline at end of file
diff --git a/db/schema_migrations/20230705145827 b/db/schema_migrations/20230705145827
new file mode 100644
index 00000000000..48bf419a084
--- /dev/null
+++ b/db/schema_migrations/20230705145827
@@ -0,0 +1 @@
+c6bd06a0e306916809474790126ba90089c8f0dd8d25e3858f2e7b416996c9c8 \ No newline at end of file
diff --git a/db/schema_migrations/20230705150100 b/db/schema_migrations/20230705150100
new file mode 100644
index 00000000000..07da63247f9
--- /dev/null
+++ b/db/schema_migrations/20230705150100
@@ -0,0 +1 @@
+62ea862f8911a5114cfa8140862e1a3c5be7cf4f80064d72c453f8c81d8a7623 \ No newline at end of file
diff --git a/db/schema_migrations/20230705155000 b/db/schema_migrations/20230705155000
new file mode 100644
index 00000000000..e2f6d13e31e
--- /dev/null
+++ b/db/schema_migrations/20230705155000
@@ -0,0 +1 @@
+4f3d64c52ac1b46bab194be78cadeaa36abf3faf26de1c7d7ca3c03cc64b876f \ No newline at end of file
diff --git a/db/schema_migrations/20230706011541 b/db/schema_migrations/20230706011541
new file mode 100644
index 00000000000..4cebe9198b3
--- /dev/null
+++ b/db/schema_migrations/20230706011541
@@ -0,0 +1 @@
+fad04601d706468f7e77a232e07125c152373f9fe2c443a661e0d5ee68ea6e7b \ No newline at end of file
diff --git a/db/schema_migrations/20230706073937 b/db/schema_migrations/20230706073937
new file mode 100644
index 00000000000..56c214818d7
--- /dev/null
+++ b/db/schema_migrations/20230706073937
@@ -0,0 +1 @@
+e7cf459527a96936684778c46bfc3b3490d314f4dbf5e3a3daca8670f1fcaeaf \ No newline at end of file
diff --git a/db/schema_migrations/20230706080234 b/db/schema_migrations/20230706080234
new file mode 100644
index 00000000000..a188efbf3ca
--- /dev/null
+++ b/db/schema_migrations/20230706080234
@@ -0,0 +1 @@
+a76b57ff9a9e62c1e8d73c46a9bdf6512f0fe48d3b95b4c9a291d602d54d7a33 \ No newline at end of file
diff --git a/db/schema_migrations/20230706130217 b/db/schema_migrations/20230706130217
new file mode 100644
index 00000000000..8d2a74a3fc2
--- /dev/null
+++ b/db/schema_migrations/20230706130217
@@ -0,0 +1 @@
+3a355ebb2299786d9aa5ce9bf1f07b2bbd3b6aca719c12c78c4a945c4a96cfe3 \ No newline at end of file
diff --git a/db/schema_migrations/20230706192435 b/db/schema_migrations/20230706192435
new file mode 100644
index 00000000000..190b795da80
--- /dev/null
+++ b/db/schema_migrations/20230706192435
@@ -0,0 +1 @@
+92018d19330a9808bf1ee93c8a950d68794213fb600b040ebe5fbb7420c0d1f0 \ No newline at end of file
diff --git a/db/schema_migrations/20230707090835 b/db/schema_migrations/20230707090835
new file mode 100644
index 00000000000..8add6e8e125
--- /dev/null
+++ b/db/schema_migrations/20230707090835
@@ -0,0 +1 @@
+500559ce2b6a3ef8dbf33c6e1ebd1e11b4645d19b52139eaa247fc06c00a1f7c \ No newline at end of file
diff --git a/db/schema_migrations/20230707094002 b/db/schema_migrations/20230707094002
new file mode 100644
index 00000000000..1d19e5bc29e
--- /dev/null
+++ b/db/schema_migrations/20230707094002
@@ -0,0 +1 @@
+7e946c03c02800868016387682c3f4146edcd604c8007747ff64b6e4ef4badb2 \ No newline at end of file
diff --git a/db/schema_migrations/20230707094003 b/db/schema_migrations/20230707094003
new file mode 100644
index 00000000000..56442a983ee
--- /dev/null
+++ b/db/schema_migrations/20230707094003
@@ -0,0 +1 @@
+bf71e6fec331ea1b38a79fc376f63ce30c896f197ffa335b0ec8a914317a391f \ No newline at end of file
diff --git a/db/schema_migrations/20230707114012 b/db/schema_migrations/20230707114012
new file mode 100644
index 00000000000..b9525ad8a67
--- /dev/null
+++ b/db/schema_migrations/20230707114012
@@ -0,0 +1 @@
+dc0b3017e7dc807b18382cc0a19725be652eea6210c4b5b716093557deace62d \ No newline at end of file
diff --git a/db/schema_migrations/20230707211358 b/db/schema_migrations/20230707211358
new file mode 100644
index 00000000000..2f1f6a3d370
--- /dev/null
+++ b/db/schema_migrations/20230707211358
@@ -0,0 +1 @@
+1f2ae1ac4c26b8fe257c158e9c1b9a99a590176e8566d7b9f22c4265177c861a \ No newline at end of file
diff --git a/db/schema_migrations/20230707211359 b/db/schema_migrations/20230707211359
new file mode 100644
index 00000000000..00cc079594c
--- /dev/null
+++ b/db/schema_migrations/20230707211359
@@ -0,0 +1 @@
+7b319745b746418deedc6130cf6ed2860e0c4a01af9b15548dfacac314cdabe2 \ No newline at end of file
diff --git a/db/schema_migrations/20230707220646 b/db/schema_migrations/20230707220646
new file mode 100644
index 00000000000..7577fce9131
--- /dev/null
+++ b/db/schema_migrations/20230707220646
@@ -0,0 +1 @@
+6f801df7ed92d70e6f603d36b8c23c4e133e09b05040f848ca8d71581b8a793f \ No newline at end of file
diff --git a/db/schema_migrations/20230710160232 b/db/schema_migrations/20230710160232
new file mode 100644
index 00000000000..08f2ba7fa32
--- /dev/null
+++ b/db/schema_migrations/20230710160232
@@ -0,0 +1 @@
+1f894fea060c0abee05799f161665214d66c8e8f0509b464b2bf6a35964f457b \ No newline at end of file
diff --git a/db/schema_migrations/20230710200434 b/db/schema_migrations/20230710200434
new file mode 100644
index 00000000000..f58e9cdc060
--- /dev/null
+++ b/db/schema_migrations/20230710200434
@@ -0,0 +1 @@
+ee8f60421aed0a748b55efce7292c319159f21d9112cd61012a771654f70a769 \ No newline at end of file
diff --git a/db/schema_migrations/20230711093010 b/db/schema_migrations/20230711093010
new file mode 100644
index 00000000000..7fcdd69e7df
--- /dev/null
+++ b/db/schema_migrations/20230711093010
@@ -0,0 +1 @@
+1634c4bbe3fd813098a4865db2d84e83fd9eac967723c4500da4c78e9255af46 \ No newline at end of file
diff --git a/db/schema_migrations/20230712020407 b/db/schema_migrations/20230712020407
new file mode 100644
index 00000000000..d31382ed737
--- /dev/null
+++ b/db/schema_migrations/20230712020407
@@ -0,0 +1 @@
+3dc44ced12562d7846fcdc0ad956993705b13f0ecc2418d6ef1853337eea2fff \ No newline at end of file
diff --git a/db/schema_migrations/20230712064637 b/db/schema_migrations/20230712064637
new file mode 100644
index 00000000000..7b541ed714d
--- /dev/null
+++ b/db/schema_migrations/20230712064637
@@ -0,0 +1 @@
+b39d83cc2257d75ece3dfa1c5f6faa1ef6eb1c40d3de0a1899a2860d5a1c7ed1 \ No newline at end of file
diff --git a/db/schema_migrations/20230712064655 b/db/schema_migrations/20230712064655
new file mode 100644
index 00000000000..860b5183a04
--- /dev/null
+++ b/db/schema_migrations/20230712064655
@@ -0,0 +1 @@
+25d0b4c560dcec564a268d96e969b07fbfe18f1d902fdafe415cf747bdb1302c \ No newline at end of file
diff --git a/db/schema_migrations/20230712145323 b/db/schema_migrations/20230712145323
new file mode 100644
index 00000000000..00d938eb599
--- /dev/null
+++ b/db/schema_migrations/20230712145323
@@ -0,0 +1 @@
+3102bb4fb27322ca9a0b2f60757a0bb90d7fce74a8607226f2e2bcf336563ceb \ No newline at end of file
diff --git a/db/schema_migrations/20230712145821 b/db/schema_migrations/20230712145821
new file mode 100644
index 00000000000..8282462f0de
--- /dev/null
+++ b/db/schema_migrations/20230712145821
@@ -0,0 +1 @@
+cf697183d364abeab6c9701f51db570f153d88949b51a8e157a502c0a38f007e \ No newline at end of file
diff --git a/db/schema_migrations/20230712145926 b/db/schema_migrations/20230712145926
new file mode 100644
index 00000000000..b0666ce0cf6
--- /dev/null
+++ b/db/schema_migrations/20230712145926
@@ -0,0 +1 @@
+992137f8611e57d44b4b3a861fce07353f0eccfafa894dd3cede02554bcde424 \ No newline at end of file
diff --git a/db/schema_migrations/20230712214613 b/db/schema_migrations/20230712214613
new file mode 100644
index 00000000000..f9afbe825d6
--- /dev/null
+++ b/db/schema_migrations/20230712214613
@@ -0,0 +1 @@
+56415a907d3bba749b9d42b5f37919981e779f0422c86793028d128350875f2d \ No newline at end of file
diff --git a/db/schema_migrations/20230713020247 b/db/schema_migrations/20230713020247
new file mode 100644
index 00000000000..a11206d6e55
--- /dev/null
+++ b/db/schema_migrations/20230713020247
@@ -0,0 +1 @@
+8fcab29ea25760d876c2b985cf9e4f2a62e25450322a92fe769533b0882b5402 \ No newline at end of file
diff --git a/db/schema_migrations/20230713100100 b/db/schema_migrations/20230713100100
new file mode 100644
index 00000000000..ee77da01273
--- /dev/null
+++ b/db/schema_migrations/20230713100100
@@ -0,0 +1 @@
+9787c717ecf74dd05277bde331b554fb824d6d39df83b5d46bac45ba1962e96a \ No newline at end of file
diff --git a/db/schema_migrations/20230714195649 b/db/schema_migrations/20230714195649
new file mode 100644
index 00000000000..7d0954f5ed8
--- /dev/null
+++ b/db/schema_migrations/20230714195649
@@ -0,0 +1 @@
+d47e6e46f9c70ae93c929e93bc361f3ca88ae86d1139110ddda341564a465b60 \ No newline at end of file
diff --git a/db/schema_migrations/20230717200940 b/db/schema_migrations/20230717200940
new file mode 100644
index 00000000000..6e25e66b8f8
--- /dev/null
+++ b/db/schema_migrations/20230717200940
@@ -0,0 +1 @@
+970898c369a13483eab732969f1ef3a63f7bcaf041fdb8a2b8c10e93da0de7c1 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index a1ca2147c8c..408d9d851aa 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -191,6 +191,18 @@ CREATE FUNCTION postgres_pg_stat_activity_autovacuum() RETURNS TABLE(query text,
AND backend_type = 'autovacuum worker'
$$;
+CREATE FUNCTION prevent_delete_of_default_organization() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+IF OLD.id = 1 THEN
+ RAISE EXCEPTION 'Deletion of the default Organization is not allowed.';
+END IF;
+RETURN OLD;
+
+END
+$$;
+
CREATE FUNCTION set_has_external_issue_tracker() RETURNS trigger
LANGUAGE plpgsql
AS $$
@@ -237,29 +249,20 @@ RETURN NULL;
END
$$;
-CREATE FUNCTION trigger_023e82d8e257() RETURNS trigger
- LANGUAGE plpgsql
- AS $$
-BEGIN
- NEW."id_convert_to_bigint" := NEW."id";
- RETURN NEW;
-END;
-$$;
-
-CREATE FUNCTION trigger_080e73845bfd() RETURNS trigger
+CREATE FUNCTION trigger_1a857e8db6cd() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
- NEW."id_convert_to_bigint" := NEW."id";
+ NEW."uuid_convert_string_to_uuid" := NEW."uuid";
RETURN NEW;
END;
$$;
-CREATE FUNCTION trigger_1a857e8db6cd() RETURNS trigger
+CREATE FUNCTION trigger_7f3d66a7d7f5() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
- NEW."uuid_convert_string_to_uuid" := NEW."uuid";
+ NEW."pipeline_id_convert_to_bigint" := NEW."pipeline_id";
RETURN NEW;
END;
$$;
@@ -11766,6 +11769,10 @@ CREATE TABLE application_settings (
unconfirmed_users_delete_after_days integer DEFAULT 7 NOT NULL,
default_branch_protection_defaults jsonb DEFAULT '{}'::jsonb NOT NULL,
gitlab_shell_operation_limit integer DEFAULT 600,
+ elasticsearch_requeue_workers boolean DEFAULT false NOT NULL,
+ elasticsearch_worker_number_of_shards integer DEFAULT 2 NOT NULL,
+ relay_state_domain_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
+ namespace_storage_forks_cost_factor double precision DEFAULT 1.0 NOT NULL,
CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
CONSTRAINT app_settings_container_registry_pre_import_tags_rate_positive CHECK ((container_registry_pre_import_tags_rate >= (0)::numeric)),
CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)),
@@ -11809,6 +11816,7 @@ CREATE TABLE application_settings (
CONSTRAINT check_9c6c447a13 CHECK ((char_length(maintenance_mode_message) <= 255)),
CONSTRAINT check_a5704163cc CHECK ((char_length(secret_detection_revocation_token_types_url) <= 255)),
CONSTRAINT check_ae53cf7f82 CHECK ((char_length(vertex_ai_host) <= 255)),
+ CONSTRAINT check_app_settings_namespace_storage_forks_cost_factor_range CHECK (((namespace_storage_forks_cost_factor >= (0)::double precision) AND (namespace_storage_forks_cost_factor <= (1)::double precision))),
CONSTRAINT check_b8c74ea5b3 CHECK ((char_length(deactivation_email_additional_text) <= 1000)),
CONSTRAINT check_d03919528d CHECK ((char_length(container_registry_vendor) <= 255)),
CONSTRAINT check_d820146492 CHECK ((char_length(spam_check_endpoint_url) <= 255)),
@@ -12120,8 +12128,10 @@ CREATE TABLE audit_events_external_audit_event_destinations (
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
verification_token text,
+ name text NOT NULL,
CONSTRAINT check_2feafb9daf CHECK ((char_length(destination_url) <= 255)),
- CONSTRAINT check_8ec80a7d06 CHECK ((char_length(verification_token) <= 24))
+ CONSTRAINT check_8ec80a7d06 CHECK ((char_length(verification_token) <= 24)),
+ CONSTRAINT check_c52ff8e90e CHECK ((char_length(name) <= 72))
);
CREATE SEQUENCE audit_events_external_audit_event_destinations_id_seq
@@ -12173,6 +12183,8 @@ CREATE TABLE audit_events_instance_external_audit_event_destinations (
destination_url text NOT NULL,
encrypted_verification_token bytea NOT NULL,
encrypted_verification_token_iv bytea NOT NULL,
+ name text NOT NULL,
+ CONSTRAINT check_433fbb3305 CHECK ((char_length(name) <= 72)),
CONSTRAINT check_4dc67167ce CHECK ((char_length(destination_url) <= 255))
);
@@ -12925,7 +12937,8 @@ ALTER SEQUENCE bulk_imports_id_seq OWNED BY bulk_imports.id;
CREATE TABLE catalog_resources (
id bigint NOT NULL,
project_id bigint NOT NULL,
- created_at timestamp with time zone NOT NULL
+ created_at timestamp with time zone NOT NULL,
+ state smallint DEFAULT 0 NOT NULL
);
CREATE SEQUENCE catalog_resources_id_seq
@@ -12982,7 +12995,7 @@ CREATE TABLE ci_build_needs (
artifacts boolean DEFAULT true NOT NULL,
optional boolean DEFAULT false NOT NULL,
build_id bigint NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL,
+ partition_id bigint NOT NULL,
id bigint NOT NULL
);
@@ -13004,7 +13017,7 @@ CREATE TABLE ci_build_pending_states (
failure_reason smallint,
trace_checksum bytea,
trace_bytesize bigint,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_build_pending_states_id_seq
@@ -13020,7 +13033,7 @@ CREATE TABLE ci_build_report_results (
build_id bigint NOT NULL,
project_id bigint NOT NULL,
data jsonb DEFAULT '{}'::jsonb NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE TABLE ci_build_trace_chunks (
@@ -13031,7 +13044,7 @@ CREATE TABLE ci_build_trace_chunks (
checksum bytea,
lock_version integer DEFAULT 0 NOT NULL,
build_id bigint NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_build_trace_chunks_id_seq
@@ -13051,7 +13064,7 @@ CREATE TABLE ci_build_trace_metadata (
remote_checksum bytea,
last_archival_attempt_at timestamp with time zone,
archived_at timestamp with time zone,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE TABLE p_ci_builds (
@@ -13216,7 +13229,7 @@ CREATE TABLE ci_builds_runner_session (
certificate character varying,
"authorization" character varying,
build_id bigint NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_builds_runner_session_id_seq
@@ -13332,7 +13345,9 @@ CREATE TABLE ci_group_variables (
variable_type smallint DEFAULT 1 NOT NULL,
environment_scope text DEFAULT '*'::text NOT NULL,
raw boolean DEFAULT false NOT NULL,
- CONSTRAINT check_dfe009485a CHECK ((char_length(environment_scope) <= 255))
+ description text,
+ CONSTRAINT check_dfe009485a CHECK ((char_length(environment_scope) <= 255)),
+ CONSTRAINT check_e2e50ff879 CHECK ((char_length(description) <= 255))
);
CREATE SEQUENCE ci_group_variables_id_seq
@@ -13394,7 +13409,7 @@ CREATE TABLE ci_job_artifacts (
id bigint NOT NULL,
job_id bigint NOT NULL,
locked smallint DEFAULT 2,
- partition_id bigint DEFAULT 100 NOT NULL,
+ partition_id bigint NOT NULL,
accessibility smallint DEFAULT 0 NOT NULL,
file_final_path text,
CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL)),
@@ -13437,7 +13452,7 @@ CREATE TABLE ci_job_variables (
variable_type smallint DEFAULT 1 NOT NULL,
source smallint DEFAULT 0 NOT NULL,
raw boolean DEFAULT false NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_job_variables_id_seq
@@ -13530,7 +13545,7 @@ CREATE TABLE ci_pending_builds (
minutes_exceeded boolean DEFAULT false NOT NULL,
tag_ids integer[] DEFAULT '{}'::integer[],
namespace_traversal_ids integer[] DEFAULT '{}'::integer[],
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_pending_builds_id_seq
@@ -13664,7 +13679,6 @@ CREATE SEQUENCE ci_pipeline_schedules_id_seq
ALTER SEQUENCE ci_pipeline_schedules_id_seq OWNED BY ci_pipeline_schedules.id;
CREATE TABLE ci_pipeline_variables (
- id_convert_to_bigint integer DEFAULT 0 NOT NULL,
key character varying NOT NULL,
value text,
encrypted_value text,
@@ -13672,9 +13686,10 @@ CREATE TABLE ci_pipeline_variables (
encrypted_value_iv character varying,
pipeline_id integer NOT NULL,
variable_type smallint DEFAULT 1 NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL,
+ partition_id bigint NOT NULL,
raw boolean DEFAULT false NOT NULL,
- id bigint NOT NULL
+ id bigint NOT NULL,
+ pipeline_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
);
CREATE SEQUENCE ci_pipeline_variables_id_seq
@@ -13716,7 +13731,7 @@ CREATE TABLE ci_pipelines (
external_pull_request_id bigint,
ci_ref_id bigint,
locked smallint DEFAULT 1 NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL,
+ partition_id bigint NOT NULL,
id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
CONSTRAINT check_d7e99a025e CHECK ((lock_version IS NOT NULL))
);
@@ -13958,7 +13973,7 @@ CREATE TABLE ci_running_builds (
runner_id bigint NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
runner_type smallint NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_running_builds_id_seq
@@ -14024,8 +14039,8 @@ CREATE TABLE ci_sources_pipelines (
source_project_id integer,
source_pipeline_id integer,
source_job_id bigint,
- partition_id bigint DEFAULT 100 NOT NULL,
- source_partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL,
+ source_partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_sources_pipelines_id_seq
@@ -14062,7 +14077,7 @@ CREATE TABLE ci_stages (
lock_version integer DEFAULT 0,
"position" integer,
id bigint NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL,
+ partition_id bigint NOT NULL,
CONSTRAINT check_81b431e49b CHECK ((lock_version IS NOT NULL))
);
@@ -14135,7 +14150,7 @@ CREATE TABLE ci_unit_test_failures (
failed_at timestamp with time zone NOT NULL,
unit_test_id bigint NOT NULL,
build_id bigint NOT NULL,
- partition_id bigint DEFAULT 100 NOT NULL
+ partition_id bigint NOT NULL
);
CREATE SEQUENCE ci_unit_test_failures_id_seq
@@ -14179,7 +14194,9 @@ CREATE TABLE ci_variables (
environment_scope character varying DEFAULT '*'::character varying NOT NULL,
masked boolean DEFAULT false NOT NULL,
variable_type smallint DEFAULT 1 NOT NULL,
- raw boolean DEFAULT false NOT NULL
+ raw boolean DEFAULT false NOT NULL,
+ description text,
+ CONSTRAINT check_7e46c006aa CHECK ((char_length(description) <= 255))
);
CREATE SEQUENCE ci_variables_id_seq
@@ -15680,7 +15697,9 @@ CREATE TABLE environments (
auto_delete_at timestamp with time zone,
tier smallint,
merge_request_id bigint,
- cluster_agent_id bigint
+ cluster_agent_id bigint,
+ kubernetes_namespace text,
+ CONSTRAINT check_b5373a1804 CHECK ((char_length(kubernetes_namespace) <= 63))
);
CREATE SEQUENCE environments_id_seq
@@ -16721,6 +16740,28 @@ CREATE TABLE group_wiki_repositories (
CONSTRAINT check_07f1c81806 CHECK ((char_length(disk_path) <= 80))
);
+CREATE TABLE group_wiki_repository_states (
+ id bigint NOT NULL,
+ verification_started_at timestamp with time zone,
+ verification_retry_at timestamp with time zone,
+ verified_at timestamp with time zone,
+ group_wiki_repository_id bigint NOT NULL,
+ verification_state smallint DEFAULT 0 NOT NULL,
+ verification_retry_count smallint DEFAULT 0 NOT NULL,
+ verification_checksum bytea,
+ verification_failure text,
+ CONSTRAINT check_14d288436d CHECK ((char_length(verification_failure) <= 255))
+);
+
+CREATE SEQUENCE group_wiki_repository_states_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE group_wiki_repository_states_id_seq OWNED BY group_wiki_repository_states.id;
+
CREATE TABLE historical_data (
id integer NOT NULL,
date date,
@@ -17135,6 +17176,8 @@ CREATE TABLE integrations (
encrypted_properties bytea,
encrypted_properties_iv bytea,
incident_events boolean DEFAULT false NOT NULL,
+ group_mention_events boolean DEFAULT false NOT NULL,
+ group_confidential_mention_events boolean DEFAULT false NOT NULL,
CONSTRAINT check_a948a0aa7e CHECK ((char_length(type_new) <= 255))
);
@@ -17866,7 +17909,8 @@ CREATE TABLE member_roles (
base_access_level integer NOT NULL,
read_code boolean DEFAULT false,
read_vulnerability boolean DEFAULT false NOT NULL,
- admin_vulnerability boolean DEFAULT false NOT NULL
+ admin_vulnerability boolean DEFAULT false NOT NULL,
+ read_dependency boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE member_roles_id_seq
@@ -18210,6 +18254,27 @@ CREATE SEQUENCE merge_request_predictions_merge_request_id_seq
ALTER SEQUENCE merge_request_predictions_merge_request_id_seq OWNED BY merge_request_predictions.merge_request_id;
+CREATE TABLE merge_request_review_llm_summaries (
+ id bigint NOT NULL,
+ user_id bigint,
+ review_id bigint NOT NULL,
+ merge_request_diff_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ provider smallint NOT NULL,
+ content text NOT NULL,
+ CONSTRAINT check_72802358e9 CHECK ((char_length(content) <= 2056))
+);
+
+CREATE SEQUENCE merge_request_review_llm_summaries_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE merge_request_review_llm_summaries_id_seq OWNED BY merge_request_review_llm_summaries.id;
+
CREATE TABLE merge_request_reviewers (
id bigint NOT NULL,
user_id bigint NOT NULL,
@@ -18552,6 +18617,7 @@ CREATE TABLE ml_experiments (
user_id bigint,
name text NOT NULL,
deleted_on timestamp with time zone,
+ model_id bigint,
CONSTRAINT check_ee07a0be2c CHECK ((char_length(name) <= 255))
);
@@ -18564,6 +18630,44 @@ CREATE SEQUENCE ml_experiments_id_seq
ALTER SEQUENCE ml_experiments_id_seq OWNED BY ml_experiments.id;
+CREATE TABLE ml_model_versions (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ project_id bigint NOT NULL,
+ model_id bigint NOT NULL,
+ package_id bigint,
+ version text NOT NULL,
+ CONSTRAINT check_28b2d892c8 CHECK ((char_length(version) <= 255))
+);
+
+CREATE SEQUENCE ml_model_versions_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ml_model_versions_id_seq OWNED BY ml_model_versions.id;
+
+CREATE TABLE ml_models (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ project_id bigint NOT NULL,
+ name text NOT NULL,
+ CONSTRAINT check_1fd2cc7d93 CHECK ((char_length(name) <= 255))
+);
+
+CREATE SEQUENCE ml_models_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ml_models_id_seq OWNED BY ml_models.id;
+
CREATE TABLE namespace_admin_notes (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -18656,7 +18760,10 @@ CREATE TABLE namespace_limits (
additional_purchased_storage_size bigint DEFAULT 0 NOT NULL,
additional_purchased_storage_ends_on date,
namespace_id integer NOT NULL,
- temporary_storage_increase_ends_on date
+ temporary_storage_increase_ends_on date,
+ pre_enforcement_notification_at timestamp with time zone,
+ first_enforced_at timestamp with time zone,
+ last_enforced_at timestamp with time zone
);
CREATE TABLE namespace_package_settings (
@@ -18805,7 +18912,8 @@ CREATE TABLE namespaces (
push_rule_id bigint,
shared_runners_enabled boolean DEFAULT true NOT NULL,
allow_descendants_override_disabled_shared_runners boolean DEFAULT false NOT NULL,
- traversal_ids integer[] DEFAULT '{}'::integer[] NOT NULL
+ traversal_ids integer[] DEFAULT '{}'::integer[] NOT NULL,
+ organization_id bigint DEFAULT 1
);
CREATE SEQUENCE namespaces_id_seq
@@ -18889,7 +18997,6 @@ CREATE SEQUENCE note_metadata_note_id_seq
ALTER SEQUENCE note_metadata_note_id_seq OWNED BY note_metadata.note_id;
CREATE TABLE notes (
- id_convert_to_bigint integer DEFAULT 0 NOT NULL,
note text,
noteable_type character varying,
author_id integer,
@@ -19231,6 +19338,30 @@ CREATE SEQUENCE operations_user_lists_id_seq
ALTER SEQUENCE operations_user_lists_id_seq OWNED BY operations_user_lists.id;
+CREATE TABLE organization_settings (
+ organization_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ settings jsonb DEFAULT '{}'::jsonb NOT NULL
+);
+
+CREATE TABLE organization_users (
+ id bigint NOT NULL,
+ organization_id bigint NOT NULL,
+ user_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL
+);
+
+CREATE SEQUENCE organization_users_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE organization_users_id_seq OWNED BY organization_users.id;
+
CREATE TABLE organizations (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -20054,7 +20185,8 @@ CREATE TABLE personal_access_tokens (
token_digest character varying,
expire_notification_delivered boolean DEFAULT false NOT NULL,
last_used_at timestamp with time zone,
- after_expiry_notification_delivered boolean DEFAULT false NOT NULL
+ after_expiry_notification_delivered boolean DEFAULT false NOT NULL,
+ previous_personal_access_token_id bigint
);
CREATE SEQUENCE personal_access_tokens_id_seq
@@ -20199,7 +20331,7 @@ CREATE TABLE pm_advisories (
CONSTRAINT check_bed97fa77a CHECK ((char_length(cvss_v3) <= 128)),
CONSTRAINT check_e4bfd3ffbf CHECK ((char_length(title) <= 256)),
CONSTRAINT check_fee880f7aa CHECK ((char_length(description) <= 8192)),
- CONSTRAINT chk_rails_e73af9de76 CHECK ((cardinality(urls) <= 10))
+ CONSTRAINT chk_rails_e73af9de76 CHECK ((cardinality(urls) <= 20))
);
CREATE SEQUENCE pm_advisories_id_seq
@@ -20218,7 +20350,7 @@ CREATE TABLE pm_affected_packages (
updated_at timestamp with time zone NOT NULL,
purl_type smallint NOT NULL,
package_name text NOT NULL,
- distro_version text,
+ distro_version text DEFAULT ''::text NOT NULL,
solution text,
affected_range text NOT NULL,
fixed_versions text[] DEFAULT '{}'::text[],
@@ -22166,7 +22298,8 @@ CREATE TABLE saml_providers (
enforced_group_managed_accounts boolean DEFAULT false NOT NULL,
prohibited_outer_forks boolean DEFAULT true NOT NULL,
default_membership_role smallint DEFAULT 10 NOT NULL,
- git_check_enforced boolean DEFAULT false NOT NULL
+ git_check_enforced boolean DEFAULT false NOT NULL,
+ relay_state_domain_allowlist text[] DEFAULT '{}'::text[] NOT NULL
);
CREATE SEQUENCE saml_providers_id_seq
@@ -22274,23 +22407,6 @@ CREATE SEQUENCE sbom_sources_id_seq
ALTER SEQUENCE sbom_sources_id_seq OWNED BY sbom_sources.id;
-CREATE TABLE sbom_vulnerable_component_versions (
- id bigint NOT NULL,
- vulnerability_advisory_id bigint,
- sbom_component_version_id bigint,
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL
-);
-
-CREATE SEQUENCE sbom_vulnerable_component_versions_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE sbom_vulnerable_component_versions_id_seq OWNED BY sbom_vulnerable_component_versions.id;
-
CREATE TABLE scan_result_policies (
id bigint NOT NULL,
security_orchestration_policy_configuration_id bigint NOT NULL,
@@ -22303,6 +22419,8 @@ CREATE TABLE scan_result_policies (
age_value integer,
age_operator smallint,
age_interval smallint,
+ vulnerability_attributes jsonb DEFAULT '{}'::jsonb,
+ project_id bigint,
CONSTRAINT age_value_null_or_positive CHECK (((age_value IS NULL) OR (age_value >= 0)))
);
@@ -22571,9 +22689,6 @@ CREATE TABLE sent_notifications (
recipient_id integer,
commit_id character varying,
reply_key character varying NOT NULL,
- line_code character varying,
- note_type character varying,
- "position" text,
in_reply_to_discussion_id character varying,
id bigint NOT NULL
);
@@ -22602,6 +22717,25 @@ CREATE SEQUENCE sentry_issues_id_seq
ALTER SEQUENCE sentry_issues_id_seq OWNED BY sentry_issues.id;
+CREATE TABLE service_access_tokens (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ category smallint DEFAULT 0 NOT NULL,
+ encrypted_token bytea NOT NULL,
+ encrypted_token_iv bytea NOT NULL,
+ expires_at timestamp with time zone NOT NULL
+);
+
+CREATE SEQUENCE service_access_tokens_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE service_access_tokens_id_seq OWNED BY service_access_tokens.id;
+
CREATE TABLE service_desk_custom_email_credentials (
project_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -23026,6 +23160,23 @@ CREATE SEQUENCE subscription_add_ons_id_seq
ALTER SEQUENCE subscription_add_ons_id_seq OWNED BY subscription_add_ons.id;
+CREATE TABLE subscription_user_add_on_assignments (
+ id bigint NOT NULL,
+ add_on_purchase_id bigint NOT NULL,
+ user_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL
+);
+
+CREATE SEQUENCE subscription_user_add_on_assignments_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE subscription_user_add_on_assignments_id_seq OWNED BY subscription_user_add_on_assignments.id;
+
CREATE TABLE subscriptions (
id integer NOT NULL,
user_id integer,
@@ -23068,6 +23219,52 @@ CREATE SEQUENCE suggestions_id_seq
ALTER SEQUENCE suggestions_id_seq OWNED BY suggestions.id;
+CREATE TABLE system_access_microsoft_applications (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ namespace_id bigint,
+ enabled boolean DEFAULT false NOT NULL,
+ tenant_xid text NOT NULL,
+ client_xid text NOT NULL,
+ login_endpoint text DEFAULT 'https://login.microsoftonline.com'::text NOT NULL,
+ graph_endpoint text DEFAULT 'https://graph.microsoft.com'::text NOT NULL,
+ encrypted_client_secret bytea NOT NULL,
+ encrypted_client_secret_iv bytea NOT NULL,
+ CONSTRAINT check_042f6b21aa CHECK ((char_length(login_endpoint) <= 255)),
+ CONSTRAINT check_1e8b2d405f CHECK ((char_length(tenant_xid) <= 255)),
+ CONSTRAINT check_339c3ffca8 CHECK ((char_length(graph_endpoint) <= 255)),
+ CONSTRAINT check_ee72fb5459 CHECK ((char_length(client_xid) <= 255))
+);
+
+CREATE SEQUENCE system_access_microsoft_applications_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE system_access_microsoft_applications_id_seq OWNED BY system_access_microsoft_applications.id;
+
+CREATE TABLE system_access_microsoft_graph_access_tokens (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ system_access_microsoft_application_id bigint,
+ expires_in integer NOT NULL,
+ encrypted_token bytea NOT NULL,
+ encrypted_token_iv bytea NOT NULL
+);
+
+CREATE SEQUENCE system_access_microsoft_graph_access_tokens_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE system_access_microsoft_graph_access_tokens_id_seq OWNED BY system_access_microsoft_graph_access_tokens.id;
+
CREATE TABLE system_note_metadata (
id integer NOT NULL,
commit_count integer,
@@ -23325,27 +23522,6 @@ CREATE SEQUENCE trending_projects_id_seq
ALTER SEQUENCE trending_projects_id_seq OWNED BY trending_projects.id;
-CREATE TABLE u2f_registrations (
- id integer NOT NULL,
- certificate text,
- key_handle character varying,
- public_key character varying,
- counter integer,
- user_id integer,
- created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL,
- name character varying
-);
-
-CREATE SEQUENCE u2f_registrations_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE u2f_registrations_id_seq OWNED BY u2f_registrations.id;
-
CREATE TABLE upcoming_reconciliations (
id bigint NOT NULL,
namespace_id bigint,
@@ -23532,7 +23708,6 @@ CREATE TABLE user_details (
password_last_changed_at timestamp with time zone DEFAULT now() NOT NULL,
onboarding_step_url text,
discord text DEFAULT ''::text NOT NULL,
- provisioned_by_group_at timestamp with time zone,
enterprise_group_id bigint,
enterprise_group_associated_at timestamp with time zone,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)),
@@ -23796,7 +23971,7 @@ CREATE TABLE users (
otp_backup_codes text,
public_email character varying,
dashboard integer DEFAULT 0,
- project_view integer DEFAULT 0,
+ project_view integer DEFAULT 2,
consumed_timestep integer,
layout integer DEFAULT 0,
hide_project_limit boolean DEFAULT false,
@@ -23832,6 +24007,7 @@ CREATE TABLE users (
static_object_token_encrypted text,
otp_secret_expires_at timestamp with time zone,
onboarding_in_progress boolean DEFAULT false NOT NULL,
+ CONSTRAINT check_0dd5948e38 CHECK ((user_type IS NOT NULL)),
CONSTRAINT check_7bde697e8e CHECK ((char_length(static_object_token_encrypted) <= 255))
);
@@ -23969,44 +24145,6 @@ CREATE SEQUENCE vulnerabilities_id_seq
ALTER SEQUENCE vulnerabilities_id_seq OWNED BY vulnerabilities.id;
-CREATE TABLE vulnerability_advisories (
- uuid uuid NOT NULL,
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL,
- id bigint NOT NULL,
- created_date date NOT NULL,
- published_date date NOT NULL,
- description text,
- title text,
- component_name text,
- solution text,
- not_impacted text,
- cvss_v2 text,
- cvss_v3 text,
- affected_range text,
- identifiers text[] DEFAULT '{}'::text[],
- fixed_versions text[] DEFAULT '{}'::text[],
- urls text[] DEFAULT '{}'::text[],
- links text[] DEFAULT '{}'::text[],
- CONSTRAINT check_3ab0544d19 CHECK ((char_length(title) <= 2048)),
- CONSTRAINT check_3b57023409 CHECK ((char_length(affected_range) <= 32)),
- CONSTRAINT check_4d5cd7be9c CHECK ((char_length(component_name) <= 2048)),
- CONSTRAINT check_962f256a51 CHECK ((char_length(solution) <= 2048)),
- CONSTRAINT check_aae93955fb CHECK ((char_length(cvss_v3) <= 128)),
- CONSTRAINT check_b8a17497f3 CHECK ((char_length(cvss_v2) <= 128)),
- CONSTRAINT check_c05a35f418 CHECK ((char_length(not_impacted) <= 2048)),
- CONSTRAINT check_ff9f6483b6 CHECK ((char_length(description) <= 2048))
-);
-
-CREATE SEQUENCE vulnerability_advisories_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE vulnerability_advisories_id_seq OWNED BY vulnerability_advisories.id;
-
CREATE TABLE vulnerability_exports (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -24310,7 +24448,6 @@ CREATE TABLE vulnerability_occurrences (
vulnerability_id bigint,
details jsonb DEFAULT '{}'::jsonb NOT NULL,
description text,
- message text,
solution text,
cve text,
location jsonb,
@@ -24318,7 +24455,6 @@ CREATE TABLE vulnerability_occurrences (
uuid_convert_string_to_uuid uuid DEFAULT '00000000-0000-0000-0000-000000000000'::uuid NOT NULL,
CONSTRAINT check_4a3a60f2ba CHECK ((char_length(solution) <= 7000)),
CONSTRAINT check_ade261da6b CHECK ((char_length(description) <= 15000)),
- CONSTRAINT check_df6dd20219 CHECK ((char_length(message) <= 3000)),
CONSTRAINT check_f602da68dd CHECK ((char_length(cve) <= 48400))
);
@@ -24513,7 +24649,8 @@ CREATE TABLE web_hooks (
encrypted_url_variables bytea,
encrypted_url_variables_iv bytea,
integration_id integer,
- branch_filter_strategy smallint DEFAULT 0 NOT NULL
+ branch_filter_strategy smallint DEFAULT 0 NOT NULL,
+ emoji_events boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE web_hooks_id_seq
@@ -25335,6 +25472,8 @@ ALTER TABLE ONLY group_import_states ALTER COLUMN group_id SET DEFAULT nextval('
ALTER TABLE ONLY group_repository_storage_moves ALTER COLUMN id SET DEFAULT nextval('group_repository_storage_moves_id_seq'::regclass);
+ALTER TABLE ONLY group_wiki_repository_states ALTER COLUMN id SET DEFAULT nextval('group_wiki_repository_states_id_seq'::regclass);
+
ALTER TABLE ONLY historical_data ALTER COLUMN id SET DEFAULT nextval('historical_data_id_seq'::regclass);
ALTER TABLE ONLY identities ALTER COLUMN id SET DEFAULT nextval('identities_id_seq'::regclass);
@@ -25471,6 +25610,8 @@ ALTER TABLE ONLY merge_request_metrics ALTER COLUMN id SET DEFAULT nextval('merg
ALTER TABLE ONLY merge_request_predictions ALTER COLUMN merge_request_id SET DEFAULT nextval('merge_request_predictions_merge_request_id_seq'::regclass);
+ALTER TABLE ONLY merge_request_review_llm_summaries ALTER COLUMN id SET DEFAULT nextval('merge_request_review_llm_summaries_id_seq'::regclass);
+
ALTER TABLE ONLY merge_request_reviewers ALTER COLUMN id SET DEFAULT nextval('merge_request_reviewers_id_seq'::regclass);
ALTER TABLE ONLY merge_request_user_mentions ALTER COLUMN id SET DEFAULT nextval('merge_request_user_mentions_id_seq'::regclass);
@@ -25501,6 +25642,10 @@ ALTER TABLE ONLY ml_experiment_metadata ALTER COLUMN id SET DEFAULT nextval('ml_
ALTER TABLE ONLY ml_experiments ALTER COLUMN id SET DEFAULT nextval('ml_experiments_id_seq'::regclass);
+ALTER TABLE ONLY ml_model_versions ALTER COLUMN id SET DEFAULT nextval('ml_model_versions_id_seq'::regclass);
+
+ALTER TABLE ONLY ml_models ALTER COLUMN id SET DEFAULT nextval('ml_models_id_seq'::regclass);
+
ALTER TABLE ONLY namespace_admin_notes ALTER COLUMN id SET DEFAULT nextval('namespace_admin_notes_id_seq'::regclass);
ALTER TABLE ONLY namespace_bans ALTER COLUMN id SET DEFAULT nextval('namespace_bans_id_seq'::regclass);
@@ -25549,6 +25694,8 @@ ALTER TABLE ONLY operations_strategies_user_lists ALTER COLUMN id SET DEFAULT ne
ALTER TABLE ONLY operations_user_lists ALTER COLUMN id SET DEFAULT nextval('operations_user_lists_id_seq'::regclass);
+ALTER TABLE ONLY organization_users ALTER COLUMN id SET DEFAULT nextval('organization_users_id_seq'::regclass);
+
ALTER TABLE ONLY organizations ALTER COLUMN id SET DEFAULT nextval('organizations_id_seq'::regclass);
ALTER TABLE ONLY p_ci_builds ALTER COLUMN id SET DEFAULT nextval('ci_builds_id_seq'::regclass);
@@ -25783,8 +25930,6 @@ ALTER TABLE ONLY sbom_occurrences ALTER COLUMN id SET DEFAULT nextval('sbom_occu
ALTER TABLE ONLY sbom_sources ALTER COLUMN id SET DEFAULT nextval('sbom_sources_id_seq'::regclass);
-ALTER TABLE ONLY sbom_vulnerable_component_versions ALTER COLUMN id SET DEFAULT nextval('sbom_vulnerable_component_versions_id_seq'::regclass);
-
ALTER TABLE ONLY scan_result_policies ALTER COLUMN id SET DEFAULT nextval('scan_result_policies_id_seq'::regclass);
ALTER TABLE ONLY schema_inconsistencies ALTER COLUMN id SET DEFAULT nextval('schema_inconsistencies_id_seq'::regclass);
@@ -25815,6 +25960,8 @@ ALTER TABLE ONLY sent_notifications ALTER COLUMN id SET DEFAULT nextval('sent_no
ALTER TABLE ONLY sentry_issues ALTER COLUMN id SET DEFAULT nextval('sentry_issues_id_seq'::regclass);
+ALTER TABLE ONLY service_access_tokens ALTER COLUMN id SET DEFAULT nextval('service_access_tokens_id_seq'::regclass);
+
ALTER TABLE ONLY shards ALTER COLUMN id SET DEFAULT nextval('shards_id_seq'::regclass);
ALTER TABLE ONLY slack_api_scopes ALTER COLUMN id SET DEFAULT nextval('slack_api_scopes_id_seq'::regclass);
@@ -25851,10 +25998,16 @@ ALTER TABLE ONLY subscription_add_on_purchases ALTER COLUMN id SET DEFAULT nextv
ALTER TABLE ONLY subscription_add_ons ALTER COLUMN id SET DEFAULT nextval('subscription_add_ons_id_seq'::regclass);
+ALTER TABLE ONLY subscription_user_add_on_assignments ALTER COLUMN id SET DEFAULT nextval('subscription_user_add_on_assignments_id_seq'::regclass);
+
ALTER TABLE ONLY subscriptions ALTER COLUMN id SET DEFAULT nextval('subscriptions_id_seq'::regclass);
ALTER TABLE ONLY suggestions ALTER COLUMN id SET DEFAULT nextval('suggestions_id_seq'::regclass);
+ALTER TABLE ONLY system_access_microsoft_applications ALTER COLUMN id SET DEFAULT nextval('system_access_microsoft_applications_id_seq'::regclass);
+
+ALTER TABLE ONLY system_access_microsoft_graph_access_tokens ALTER COLUMN id SET DEFAULT nextval('system_access_microsoft_graph_access_tokens_id_seq'::regclass);
+
ALTER TABLE ONLY system_note_metadata ALTER COLUMN id SET DEFAULT nextval('system_note_metadata_id_seq'::regclass);
ALTER TABLE ONLY taggings ALTER COLUMN id SET DEFAULT nextval('taggings_id_seq'::regclass);
@@ -25879,8 +26032,6 @@ ALTER TABLE ONLY topics ALTER COLUMN id SET DEFAULT nextval('topics_id_seq'::reg
ALTER TABLE ONLY trending_projects ALTER COLUMN id SET DEFAULT nextval('trending_projects_id_seq'::regclass);
-ALTER TABLE ONLY u2f_registrations ALTER COLUMN id SET DEFAULT nextval('u2f_registrations_id_seq'::regclass);
-
ALTER TABLE ONLY upcoming_reconciliations ALTER COLUMN id SET DEFAULT nextval('upcoming_reconciliations_id_seq'::regclass);
ALTER TABLE ONLY upload_states ALTER COLUMN upload_id SET DEFAULT nextval('upload_states_upload_id_seq'::regclass);
@@ -25925,8 +26076,6 @@ ALTER TABLE ONLY value_stream_dashboard_counts ALTER COLUMN id SET DEFAULT nextv
ALTER TABLE ONLY vulnerabilities ALTER COLUMN id SET DEFAULT nextval('vulnerabilities_id_seq'::regclass);
-ALTER TABLE ONLY vulnerability_advisories ALTER COLUMN id SET DEFAULT nextval('vulnerability_advisories_id_seq'::regclass);
-
ALTER TABLE ONLY vulnerability_exports ALTER COLUMN id SET DEFAULT nextval('vulnerability_exports_id_seq'::regclass);
ALTER TABLE ONLY vulnerability_external_issue_links ALTER COLUMN id SET DEFAULT nextval('vulnerability_external_issue_links_id_seq'::regclass);
@@ -26848,9 +26997,6 @@ ALTER TABLE ONLY chat_names
ALTER TABLE ONLY chat_teams
ADD CONSTRAINT chat_teams_pkey PRIMARY KEY (id);
-ALTER TABLE users
- ADD CONSTRAINT check_0dd5948e38 CHECK ((user_type IS NOT NULL)) NOT VALID;
-
ALTER TABLE vulnerability_scanners
ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) NOT VALID;
@@ -27436,6 +27582,9 @@ ALTER TABLE ONLY group_repository_storage_moves
ALTER TABLE ONLY group_wiki_repositories
ADD CONSTRAINT group_wiki_repositories_pkey PRIMARY KEY (group_id);
+ALTER TABLE ONLY group_wiki_repository_states
+ ADD CONSTRAINT group_wiki_repository_states_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY historical_data
ADD CONSTRAINT historical_data_pkey PRIMARY KEY (id);
@@ -27664,6 +27813,9 @@ ALTER TABLE ONLY merge_request_metrics
ALTER TABLE ONLY merge_request_predictions
ADD CONSTRAINT merge_request_predictions_pkey PRIMARY KEY (merge_request_id);
+ALTER TABLE ONLY merge_request_review_llm_summaries
+ ADD CONSTRAINT merge_request_review_llm_summaries_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY merge_request_reviewers
ADD CONSTRAINT merge_request_reviewers_pkey PRIMARY KEY (id);
@@ -27712,6 +27864,12 @@ ALTER TABLE ONLY ml_experiment_metadata
ALTER TABLE ONLY ml_experiments
ADD CONSTRAINT ml_experiments_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ml_model_versions
+ ADD CONSTRAINT ml_model_versions_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY ml_models
+ ADD CONSTRAINT ml_models_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY namespace_admin_notes
ADD CONSTRAINT namespace_admin_notes_pkey PRIMARY KEY (id);
@@ -27808,6 +27966,12 @@ ALTER TABLE ONLY operations_strategies_user_lists
ALTER TABLE ONLY operations_user_lists
ADD CONSTRAINT operations_user_lists_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY organization_settings
+ ADD CONSTRAINT organization_settings_pkey PRIMARY KEY (organization_id);
+
+ALTER TABLE ONLY organization_users
+ ADD CONSTRAINT organization_users_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY organizations
ADD CONSTRAINT organizations_pkey PRIMARY KEY (id);
@@ -28216,9 +28380,6 @@ ALTER TABLE ONLY sbom_occurrences
ALTER TABLE ONLY sbom_sources
ADD CONSTRAINT sbom_sources_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY sbom_vulnerable_component_versions
- ADD CONSTRAINT sbom_vulnerable_component_versions_pkey PRIMARY KEY (id);
-
ALTER TABLE ONLY scan_result_policies
ADD CONSTRAINT scan_result_policies_pkey PRIMARY KEY (id);
@@ -28270,6 +28431,9 @@ ALTER TABLE ONLY sentry_issues
ALTER TABLE ONLY sprints
ADD CONSTRAINT sequence_is_unique_per_iterations_cadence_id UNIQUE (iterations_cadence_id, sequence) DEFERRABLE INITIALLY DEFERRED;
+ALTER TABLE ONLY service_access_tokens
+ ADD CONSTRAINT service_access_tokens_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY service_desk_custom_email_credentials
ADD CONSTRAINT service_desk_custom_email_credentials_pkey PRIMARY KEY (project_id);
@@ -28339,12 +28503,21 @@ ALTER TABLE ONLY subscription_add_on_purchases
ALTER TABLE ONLY subscription_add_ons
ADD CONSTRAINT subscription_add_ons_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY subscription_user_add_on_assignments
+ ADD CONSTRAINT subscription_user_add_on_assignments_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY subscriptions
ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (id);
ALTER TABLE ONLY suggestions
ADD CONSTRAINT suggestions_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY system_access_microsoft_applications
+ ADD CONSTRAINT system_access_microsoft_applications_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY system_access_microsoft_graph_access_tokens
+ ADD CONSTRAINT system_access_microsoft_graph_access_tokens_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY system_note_metadata
ADD CONSTRAINT system_note_metadata_pkey PRIMARY KEY (id);
@@ -28381,9 +28554,6 @@ ALTER TABLE ONLY topics
ALTER TABLE ONLY trending_projects
ADD CONSTRAINT trending_projects_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY u2f_registrations
- ADD CONSTRAINT u2f_registrations_pkey PRIMARY KEY (id);
-
ALTER TABLE ONLY upcoming_reconciliations
ADD CONSTRAINT upcoming_reconciliations_pkey PRIMARY KEY (id);
@@ -28474,9 +28644,6 @@ ALTER TABLE ONLY verification_codes
ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT vulnerabilities_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY vulnerability_advisories
- ADD CONSTRAINT vulnerability_advisories_pkey PRIMARY KEY (id);
-
ALTER TABLE ONLY vulnerability_exports
ADD CONSTRAINT vulnerability_exports_pkey PRIMARY KEY (id);
@@ -29767,14 +29934,6 @@ CREATE INDEX idx_container_exp_policies_on_project_id_next_run_at_enabled ON con
CREATE INDEX idx_container_repos_on_exp_cleanup_status_project_id_start_date ON container_repositories USING btree (expiration_policy_cleanup_status, project_id, expiration_policy_started_at);
-CREATE INDEX idx_container_repos_on_import_started_at_when_importing ON container_repositories USING btree (migration_import_started_at) WHERE (migration_state = 'importing'::text);
-
-CREATE INDEX idx_container_repos_on_migration_state_migration_plan_created ON container_repositories USING btree (migration_state, migration_plan, created_at);
-
-CREATE INDEX idx_container_repos_on_pre_import_done_at_when_pre_import_done ON container_repositories USING btree (migration_pre_import_done_at) WHERE (migration_state = 'pre_import_done'::text);
-
-CREATE INDEX idx_container_repos_on_pre_import_started_at_when_pre_importing ON container_repositories USING btree (migration_pre_import_started_at) WHERE (migration_state = 'pre_importing'::text);
-
CREATE INDEX idx_deployment_clusters_on_cluster_id_and_kubernetes_namespace ON deployment_clusters USING btree (cluster_id, kubernetes_namespace);
CREATE INDEX idx_devops_adoption_segments_namespace_end_time ON analytics_devops_adoption_snapshots USING btree (namespace_id, end_time);
@@ -29869,8 +30028,12 @@ CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_golang O
CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_helm ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 11) AND (status <> 4));
+CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_npm ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 2) AND (status <> 4));
+
CREATE INDEX idx_packages_packages_on_project_id_name_version_package_type ON packages_packages USING btree (project_id, name, version, package_type);
+CREATE INDEX idx_personal_access_tokens_on_previous_personal_access_token_id ON personal_access_tokens USING btree (previous_personal_access_token_id);
+
CREATE INDEX idx_pkgs_debian_group_distribution_keys_on_distribution_id ON packages_debian_group_distribution_keys USING btree (distribution_id);
CREATE INDEX idx_pkgs_debian_project_distribution_keys_on_distribution_id ON packages_debian_project_distribution_keys USING btree (distribution_id);
@@ -30657,6 +30820,8 @@ CREATE INDEX index_ci_triggers_on_owner_id ON ci_triggers USING btree (owner_id)
CREATE INDEX index_ci_triggers_on_project_id ON ci_triggers USING btree (project_id);
+CREATE UNIQUE INDEX index_ci_triggers_on_token ON ci_triggers USING btree (token);
+
CREATE INDEX index_ci_unit_test_failures_on_build_id ON ci_unit_test_failures USING btree (build_id);
CREATE INDEX index_ci_unit_test_failures_on_partition_id_build_id ON ci_unit_test_failures USING btree (partition_id, build_id);
@@ -30729,10 +30894,6 @@ CREATE INDEX index_container_expiration_policies_on_next_run_at_and_enabled ON c
CREATE INDEX index_container_registry_data_repair_details_on_status ON container_registry_data_repair_details USING btree (status);
-CREATE INDEX index_container_repositories_on_greatest_completed_at ON container_repositories USING btree (GREATEST(migration_pre_import_done_at, migration_import_done_at, migration_aborted_at, migration_skipped_at)) WHERE (migration_state = ANY (ARRAY['import_done'::text, 'pre_import_done'::text, 'import_aborted'::text, 'import_skipped'::text]));
-
-CREATE INDEX index_container_repositories_on_migration_state_import_done_at ON container_repositories USING btree (migration_state, migration_import_done_at);
-
CREATE INDEX index_container_repositories_on_project_id_and_id ON container_repositories USING btree (project_id, id);
CREATE UNIQUE INDEX index_container_repositories_on_project_id_and_name ON container_repositories USING btree (project_id, name);
@@ -31109,8 +31270,6 @@ CREATE INDEX index_events_on_project_id_and_created_at ON events USING btree (pr
CREATE INDEX index_events_on_project_id_and_id ON events USING btree (project_id, id);
-CREATE INDEX index_events_on_project_id_and_id_desc_on_merged_action ON events USING btree (project_id, id DESC) WHERE (action = 7);
-
CREATE UNIQUE INDEX index_events_on_target_type_and_target_id_and_fingerprint ON events USING btree (target_type, target_id, fingerprint);
CREATE INDEX index_evidences_on_release_id ON evidences USING btree (release_id);
@@ -31289,13 +31448,23 @@ CREATE UNIQUE INDEX index_group_wiki_repositories_on_disk_path ON group_wiki_rep
CREATE INDEX index_group_wiki_repositories_on_shard_id ON group_wiki_repositories USING btree (shard_id);
+CREATE INDEX index_group_wiki_repository_states_failed_verification ON group_wiki_repository_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
+
+CREATE INDEX index_group_wiki_repository_states_needs_verification ON group_wiki_repository_states USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3));
+
+CREATE UNIQUE INDEX index_group_wiki_repository_states_on_group_wiki_repository_id ON group_wiki_repository_states USING btree (group_wiki_repository_id);
+
+CREATE INDEX index_group_wiki_repository_states_on_verification_state ON group_wiki_repository_states USING btree (verification_state);
+
+CREATE INDEX index_group_wiki_repository_states_pending_verification ON group_wiki_repository_states USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0);
+
CREATE INDEX index_groups_on_parent_id_id ON namespaces USING btree (parent_id, id) WHERE ((type)::text = 'Group'::text);
CREATE INDEX index_groups_on_path_and_id ON namespaces USING btree (path, id) WHERE ((type)::text = 'Group'::text);
CREATE INDEX index_historical_data_on_recorded_at ON historical_data USING btree (recorded_at);
-CREATE UNIQUE INDEX index_http_integrations_on_active_and_project_and_endpoint ON alert_management_http_integrations USING btree (active, project_id, endpoint_identifier) WHERE active;
+CREATE UNIQUE INDEX index_http_integrations_on_project_and_endpoint ON alert_management_http_integrations USING btree (project_id, endpoint_identifier);
CREATE INDEX index_identities_on_saml_provider_id ON identities USING btree (saml_provider_id) WHERE (saml_provider_id IS NOT NULL);
@@ -31467,6 +31636,10 @@ CREATE INDEX index_issues_on_moved_to_id ON issues USING btree (moved_to_id) WHE
CREATE INDEX index_issues_on_namespace_id ON issues USING btree (namespace_id);
+CREATE INDEX index_issues_on_project_health_status_asc_work_item_type ON issues USING btree (project_id, health_status, id DESC, state_id, work_item_type_id);
+
+CREATE INDEX index_issues_on_project_health_status_desc_work_item_type ON issues USING btree (project_id, health_status DESC NULLS LAST, id DESC, state_id, work_item_type_id);
+
CREATE INDEX index_issues_on_project_id_and_created_at_issue_type_incident ON issues USING btree (project_id, created_at) WHERE (issue_type = 1);
CREATE UNIQUE INDEX index_issues_on_project_id_and_external_key ON issues USING btree (project_id, external_key) WHERE (external_key IS NOT NULL);
@@ -31701,6 +31874,12 @@ CREATE INDEX index_merge_request_metrics_on_pipeline_id ON merge_request_metrics
CREATE INDEX index_merge_request_metrics_on_target_project_id ON merge_request_metrics USING btree (target_project_id);
+CREATE INDEX index_merge_request_review_llm_summaries_on_mr_diff_id ON merge_request_review_llm_summaries USING btree (merge_request_diff_id);
+
+CREATE INDEX index_merge_request_review_llm_summaries_on_review_id ON merge_request_review_llm_summaries USING btree (review_id);
+
+CREATE INDEX index_merge_request_review_llm_summaries_on_user_id ON merge_request_review_llm_summaries USING btree (user_id);
+
CREATE UNIQUE INDEX index_merge_request_reviewers_on_merge_request_id_and_user_id ON merge_request_reviewers USING btree (merge_request_id, user_id);
CREATE INDEX index_merge_request_reviewers_on_user_id ON merge_request_reviewers USING btree (user_id);
@@ -31823,12 +32002,26 @@ CREATE INDEX index_ml_candidates_on_user_id ON ml_candidates USING btree (user_i
CREATE UNIQUE INDEX index_ml_experiment_metadata_on_experiment_id_and_name ON ml_experiment_metadata USING btree (experiment_id, name);
+CREATE INDEX index_ml_experiments_on_model_id ON ml_experiments USING btree (model_id);
+
CREATE UNIQUE INDEX index_ml_experiments_on_project_id_and_iid ON ml_experiments USING btree (project_id, iid);
CREATE UNIQUE INDEX index_ml_experiments_on_project_id_and_name ON ml_experiments USING btree (project_id, name);
CREATE INDEX index_ml_experiments_on_user_id ON ml_experiments USING btree (user_id);
+CREATE INDEX index_ml_model_versions_on_model_id ON ml_model_versions USING btree (model_id);
+
+CREATE INDEX index_ml_model_versions_on_package_id ON ml_model_versions USING btree (package_id);
+
+CREATE INDEX index_ml_model_versions_on_project_id ON ml_model_versions USING btree (project_id);
+
+CREATE UNIQUE INDEX index_ml_model_versions_on_project_id_and_model_id_and_version ON ml_model_versions USING btree (project_id, model_id, version);
+
+CREATE INDEX index_ml_models_on_project_id ON ml_models USING btree (project_id);
+
+CREATE UNIQUE INDEX index_ml_models_on_project_id_and_name ON ml_models USING btree (project_id, name);
+
CREATE UNIQUE INDEX index_mr_blocks_on_blocking_and_blocked_mr_ids ON merge_request_blocks USING btree (blocking_merge_request_id, blocked_merge_request_id);
CREATE INDEX index_mr_cleanup_schedules_timestamps_status ON merge_request_cleanup_schedules USING btree (scheduled_at) WHERE ((completed_at IS NULL) AND (status = 0));
@@ -31871,6 +32064,8 @@ CREATE INDEX index_namespaces_on_ldap_sync_last_update_at ON namespaces USING bt
CREATE INDEX index_namespaces_on_name_trigram ON namespaces USING gin (name gin_trgm_ops);
+CREATE INDEX index_namespaces_on_organization_id ON namespaces USING btree (organization_id);
+
CREATE INDEX index_namespaces_on_owner_id ON namespaces USING btree (owner_id);
CREATE UNIQUE INDEX index_namespaces_on_parent_id_and_id ON namespaces USING btree (parent_id, id);
@@ -32061,6 +32256,10 @@ CREATE UNIQUE INDEX index_ops_feature_flags_issues_on_feature_flag_id_and_issue_
CREATE UNIQUE INDEX index_ops_strategies_user_lists_on_strategy_id_and_user_list_id ON operations_strategies_user_lists USING btree (strategy_id, user_list_id);
+CREATE UNIQUE INDEX index_organization_users_on_organization_id_and_user_id ON organization_users USING btree (organization_id, user_id);
+
+CREATE INDEX index_organization_users_on_user_id ON organization_users USING btree (user_id);
+
CREATE UNIQUE INDEX index_organizations_on_unique_name_per_group ON customer_relations_organizations USING btree (group_id, lower(name), id);
CREATE UNIQUE INDEX index_p_ci_job_annotations_on_partition_id_job_id_name ON ONLY p_ci_job_annotations USING btree (partition_id, job_id, name);
@@ -32245,8 +32444,6 @@ CREATE INDEX index_pm_package_version_licenses_on_pm_package_version_id ON pm_pa
CREATE INDEX index_pm_package_versions_on_pm_package_id ON pm_package_versions USING btree (pm_package_id);
-CREATE UNIQUE INDEX index_pool_repositories_on_disk_path ON pool_repositories USING btree (disk_path);
-
CREATE INDEX index_pool_repositories_on_shard_id ON pool_repositories USING btree (shard_id);
CREATE UNIQUE INDEX index_pool_repositories_on_source_project_id_and_shard_id ON pool_repositories USING btree (source_project_id, shard_id);
@@ -32393,6 +32590,8 @@ CREATE INDEX index_project_topics_on_topic_id ON project_topics USING btree (top
CREATE UNIQUE INDEX index_project_user_callouts_feature ON user_project_callouts USING btree (user_id, feature_name, project_id);
+CREATE INDEX index_project_vulnerability_reads_common_finder_query_desc ON vulnerability_reads USING btree (project_id, state, report_type, severity DESC, vulnerability_id DESC);
+
CREATE UNIQUE INDEX index_project_wiki_repositories_on_project_id ON project_wiki_repositories USING btree (project_id);
CREATE INDEX index_projects_aimed_for_deletion ON projects USING btree (marked_for_deletion_at) WHERE ((marked_for_deletion_at IS NOT NULL) AND (pending_delete = false));
@@ -32721,6 +32920,8 @@ CREATE UNIQUE INDEX index_sbom_sources_on_source_type_and_source ON sbom_sources
CREATE INDEX index_scan_result_policies_on_policy_configuration_id ON scan_result_policies USING btree (security_orchestration_policy_configuration_id);
+CREATE INDEX index_scan_result_policies_on_project_id ON scan_result_policies USING btree (project_id);
+
CREATE INDEX index_schema_inconsistencies_on_issue_id ON schema_inconsistencies USING btree (issue_id);
CREATE INDEX index_scim_identities_on_group_id ON scim_identities USING btree (group_id);
@@ -32903,6 +33104,8 @@ CREATE INDEX index_subscription_add_on_purchases_on_subscription_add_on_id ON su
CREATE UNIQUE INDEX index_subscription_add_ons_on_name ON subscription_add_ons USING btree (name);
+CREATE INDEX index_subscription_user_add_on_assignments_on_user_id ON subscription_user_add_on_assignments USING btree (user_id);
+
CREATE INDEX index_subscriptions_on_project_id ON subscriptions USING btree (project_id);
CREATE UNIQUE INDEX index_subscriptions_on_subscribable_and_user_id_and_project_id ON subscriptions USING btree (subscribable_id, subscribable_type, user_id, project_id);
@@ -32913,6 +33116,8 @@ CREATE INDEX index_successful_deployments_on_cluster_id_and_environment_id ON de
CREATE UNIQUE INDEX index_suggestions_on_note_id_and_relative_order ON suggestions USING btree (note_id, relative_order);
+CREATE UNIQUE INDEX index_system_access_microsoft_applications_on_namespace_id ON system_access_microsoft_applications USING btree (namespace_id);
+
CREATE UNIQUE INDEX index_system_note_metadata_on_description_version_id ON system_note_metadata USING btree (description_version_id) WHERE (description_version_id IS NOT NULL);
CREATE UNIQUE INDEX index_system_note_metadata_on_note_id ON system_note_metadata USING btree (note_id);
@@ -32999,10 +33204,6 @@ CREATE INDEX index_topics_total_projects_count ON topics USING btree (total_proj
CREATE UNIQUE INDEX index_trending_projects_on_project_id ON trending_projects USING btree (project_id);
-CREATE INDEX index_u2f_registrations_on_key_handle ON u2f_registrations USING btree (key_handle);
-
-CREATE INDEX index_u2f_registrations_on_user_id ON u2f_registrations USING btree (user_id);
-
CREATE UNIQUE INDEX index_uniq_ci_runners_on_token ON ci_runners USING btree (token);
CREATE UNIQUE INDEX index_uniq_ci_runners_on_token_encrypted ON ci_runners USING btree (token_encrypted);
@@ -33147,7 +33348,7 @@ CREATE INDEX index_users_on_state_and_user_type ON users USING btree (state, use
CREATE UNIQUE INDEX index_users_on_static_object_token ON users USING btree (static_object_token);
-CREATE INDEX index_users_on_unconfirmed_and_created_at_for_active_humans ON users USING btree (created_at, id) WHERE ((confirmed_at IS NULL) AND ((state)::text = 'active'::text) AND (user_type = 0));
+CREATE INDEX index_users_on_unconfirmed_created_at_active_type_sign_in_count ON users USING btree (created_at, id) WHERE ((confirmed_at IS NULL) AND ((state)::text = 'active'::text) AND (user_type = 0) AND (sign_in_count = 0));
CREATE INDEX index_users_on_unconfirmed_email ON users USING btree (unconfirmed_email) WHERE (unconfirmed_email IS NOT NULL);
@@ -33195,6 +33396,8 @@ CREATE INDEX index_vulnerabilities_on_author_id ON vulnerabilities USING btree (
CREATE INDEX index_vulnerabilities_on_confirmed_by_id ON vulnerabilities USING btree (confirmed_by_id);
+CREATE INDEX index_vulnerabilities_on_detected_at_and_id ON vulnerabilities USING btree (id, detected_at);
+
CREATE INDEX index_vulnerabilities_on_dismissed_by_id ON vulnerabilities USING btree (dismissed_by_id);
CREATE INDEX index_vulnerabilities_on_due_date_sourcing_milestone_id ON vulnerabilities USING btree (due_date_sourcing_milestone_id);
@@ -33315,6 +33518,8 @@ CREATE INDEX index_vulnerability_reads_on_scanner_id ON vulnerability_reads USIN
CREATE UNIQUE INDEX index_vulnerability_reads_on_uuid ON vulnerability_reads USING btree (uuid);
+CREATE INDEX index_vulnerability_reads_on_uuid_project_id_and_state ON vulnerability_reads USING btree (uuid, project_id, state);
+
CREATE UNIQUE INDEX index_vulnerability_reads_on_vulnerability_id ON vulnerability_reads USING btree (vulnerability_id);
CREATE UNIQUE INDEX index_vulnerability_remediations_on_project_id_and_checksum ON vulnerability_remediations USING btree (project_id, checksum);
@@ -33335,10 +33540,6 @@ CREATE UNIQUE INDEX index_vulnerability_statistics_on_unique_project_id ON vulne
CREATE UNIQUE INDEX index_vulnerability_user_mentions_on_note_id ON vulnerability_user_mentions USING btree (note_id) WHERE (note_id IS NOT NULL);
-CREATE INDEX index_vulnerable_component_versions_on_sbom_component_version ON sbom_vulnerable_component_versions USING btree (sbom_component_version_id);
-
-CREATE INDEX index_vulnerable_component_versions_on_vulnerability_advisory ON sbom_vulnerable_component_versions USING btree (vulnerability_advisory_id);
-
CREATE UNIQUE INDEX index_vulns_user_mentions_on_vulnerability_id ON vulnerability_user_mentions USING btree (vulnerability_id) WHERE (note_id IS NULL);
CREATE UNIQUE INDEX index_vulns_user_mentions_on_vulnerability_id_and_note_id ON vulnerability_user_mentions USING btree (vulnerability_id, note_id);
@@ -33521,28 +33722,22 @@ CREATE INDEX tmp_idx_for_vulnerability_feedback_migration ON vulnerability_feedb
CREATE INDEX tmp_idx_packages_on_project_id_when_npm_not_pending_destruction ON packages_packages USING btree (project_id) WHERE ((package_type = 2) AND (status <> 4));
+CREATE INDEX tmp_idx_vuln_reads_where_dismissal_reason_null ON vulnerability_reads USING btree (id) WHERE ((state = 2) AND (dismissal_reason IS NULL));
+
CREATE INDEX tmp_idx_vulnerability_occurrences_on_id_where_report_type_7_99 ON vulnerability_occurrences USING btree (id) WHERE (report_type = ANY (ARRAY[7, 99]));
-CREATE INDEX tmp_index_ci_job_artifacts_on_expire_at_where_locked_unknown ON ci_job_artifacts USING btree (expire_at, job_id) WHERE ((locked = 2) AND (expire_at IS NOT NULL));
+CREATE INDEX tmp_idx_vulns_on_converted_uuid ON vulnerability_occurrences USING btree (id, uuid_convert_string_to_uuid) WHERE (uuid_convert_string_to_uuid = '00000000-0000-0000-0000-000000000000'::uuid);
-CREATE INDEX tmp_index_ci_job_artifacts_on_id_expire_at_file_type_trace ON ci_job_artifacts USING btree (id) WHERE (((date_part('day'::text, timezone('UTC'::text, expire_at)) = ANY (ARRAY[(21)::double precision, (22)::double precision, (23)::double precision])) AND (date_part('minute'::text, timezone('UTC'::text, expire_at)) = ANY (ARRAY[(0)::double precision, (30)::double precision, (45)::double precision])) AND (date_part('second'::text, timezone('UTC'::text, expire_at)) = (0)::double precision)) OR (file_type = 3));
+CREATE INDEX tmp_index_ci_job_artifacts_on_expire_at_where_locked_unknown ON ci_job_artifacts USING btree (expire_at, job_id) WHERE ((locked = 2) AND (expire_at IS NOT NULL));
CREATE INDEX tmp_index_cis_vulnerability_reads_on_id ON vulnerability_reads USING btree (id) WHERE (report_type = 7);
-CREATE INDEX tmp_index_container_repos_on_non_migrated ON container_repositories USING btree (project_id, id) WHERE (migration_state <> 'import_done'::text);
-
-CREATE INDEX tmp_index_container_repositories_on_id_migration_state ON container_repositories USING btree (id, migration_state);
-
-CREATE INDEX tmp_index_for_backfilling_resource_link_events ON system_note_metadata USING btree (id) WHERE (((action)::text = 'relate_to_parent'::text) OR ((action)::text = 'unrelate_from_parent'::text));
-
CREATE INDEX tmp_index_for_null_member_namespace_id ON members USING btree (member_namespace_id) WHERE (member_namespace_id IS NULL);
CREATE INDEX tmp_index_for_project_namespace_id_migration_on_routes ON routes USING btree (id) WHERE ((namespace_id IS NULL) AND ((source_type)::text = 'Project'::text));
CREATE INDEX tmp_index_members_on_state ON members USING btree (state) WHERE (state = 2);
-CREATE INDEX tmp_index_migrated_container_registries ON container_repositories USING btree (project_id) WHERE ((migration_state = 'import_done'::text) OR (created_at >= '2022-01-23 00:00:00'::timestamp without time zone));
-
CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING btree (id) WHERE (state <> 2);
CREATE INDEX tmp_index_project_statistics_cont_registry_size ON project_statistics USING btree (project_id) WHERE (container_registry_size = 0);
@@ -33555,6 +33750,8 @@ CREATE UNIQUE INDEX u_project_compliance_standards_adherence_for_reporting ON pr
CREATE UNIQUE INDEX uniq_idx_packages_packages_on_project_id_name_version_ml_model ON packages_packages USING btree (project_id, name, version) WHERE (package_type = 14);
+CREATE UNIQUE INDEX uniq_idx_user_add_on_assignments_on_add_on_purchase_and_user ON subscription_user_add_on_assignments USING btree (add_on_purchase_id, user_id);
+
CREATE UNIQUE INDEX uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name ON packages_debian_group_architectures USING btree (distribution_id, name);
CREATE UNIQUE INDEX uniq_pkgs_deb_grp_components_on_distribution_id_and_name ON packages_debian_group_components USING btree (distribution_id, name);
@@ -33573,6 +33770,8 @@ CREATE UNIQUE INDEX uniq_pkgs_debian_project_distributions_project_id_and_suite
CREATE UNIQUE INDEX unique_ci_builds_token_encrypted_and_partition_id ON ci_builds USING btree (token_encrypted, partition_id) WHERE (token_encrypted IS NOT NULL);
+CREATE UNIQUE INDEX unique_external_audit_event_destination_namespace_id_and_name ON audit_events_external_audit_event_destinations USING btree (namespace_id, name);
+
CREATE UNIQUE INDEX unique_google_cloud_logging_configurations_on_namespace_id ON audit_events_google_cloud_logging_configurations USING btree (namespace_id, google_project_id_name, log_id_name);
CREATE UNIQUE INDEX unique_idx_namespaces_storage_limit_exclusions_on_namespace_id ON namespaces_storage_limit_exclusions USING btree (namespace_id);
@@ -33583,6 +33782,10 @@ CREATE UNIQUE INDEX unique_index_for_project_pages_unique_domain ON project_sett
CREATE UNIQUE INDEX unique_index_on_system_note_metadata_id ON resource_link_events USING btree (system_note_metadata_id);
+CREATE UNIQUE INDEX unique_index_sysaccess_ms_access_tokens_on_sysaccess_ms_app_id ON system_access_microsoft_graph_access_tokens USING btree (system_access_microsoft_application_id);
+
+CREATE UNIQUE INDEX unique_instance_audit_event_destination_name ON audit_events_instance_external_audit_event_destinations USING btree (name);
+
CREATE UNIQUE INDEX unique_merge_request_diff_llm_summaries_on_mr_diff_id ON merge_request_diff_llm_summaries USING btree (merge_request_diff_id);
CREATE UNIQUE INDEX unique_merge_request_metrics_by_merge_request_id ON merge_request_metrics USING btree (merge_request_id);
@@ -33591,6 +33794,8 @@ CREATE UNIQUE INDEX unique_organizations_on_path ON organizations USING btree (p
CREATE UNIQUE INDEX unique_packages_project_id_and_name_and_version_when_debian ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 9) AND (status <> 4));
+CREATE UNIQUE INDEX unique_pool_repositories_on_disk_path_and_shard_id ON pool_repositories USING btree (disk_path, shard_id);
+
CREATE UNIQUE INDEX unique_postgres_async_fk_validations_name_and_table_name ON postgres_async_foreign_key_validations USING btree (name, table_name);
CREATE UNIQUE INDEX unique_projects_on_name_namespace_id ON projects USING btree (name, namespace_id);
@@ -35095,20 +35300,22 @@ CREATE TRIGGER namespaces_loose_fk_trigger AFTER DELETE ON namespaces REFERENCIN
CREATE TRIGGER nullify_merge_request_metrics_build_data_on_update BEFORE UPDATE ON merge_request_metrics FOR EACH ROW EXECUTE FUNCTION nullify_merge_request_metrics_build_data();
+CREATE TRIGGER organizations_loose_fk_trigger AFTER DELETE ON organizations REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
CREATE TRIGGER p_ci_builds_loose_fk_trigger AFTER DELETE ON p_ci_builds REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+CREATE TRIGGER prevent_delete_of_default_organization_before_destroy BEFORE DELETE ON organizations FOR EACH ROW EXECUTE FUNCTION prevent_delete_of_default_organization();
+
CREATE TRIGGER projects_loose_fk_trigger AFTER DELETE ON projects REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
CREATE TRIGGER push_rules_loose_fk_trigger AFTER DELETE ON push_rules REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
CREATE TRIGGER tags_loose_fk_trigger AFTER DELETE ON tags REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
-CREATE TRIGGER trigger_023e82d8e257 BEFORE INSERT OR UPDATE ON ci_pipeline_variables FOR EACH ROW EXECUTE FUNCTION trigger_023e82d8e257();
-
-CREATE TRIGGER trigger_080e73845bfd BEFORE INSERT OR UPDATE ON notes FOR EACH ROW EXECUTE FUNCTION trigger_080e73845bfd();
-
CREATE TRIGGER trigger_1a857e8db6cd BEFORE INSERT OR UPDATE ON vulnerability_occurrences FOR EACH ROW EXECUTE FUNCTION trigger_1a857e8db6cd();
+CREATE TRIGGER trigger_7f3d66a7d7f5 BEFORE INSERT OR UPDATE ON ci_pipeline_variables FOR EACH ROW EXECUTE FUNCTION trigger_7f3d66a7d7f5();
+
CREATE TRIGGER trigger_b2d852e1e2cb BEFORE INSERT OR UPDATE ON ci_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_b2d852e1e2cb();
CREATE TRIGGER trigger_cd1aeb22b34a BEFORE INSERT OR UPDATE ON events FOR EACH ROW EXECUTE FUNCTION trigger_cd1aeb22b34a();
@@ -35220,6 +35427,9 @@ ALTER TABLE ONLY notification_settings
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_0d3f677137 FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE;
+ALTER TABLE ONLY subscription_user_add_on_assignments
+ ADD CONSTRAINT fk_0d89020c49 FOREIGN KEY (add_on_purchase_id) REFERENCES subscription_add_on_purchases(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY deployment_approvals
ADD CONSTRAINT fk_0f58311058 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -35403,6 +35613,9 @@ ALTER TABLE ONLY incident_management_timeline_events
ALTER TABLE ONLY bulk_import_exports
ADD CONSTRAINT fk_39c726d3b5 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_model_versions
+ ADD CONSTRAINT fk_39f8aa0b8a FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE SET NULL;
+
ALTER TABLE p_ci_builds
ADD CONSTRAINT fk_3a9eaa254d FOREIGN KEY (stage_id) REFERENCES ci_stages(id) ON DELETE CASCADE;
@@ -35469,6 +35682,9 @@ ALTER TABLE ONLY sbom_occurrences
ALTER TABLE ONLY namespace_commit_emails
ADD CONSTRAINT fk_4d6ba63ba5 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_model_versions
+ ADD CONSTRAINT fk_4e8b59e7a8 FOREIGN KEY (model_id) REFERENCES ml_models(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY user_achievements
ADD CONSTRAINT fk_4efde02858 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -35535,6 +35751,9 @@ ALTER TABLE ONLY user_achievements
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_6149611a04 FOREIGN KEY (assignee_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY merge_request_review_llm_summaries
+ ADD CONSTRAINT fk_6154a9cb89 FOREIGN KEY (review_id) REFERENCES reviews(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY work_item_widget_definitions
ADD CONSTRAINT fk_61bfa96db5 FOREIGN KEY (work_item_type_id) REFERENCES work_item_types(id) ON DELETE CASCADE;
@@ -35589,6 +35808,9 @@ ALTER TABLE ONLY integrations
ALTER TABLE ONLY user_interacted_projects
ADD CONSTRAINT fk_722ceba4f7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY subscription_user_add_on_assignments
+ ADD CONSTRAINT fk_724c2df9a8 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT fk_725465b774 FOREIGN KEY (dismissed_by_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -35625,6 +35847,9 @@ ALTER TABLE ONLY lists
ALTER TABLE ONLY protected_branches
ADD CONSTRAINT fk_7a9c6d93e7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY scan_result_policies
+ ADD CONSTRAINT fk_7aa24439f1 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT fk_7ac31eacb9 FOREIGN KEY (updated_by_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -35658,6 +35883,9 @@ ALTER TABLE ONLY import_export_uploads
ALTER TABLE ONLY push_rules
ADD CONSTRAINT fk_83b29894de FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY organization_users
+ ADD CONSTRAINT fk_8471abad75 FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY merge_request_diffs
ADD CONSTRAINT fk_8483f3258f FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
@@ -35691,21 +35919,24 @@ ALTER TABLE ONLY issues
ALTER TABLE ONLY ci_build_trace_chunks
ADD CONSTRAINT fk_89e29fa5ee_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
-ALTER TABLE ONLY sbom_vulnerable_component_versions
- ADD CONSTRAINT fk_8a2a1197f9 FOREIGN KEY (sbom_component_version_id) REFERENCES sbom_component_versions(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY protected_branch_merge_access_levels
ADD CONSTRAINT fk_8a3072ccb3 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE;
ALTER TABLE ONLY bulk_import_exports
ADD CONSTRAINT fk_8c6f33cebe FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY organization_users
+ ADD CONSTRAINT fk_8d9b20725d FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY releases
ADD CONSTRAINT fk_8e4456f90f FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY protected_tags
ADD CONSTRAINT fk_8e4af87648 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY merge_request_review_llm_summaries
+ ADD CONSTRAINT fk_8ec009c6ab FOREIGN KEY (merge_request_diff_id) REFERENCES merge_request_diffs(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY todos
ADD CONSTRAINT fk_91d1f47b13 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE;
@@ -35893,7 +36124,7 @@ ALTER TABLE ONLY routes
ADD CONSTRAINT fk_bb2e5b8968 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE p_ci_runner_machine_builds
- ADD CONSTRAINT fk_bb490f12fe_p FOREIGN KEY (partition_id, build_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
+ ADD CONSTRAINT fk_bb490f12fe_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY namespace_bans
ADD CONSTRAINT fk_bcc024eef2 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -35961,6 +36192,9 @@ ALTER TABLE ONLY agent_activity_events
ALTER TABLE ONLY issue_links
ADD CONSTRAINT fk_c900194ff2 FOREIGN KEY (source_id) REFERENCES issues(id) ON DELETE CASCADE;
+ALTER TABLE ONLY personal_access_tokens
+ ADD CONSTRAINT fk_c951fbf57e FOREIGN KEY (previous_personal_access_token_id) REFERENCES personal_access_tokens(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY jira_tracker_data
ADD CONSTRAINT fk_c98abcd54c FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE;
@@ -35997,6 +36231,9 @@ ALTER TABLE ONLY custom_emoji
ALTER TABLE ONLY bulk_import_entities
ADD CONSTRAINT fk_d06d023c30 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY merge_request_review_llm_summaries
+ ADD CONSTRAINT fk_d07eeb6392 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY project_mirror_data
ADD CONSTRAINT fk_d1aad367d7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -36018,9 +36255,6 @@ ALTER TABLE ONLY lists
ALTER TABLE ONLY agent_activity_events
ADD CONSTRAINT fk_d6f785c9fc FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
-ALTER TABLE ONLY sbom_vulnerable_component_versions
- ADD CONSTRAINT fk_d720a1959a FOREIGN KEY (vulnerability_advisory_id) REFERENCES vulnerability_advisories(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY user_achievements
ADD CONSTRAINT fk_d7653ef780 FOREIGN KEY (revoked_by_user_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -36082,7 +36316,7 @@ ALTER TABLE ONLY ci_sources_pipelines
ADD CONSTRAINT fk_e1bad85861 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE;
ALTER TABLE p_ci_builds_metadata
- ADD CONSTRAINT fk_e20479742e_p FOREIGN KEY (partition_id, build_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
+ ADD CONSTRAINT fk_e20479742e_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY gitlab_subscriptions
ADD CONSTRAINT fk_e2595d00a1 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -36213,6 +36447,12 @@ ALTER TABLE ONLY ml_candidate_metrics
ALTER TABLE ONLY ml_candidate_params
ADD CONSTRAINT fk_ml_candidate_params_on_candidate_id FOREIGN KEY (candidate_id) REFERENCES ml_candidates(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_candidates
+ ADD CONSTRAINT fk_ml_candidates_on_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
+
+ALTER TABLE ONLY ml_experiments
+ ADD CONSTRAINT fk_ml_experiments_on_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY path_locks
ADD CONSTRAINT fk_path_locks_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -36408,9 +36648,6 @@ ALTER TABLE ONLY vulnerability_user_mentions
ALTER TABLE ONLY packages_debian_file_metadata
ADD CONSTRAINT fk_rails_1ae85be112 FOREIGN KEY (package_file_id) REFERENCES packages_package_files(id) ON DELETE CASCADE;
-ALTER TABLE ONLY ml_candidates
- ADD CONSTRAINT fk_rails_1b37441fe5 FOREIGN KEY (user_id) REFERENCES users(id);
-
ALTER TABLE ONLY issuable_slas
ADD CONSTRAINT fk_rails_1b8768cd63 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -36438,9 +36675,6 @@ ALTER TABLE ONLY geo_repository_created_events
ALTER TABLE ONLY external_status_checks
ADD CONSTRAINT fk_rails_1f5a8aa809 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-ALTER TABLE ONLY ml_experiments
- ADD CONSTRAINT fk_rails_1fbc5e001f FOREIGN KEY (user_id) REFERENCES users(id);
-
ALTER TABLE ONLY dora_daily_metrics
ADD CONSTRAINT fk_rails_1fd07aff6f FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE;
@@ -36774,6 +37008,9 @@ ALTER TABLE ONLY project_repository_storage_moves
ALTER TABLE ONLY ml_candidate_metadata
ADD CONSTRAINT fk_rails_5117dddf22 FOREIGN KEY (candidate_id) REFERENCES ml_candidates(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_models
+ ADD CONSTRAINT fk_rails_51e87f7c50 FOREIGN KEY (project_id) REFERENCES projects(id);
+
ALTER TABLE ONLY elastic_group_index_statuses
ADD CONSTRAINT fk_rails_52b9969b12 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -36864,6 +37101,9 @@ ALTER TABLE ONLY incident_management_oncall_participants
ALTER TABLE ONLY work_item_parent_links
ADD CONSTRAINT fk_rails_601d5bec3a FOREIGN KEY (work_item_id) REFERENCES issues(id) ON DELETE CASCADE;
+ALTER TABLE ONLY system_access_microsoft_graph_access_tokens
+ ADD CONSTRAINT fk_rails_604908851f FOREIGN KEY (system_access_microsoft_application_id) REFERENCES system_access_microsoft_applications(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY vulnerability_state_transitions
ADD CONSTRAINT fk_rails_60e4899648 FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities(id) ON DELETE CASCADE;
@@ -37086,6 +37326,9 @@ ALTER TABLE ONLY required_code_owners_sections
ALTER TABLE ONLY namespace_ldap_settings
ADD CONSTRAINT fk_rails_82cd0ad4bb FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY group_wiki_repository_states
+ ADD CONSTRAINT fk_rails_832511c9f1 FOREIGN KEY (group_wiki_repository_id) REFERENCES group_wiki_repositories(group_id) ON DELETE CASCADE;
+
ALTER TABLE ONLY cluster_enabled_grants
ADD CONSTRAINT fk_rails_8336ce35af FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -37134,6 +37377,9 @@ ALTER TABLE ONLY achievements
ALTER TABLE ONLY protected_environment_deploy_access_levels
ADD CONSTRAINT fk_rails_898a13b650 FOREIGN KEY (protected_environment_id) REFERENCES protected_environments(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_model_versions
+ ADD CONSTRAINT fk_rails_8a481bd22e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY snippet_repositories
ADD CONSTRAINT fk_rails_8afd7e2f71 FOREIGN KEY (snippet_id) REFERENCES snippets(id) ON DELETE CASCADE;
@@ -37230,6 +37476,9 @@ ALTER TABLE ONLY boards_epic_board_recent_visits
ALTER TABLE ONLY packages_dependency_links
ADD CONSTRAINT fk_rails_96ef1c00d3 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_experiments
+ ADD CONSTRAINT fk_rails_97194a054e FOREIGN KEY (model_id) REFERENCES ml_models(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY group_repository_storage_moves
ADD CONSTRAINT fk_rails_982bb5daf1 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -37549,7 +37798,13 @@ ALTER TABLE ONLY boards_epic_board_recent_visits
ADD CONSTRAINT fk_rails_c4dcba4a3e FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_job_artifacts
- ADD CONSTRAINT fk_rails_c5137cb2c1_p FOREIGN KEY (partition_id, job_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
+ ADD CONSTRAINT fk_rails_c5137cb2c1_p FOREIGN KEY (partition_id, job_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
+
+ALTER TABLE ONLY organization_settings
+ ADD CONSTRAINT fk_rails_c56e4690c0 FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY system_access_microsoft_applications
+ ADD CONSTRAINT fk_rails_c5b7765d04 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY project_settings
ADD CONSTRAINT fk_rails_c6df6e6328 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -37663,7 +37918,7 @@ ALTER TABLE ONLY merge_request_reviewers
ADD CONSTRAINT fk_rails_d9fec24b9d FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_running_builds
- ADD CONSTRAINT fk_rails_da45cfa165_p FOREIGN KEY (partition_id, build_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
+ ADD CONSTRAINT fk_rails_da45cfa165_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY resource_link_events
ADD CONSTRAINT fk_rails_da5dd8a56f FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -37915,7 +38170,7 @@ ALTER TABLE ONLY board_project_recent_visits
ADD CONSTRAINT fk_rails_fb6fc419cb FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_job_variables
- ADD CONSTRAINT fk_rails_fbf3b34792_p FOREIGN KEY (partition_id, job_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
+ ADD CONSTRAINT fk_rails_fbf3b34792_p FOREIGN KEY (partition_id, job_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY packages_nuget_metadata
ADD CONSTRAINT fk_rails_fc0c19f5b4 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
@@ -37956,9 +38211,6 @@ ALTER TABLE ONLY timelogs
ALTER TABLE ONLY timelogs
ADD CONSTRAINT fk_timelogs_note_id FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE SET NULL;
-ALTER TABLE ONLY u2f_registrations
- ADD CONSTRAINT fk_u2f_registrations_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
-
ALTER TABLE issue_search_data
ADD CONSTRAINT issue_search_data_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -37968,18 +38220,6 @@ ALTER TABLE issue_search_data
ALTER TABLE product_analytics_events_experimental
ADD CONSTRAINT product_analytics_events_experimental_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-ALTER TABLE ONLY ci_builds_metadata
- ADD CONSTRAINT temp_fk_e20479742e_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
-
-ALTER TABLE ONLY ci_job_artifacts
- ADD CONSTRAINT temp_fk_rails_c5137cb2c1_p FOREIGN KEY (partition_id, job_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
-
-ALTER TABLE ONLY ci_running_builds
- ADD CONSTRAINT temp_fk_rails_da45cfa165_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
-
-ALTER TABLE ONLY ci_job_variables
- ADD CONSTRAINT temp_fk_rails_fbf3b34792_p FOREIGN KEY (partition_id, job_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
-
ALTER TABLE ONLY user_follow_users
ADD CONSTRAINT user_follow_users_followee_id_fkey FOREIGN KEY (followee_id) REFERENCES users(id) ON DELETE CASCADE;