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/docs/README.md6
-rw-r--r--db/docs/integrations.yml1
-rw-r--r--db/docs/member_roles.yml10
-rw-r--r--db/docs/ml_candidate_metrics.yml10
-rw-r--r--db/docs/ml_candidate_params.yml10
-rw-r--r--db/docs/ml_candidates.yml10
-rw-r--r--db/docs/ml_experiments.yml10
-rw-r--r--db/docs/namespace_details.yml9
-rw-r--r--db/docs/project_statistics.yml8
-rw-r--r--db/docs/user_project_callouts.yml9
-rw-r--r--db/fixtures/development/14_pipelines.rb2
-rw-r--r--db/fixtures/development/18_abuse_reports.rb2
-rw-r--r--db/migrate/20210601080039_group_protected_environments_add_index_and_constraint.rb2
-rw-r--r--db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb70
-rw-r--r--db/migrate/20210804150320_create_base_work_item_types.rb6
-rw-r--r--db/migrate/20210831203408_upsert_base_work_item_types.rb6
-rw-r--r--db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb5
-rw-r--r--db/migrate/20220316022505_create_namespace_details.rb21
-rw-r--r--db/migrate/20220406113217_add_inactive_project_deletion_to_application_settings.rb4
-rw-r--r--db/migrate/20220506154054_create_sync_namespace_details_trigger.rb70
-rw-r--r--db/migrate/20220513093614_add_ding_talk_into_application_settings.rb4
-rw-r--r--db/migrate/20220513093615_add_ding_talk_tracker_data.rb2
-rw-r--r--db/migrate/20220524184149_create_sync_project_namespace_details_trigger.rb68
-rw-r--r--db/migrate/20220619212618_add_selective_code_owner_removals_to_project_settings.rb9
-rw-r--r--db/migrate/20220627061008_add_fei_shu_integration.rb4
-rw-r--r--db/migrate/20220707105335_rename_chat_name_service_id_to_integration_id.rb13
-rw-r--r--db/migrate/20220707160707_rename_slack_integration_service_id_to_integration_id.rb13
-rw-r--r--db/migrate/20220707181910_create_member_roles.rb15
-rw-r--r--db/migrate/20220707181920_add_member_role_id_to_members.rb13
-rw-r--r--db/migrate/20220707181930_add_member_roles_relation_to_members.rb19
-rw-r--r--db/migrate/20220707190546_add_plan_limits_max_size_cyclonedx_report_column.rb7
-rw-r--r--db/migrate/20220708150315_add_vulnerabilities_foreign_key_to_vulnerability_merge_request_links.rb4
-rw-r--r--db/migrate/20220708150335_add_merge_requests_foreign_key_to_vulnerability_merge_request_links.rb4
-rw-r--r--db/migrate/20220712131513_rename_issue_tracker_data_service_id_to_integration_id.rb13
-rw-r--r--db/migrate/20220712144843_rename_jira_tracker_data_service_id_to_integration_id.rb13
-rw-r--r--db/migrate/20220718083945_add_unique_project_download_limit_allowlist_to_namespace_settings.rb11
-rw-r--r--db/migrate/20220720161816_add_namespace_id_to_vulnerability_reads_table.rb9
-rw-r--r--db/migrate/20220720162123_update_vulnerability_reads_triggers_to_set_namespace_id.rb159
-rw-r--r--db/migrate/20220720210446_add_start_date_to_issues_table.rb9
-rw-r--r--db/migrate/20220722123318_update_delayed_deletion_period.rb27
-rw-r--r--db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb32
-rw-r--r--db/migrate/20220722203840_update_lock_writes_function_disabled_via_setting.rb36
-rw-r--r--db/migrate/20220723120039_add_author_id_to_vulnerability_state_transitions.rb7
-rw-r--r--db/migrate/20220726025516_add_namespace_settings_unique_project_download_limit_allowlist_size_constraint.rb17
-rw-r--r--db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb18
-rw-r--r--db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb17
-rw-r--r--db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb15
-rw-r--r--db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb18
-rw-r--r--db/migrate/20220726154016_make_component_version_nullable.rb9
-rw-r--r--db/migrate/20220726230052_remove_tmp_index_project_membership_namespace_id_column.rb20
-rw-r--r--db/migrate/20220728114136_make_ssh_signature_key_nullable.rb9
-rw-r--r--db/migrate/20220729073603_index_personal_access_tokens_on_id_and_created_at.rb15
-rw-r--r--db/migrate/20220802154757_add_deactivate_dormant_user_time_setting.rb6
-rw-r--r--db/migrate/20220803145637_create_user_project_callout.rb19
-rw-r--r--db/migrate/20220803154543_add_project_id_fkey_for_user_project_callout.rb15
-rw-r--r--db/migrate/20220803154758_add_user_id_fkey_for_user_project_callout.rb15
-rw-r--r--db/migrate/20220805154101_add_allow_run_pipelines_in_the_parent_project_setting.rb8
-rw-r--r--db/migrate/20220808133824_add_timestamps_to_project_statistics.rb7
-rw-r--r--db/migrate/20220808190124_add_id_token_to_ci_builds_metadata.rb9
-rw-r--r--db/migrate/20220808194857_remove_description_html_limit.rb15
-rw-r--r--db/migrate/20220811092243_create_ml_experiments.rb18
-rw-r--r--db/migrate/20220811092244_create_ml_candidates.rb16
-rw-r--r--db/migrate/20220811092245_create_ml_candidate_params.rb14
-rw-r--r--db/migrate/20220811092246_create_ml_candidate_metrics.rb16
-rw-r--r--db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb15
-rw-r--r--db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb15
-rw-r--r--db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb2
-rw-r--r--db/post_migrate/20210421163509_schedule_update_jira_tracker_data_deployment_type_based_on_url.rb21
-rw-r--r--db/post_migrate/20210622045705_finalize_events_bigint_conversion.rb2
-rw-r--r--db/post_migrate/20210701141346_finalize_ci_builds_stage_id_bigint_conversion.rb2
-rw-r--r--db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb10
-rw-r--r--db/post_migrate/20210708011426_finalize_ci_builds_metadata_bigint_conversion.rb2
-rw-r--r--db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb6
-rw-r--r--db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb22
-rw-r--r--db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb2
-rw-r--r--db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb10
-rw-r--r--db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb26
-rw-r--r--db/post_migrate/20210817024335_prepare_indexes_for_events_bigint_conversion.rb7
-rw-r--r--db/post_migrate/20210824174615_prepare_ci_builds_metadata_and_ci_build_async_indexes.rb8
-rw-r--r--db/post_migrate/20210825193652_backfill_cadence_id_for_boards_scoped_to_iteration.rb6
-rw-r--r--db/post_migrate/20210907211557_finalize_ci_builds_bigint_conversion.rb6
-rw-r--r--db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb45
-rw-r--r--db/post_migrate/20211007155221_schedule_populate_status_column_of_security_scans.rb15
-rw-r--r--db/post_migrate/20211208122200_schedule_backfill_ci_namespace_mirrors.rb14
-rw-r--r--db/post_migrate/20211208122201_schedule_backfill_ci_project_mirrors.rb14
-rw-r--r--db/post_migrate/20220127132200_cleanup_backfill_ci_namespace_mirrors.rb6
-rw-r--r--db/post_migrate/20220127132201_cleanup_backfill_ci_project_mirrors.rb6
-rw-r--r--db/post_migrate/20220213103859_remove_integrations_type.rb2
-rw-r--r--db/post_migrate/20220412143552_consume_remaining_encrypt_integration_property_jobs.rb2
-rw-r--r--db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb22
-rw-r--r--db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb2
-rw-r--r--db/post_migrate/20220525201022_add_temporary_index_for_vulnerability_reads_cluster_agent_id_migration.rb16
-rw-r--r--db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb29
-rw-r--r--db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb22
-rw-r--r--db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb20
-rw-r--r--db/post_migrate/20220614185644_update_index_vulnerabilities_project_id_id.rb22
-rw-r--r--db/post_migrate/20220621192541_add_project_id_state_severity_default_branch_index_for_vulnerabilities.rb16
-rw-r--r--db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb10
-rw-r--r--db/post_migrate/20220629124942_remove_vulnerability_occurrences_migrated_to_new_structure_column.rb21
-rw-r--r--db/post_migrate/20220707105529_cleanup_chat_name_service_id.rb13
-rw-r--r--db/post_migrate/20220707160921_cleanup_slack_integration_service_id.rb13
-rw-r--r--db/post_migrate/20220712131533_cleanup_issue_tracker_data_service_id.rb13
-rw-r--r--db/post_migrate/20220712144900_cleanup_jira_tracker_data_service_id.rb13
-rw-r--r--db/post_migrate/20220715152108_backfill_project_import_level.rb22
-rw-r--r--db/post_migrate/20220715185348_add_index_on_security_findings_id_and_partition_number.rb15
-rw-r--r--db/post_migrate/20220715185436_add_index_on_security_findings_unique_columns.rb15
-rw-r--r--db/post_migrate/20220715190612_drop_index_on_security_findings_uuid_and_scan_id.rb15
-rw-r--r--db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb29
-rw-r--r--db/post_migrate/20220719081542_drop_queued_at_index_from_ci_builds.rb17
-rw-r--r--db/post_migrate/20220719165537_remove_ci_runners_semver_column.rb21
-rw-r--r--db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb26
-rw-r--r--db/post_migrate/20220720121421_remove_pat_and_ssh_enforcement_columns_from_application_settings.rb8
-rw-r--r--db/post_migrate/20220720123249_remove_token_column_from_ci_builds.rb9
-rw-r--r--db/post_migrate/20220720171102_add_index_on_vulnerability_reads_namespace_id.rb18
-rw-r--r--db/post_migrate/20220720171801_add_foreign_key_on_vulnerability_reads_namespace_id.rb15
-rw-r--r--db/post_migrate/20220721031446_schedule_disable_legacy_open_source_license_for_one_member_no_repo_projects.rb33
-rw-r--r--db/post_migrate/20220721140252_prepare_partial_trigram_indexes_for_issues.rb23
-rw-r--r--db/post_migrate/20220722084543_schedule_disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb33
-rw-r--r--db/post_migrate/20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb35
-rw-r--r--db/post_migrate/20220722145845_schedule_backfilling_the_namespace_id_for_vulnerability_reads.rb23
-rw-r--r--db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb28
-rw-r--r--db/post_migrate/20220726182310_add_user_fk_to_vulnerability_state_transitions.rb20
-rw-r--r--db/post_migrate/20220728134255_update_index_vulnerabilities_common_finder.rb21
-rw-r--r--db/post_migrate/20220729033851_add_partial_legacy_open_source_license_available_index.rb18
-rw-r--r--db/post_migrate/20220729052031_add_index_on_vulnerability_reads_namespace_id_with_report_type.rb18
-rw-r--r--db/post_migrate/20220801144713_add_partial_trigram_index_for_issue_title.rb18
-rw-r--r--db/post_migrate/20220801150028_add_partial_trigram_index_for_issue_description.rb18
-rw-r--r--db/post_migrate/20220802112102_schedule_migrate_shared_vulnerability_scanners.rb34
-rw-r--r--db/post_migrate/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics.rb37
-rw-r--r--db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb18
-rw-r--r--db/post_migrate/20220802204737_remove_deactivated_user_highest_role_stats.rb27
-rw-r--r--db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb18
-rw-r--r--db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb24
-rw-r--r--db/post_migrate/20220804235614_add_comment_to_vulnerability_state_transitions.rb10
-rw-r--r--db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb13
-rw-r--r--db/post_migrate/20220808072054_prepare_index_removal_security_findings.rb13
-rw-r--r--db/post_migrate/20220808131659_remove_ci_namespace_monthly_usages_additional_amount_available_column.rb11
-rw-r--r--db/post_migrate/20220810093742_add_async_tmp_index_job_artifacts_id_and_expire_at.rb23
-rw-r--r--db/schema_migrations/202203160225051
-rw-r--r--db/schema_migrations/202205061540541
-rw-r--r--db/schema_migrations/202205241841491
-rw-r--r--db/schema_migrations/202205252010221
-rw-r--r--db/schema_migrations/202205252211331
-rw-r--r--db/schema_migrations/202206031731031
-rw-r--r--db/schema_migrations/202206070829101
-rw-r--r--db/schema_migrations/202206141856441
-rw-r--r--db/schema_migrations/202206192126181
-rw-r--r--db/schema_migrations/202206211925411
-rw-r--r--db/schema_migrations/202206291249421
-rw-r--r--db/schema_migrations/202207071053351
-rw-r--r--db/schema_migrations/202207071055291
-rw-r--r--db/schema_migrations/202207071607071
-rw-r--r--db/schema_migrations/202207071609211
-rw-r--r--db/schema_migrations/202207071819101
-rw-r--r--db/schema_migrations/202207071819201
-rw-r--r--db/schema_migrations/202207071819301
-rw-r--r--db/schema_migrations/202207071905461
-rw-r--r--db/schema_migrations/202207121315131
-rw-r--r--db/schema_migrations/202207121315331
-rw-r--r--db/schema_migrations/202207121448431
-rw-r--r--db/schema_migrations/202207121449001
-rw-r--r--db/schema_migrations/202207151521081
-rw-r--r--db/schema_migrations/202207151853481
-rw-r--r--db/schema_migrations/202207151854361
-rw-r--r--db/schema_migrations/202207151906121
-rw-r--r--db/schema_migrations/202207151916291
-rw-r--r--db/schema_migrations/202207180839451
-rw-r--r--db/schema_migrations/202207190815421
-rw-r--r--db/schema_migrations/202207191655371
-rw-r--r--db/schema_migrations/202207200903541
-rw-r--r--db/schema_migrations/202207201214211
-rw-r--r--db/schema_migrations/202207201232491
-rw-r--r--db/schema_migrations/202207201618161
-rw-r--r--db/schema_migrations/202207201621231
-rw-r--r--db/schema_migrations/202207201711021
-rw-r--r--db/schema_migrations/202207201718011
-rw-r--r--db/schema_migrations/202207202104461
-rw-r--r--db/schema_migrations/202207210314461
-rw-r--r--db/schema_migrations/202207211402521
-rw-r--r--db/schema_migrations/202207220845431
-rw-r--r--db/schema_migrations/202207221100261
-rw-r--r--db/schema_migrations/202207221233181
-rw-r--r--db/schema_migrations/202207221458451
-rw-r--r--db/schema_migrations/202207221502311
-rw-r--r--db/schema_migrations/202207222038401
-rw-r--r--db/schema_migrations/202207231200391
-rw-r--r--db/schema_migrations/202207251501271
-rw-r--r--db/schema_migrations/202207260255161
-rw-r--r--db/schema_migrations/202207261540121
-rw-r--r--db/schema_migrations/202207261540131
-rw-r--r--db/schema_migrations/202207261540141
-rw-r--r--db/schema_migrations/202207261540151
-rw-r--r--db/schema_migrations/202207261540161
-rw-r--r--db/schema_migrations/202207261823101
-rw-r--r--db/schema_migrations/202207262300521
-rw-r--r--db/schema_migrations/202207281141361
-rw-r--r--db/schema_migrations/202207281342551
-rw-r--r--db/schema_migrations/202207290338511
-rw-r--r--db/schema_migrations/202207290520311
-rw-r--r--db/schema_migrations/202207290736031
-rw-r--r--db/schema_migrations/202208011447131
-rw-r--r--db/schema_migrations/202208011500281
-rw-r--r--db/schema_migrations/202208021121021
-rw-r--r--db/schema_migrations/202208021143511
-rw-r--r--db/schema_migrations/202208021321581
-rw-r--r--db/schema_migrations/202208021547571
-rw-r--r--db/schema_migrations/202208022047371
-rw-r--r--db/schema_migrations/202208030423511
-rw-r--r--db/schema_migrations/202208030423521
-rw-r--r--db/schema_migrations/202208031456371
-rw-r--r--db/schema_migrations/202208031545431
-rw-r--r--db/schema_migrations/202208031547581
-rw-r--r--db/schema_migrations/202208042356141
-rw-r--r--db/schema_migrations/202208050012101
-rw-r--r--db/schema_migrations/202208051541011
-rw-r--r--db/schema_migrations/202208080720541
-rw-r--r--db/schema_migrations/202208081316591
-rw-r--r--db/schema_migrations/202208081338241
-rw-r--r--db/schema_migrations/202208081901241
-rw-r--r--db/schema_migrations/202208081948571
-rw-r--r--db/schema_migrations/202208100937421
-rw-r--r--db/schema_migrations/202208110922431
-rw-r--r--db/schema_migrations/202208110922441
-rw-r--r--db/schema_migrations/202208110922451
-rw-r--r--db/schema_migrations/202208110922461
-rw-r--r--db/schema_migrations/202208110922511
-rw-r--r--db/schema_migrations/202208110922531
-rw-r--r--db/structure.sql478
228 files changed, 2490 insertions, 359 deletions
diff --git a/db/docs/README.md b/db/docs/README.md
new file mode 100644
index 00000000000..ef0d6b335d4
--- /dev/null
+++ b/db/docs/README.md
@@ -0,0 +1,6 @@
+# Database Dictionary
+
+This directory contains a metadata file for each database table.
+
+See [documentation](https://docs.gitlab.com/ee/development/database/database_dictionary.html)
+for more information on the schema and purpose of these metadata files.
diff --git a/db/docs/integrations.yml b/db/docs/integrations.yml
index 4629b7558ed..5100ee77fa7 100644
--- a/db/docs/integrations.yml
+++ b/db/docs/integrations.yml
@@ -38,6 +38,7 @@ classes:
- Integrations::PipelinesEmail
- Integrations::Pivotaltracker
- Integrations::Prometheus
+- Integrations::Pumble
- Integrations::Pushover
- Integrations::Redmine
- Integrations::Shimo
diff --git a/db/docs/member_roles.yml b/db/docs/member_roles.yml
new file mode 100644
index 00000000000..314c65a1ef7
--- /dev/null
+++ b/db/docs/member_roles.yml
@@ -0,0 +1,10 @@
+---
+table_name: member_roles
+classes:
+- MemberRole
+feature_categories:
+- projects
+- subgroups
+description: Stores custom roles with composable permissions
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92152
+milestone: '15.2'
diff --git a/db/docs/ml_candidate_metrics.yml b/db/docs/ml_candidate_metrics.yml
new file mode 100644
index 00000000000..b0d9ed13489
--- /dev/null
+++ b/db/docs/ml_candidate_metrics.yml
@@ -0,0 +1,10 @@
+---
+table_name: ml_candidate_metrics
+classes:
+ - Ml::CandidateMetric
+feature_categories:
+ - mlops
+ - incubation
+description: Metrics recorded for a Machine Learning model candidate
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168
+milestone: '15.4'
diff --git a/db/docs/ml_candidate_params.yml b/db/docs/ml_candidate_params.yml
new file mode 100644
index 00000000000..01903b66108
--- /dev/null
+++ b/db/docs/ml_candidate_params.yml
@@ -0,0 +1,10 @@
+---
+table_name: ml_candidate_params
+classes:
+ - Ml::CandidateParams
+feature_categories:
+ - mlops
+ - incubation
+description: Configuration parameters recorded for a Machine Learning model candidate
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168
+milestone: '15.4'
diff --git a/db/docs/ml_candidates.yml b/db/docs/ml_candidates.yml
new file mode 100644
index 00000000000..c1f7f622350
--- /dev/null
+++ b/db/docs/ml_candidates.yml
@@ -0,0 +1,10 @@
+---
+table_name: ml_candidates
+classes:
+ - Ml::Candidate
+feature_categories:
+ - mlops
+ - incubation
+description: A Model Candidate is a record of the results on training a model on some configuration
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168
+milestone: '15.4'
diff --git a/db/docs/ml_experiments.yml b/db/docs/ml_experiments.yml
new file mode 100644
index 00000000000..ea5edc9569c
--- /dev/null
+++ b/db/docs/ml_experiments.yml
@@ -0,0 +1,10 @@
+---
+table_name: ml_experiments
+classes:
+ - Ml::Experiment
+feature_categories:
+ - mlops
+ - incubation
+description: A Machine Learning Experiments groups many Model Candidates
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168
+milestone: '15.4'
diff --git a/db/docs/namespace_details.yml b/db/docs/namespace_details.yml
new file mode 100644
index 00000000000..00053d39396
--- /dev/null
+++ b/db/docs/namespace_details.yml
@@ -0,0 +1,9 @@
+---
+table_name: namespace_details
+classes:
+- NamespaceDetail
+feature_categories:
+- subgroups
+description: Used to store details for namespaces
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82958
+milestone: '15.3'
diff --git a/db/docs/project_statistics.yml b/db/docs/project_statistics.yml
index 75d4af85ce4..323ba1d60d4 100644
--- a/db/docs/project_statistics.yml
+++ b/db/docs/project_statistics.yml
@@ -3,7 +3,7 @@ table_name: project_statistics
classes:
- ProjectStatistics
feature_categories:
-- source_code_management
-description: TODO
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/3ef4f74b1acc9399db320b53dffc592542de0126
-milestone: '9.0'
+- utilization
+description: Records statistics about the usage of various product features
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/7754
+milestone: '8.16'
diff --git a/db/docs/user_project_callouts.yml b/db/docs/user_project_callouts.yml
new file mode 100644
index 00000000000..308c3048aa7
--- /dev/null
+++ b/db/docs/user_project_callouts.yml
@@ -0,0 +1,9 @@
+---
+table_name: user_project_callouts
+classes:
+- Users::ProjectCallout
+feature_categories:
+- navigation
+description: Adds the ability to track a user callout being dismissed by project
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/94144
+milestone: '15.3'
diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb
index 47d72c4c2e7..e8fa3ee2110 100644
--- a/db/fixtures/development/14_pipelines.rb
+++ b/db/fixtures/development/14_pipelines.rb
@@ -59,6 +59,8 @@ class Gitlab::Seeder::Pipelines
pipeline.update_duration
::Ci::ProcessPipelineService.new(pipeline).execute
end
+
+ ::Gitlab::Seeder::Ci::DailyBuildGroupReportResult.new(@project).seed if @project.last_pipeline
end
private
diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb
index 88d2f784852..7dd93069122 100644
--- a/db/fixtures/development/18_abuse_reports.rb
+++ b/db/fixtures/development/18_abuse_reports.rb
@@ -11,7 +11,7 @@ module Db
name: FFaker::Name.name,
email: FFaker::Internet.email,
confirmed_at: DateTime.now,
- password: '12345678'
+ password: ::User.random_password
)
::AbuseReport.create(reporter: ::User.take, user: reported_user, message: 'User sends spam')
diff --git a/db/migrate/20210601080039_group_protected_environments_add_index_and_constraint.rb b/db/migrate/20210601080039_group_protected_environments_add_index_and_constraint.rb
index 611619e496c..1109d814ee9 100644
--- a/db/migrate/20210601080039_group_protected_environments_add_index_and_constraint.rb
+++ b/db/migrate/20210601080039_group_protected_environments_add_index_and_constraint.rb
@@ -9,7 +9,7 @@ class GroupProtectedEnvironmentsAddIndexAndConstraint < ActiveRecord::Migration[
def up
add_concurrent_index :protected_environments, [:group_id, :name], unique: true,
- name: INDEX_NAME, where: 'group_id IS NOT NULL'
+ name: INDEX_NAME, where: 'group_id IS NOT NULL'
add_concurrent_foreign_key :protected_environments, :namespaces, column: :group_id, on_delete: :cascade
add_check_constraint :protected_environments,
diff --git a/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb b/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb
index 5db39334550..14b6b9efad3 100644
--- a/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb
+++ b/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb
@@ -1,77 +1,11 @@
# frozen_string_literal: true
class AssociateExistingDastBuildsWithVariables < ActiveRecord::Migration[6.1]
- disable_ddl_transaction!
-
- class Profile < ApplicationRecord
- self.table_name = 'dast_profiles'
- self.inheritance_column = :_type_disabled
- end
-
- class ProfilesPipeline < ApplicationRecord
- include EachBatch
-
- self.table_name = 'dast_profiles_pipelines'
- self.inheritance_column = :_type_disabled
-
- belongs_to :profile, foreign_key: :dast_profile_id
- end
-
- class Build < ApplicationRecord
- self.table_name = 'ci_builds'
- self.inheritance_column = :_type_disabled
-
- default_scope { where(name: :dast, stage: :dast) } # rubocop:disable Cop/DefaultScope
- end
-
- class SiteProfilesBuild < ApplicationRecord
- self.table_name = 'dast_site_profiles_builds'
- self.inheritance_column = :_type_disabled
- end
-
- BATCH_SIZE = 300
-
def up
- process_batch do |batch|
- bulk_inserts = []
-
- grouped_builds = fetch_builds(batch).group_by(&:commit_id)
-
- batch.includes(:profile).each do |profile_pipeline|
- builds = grouped_builds[profile_pipeline.ci_pipeline_id]
-
- next if builds.blank?
-
- builds.each do |build|
- bulk_inserts.push(dast_site_profile_id: profile_pipeline.profile.dast_site_profile_id, ci_build_id: build.id)
- end
- end
-
- SiteProfilesBuild.insert_all(bulk_inserts, unique_by: :ci_build_id)
- end
+ # no-op: Must have run before %"15.X" as it is not compatible with decomposed CI database
end
def down
- process_batch do |batch|
- builds = fetch_builds(batch)
-
- SiteProfilesBuild
- .where(ci_build_id: builds)
- .delete_all
- end
- end
-
- private
-
- def fetch_builds(batch)
- # pluck necessary to support ci table decomposition
- # https://gitlab.com/groups/gitlab-org/-/epics/6289
- Build.where(commit_id: batch.pluck(:ci_pipeline_id))
- end
-
- def process_batch
- ProfilesPipeline.each_batch(of: BATCH_SIZE, column: :ci_pipeline_id) do |batch|
- yield(batch)
- end
+ # No-op
end
end
diff --git a/db/migrate/20210804150320_create_base_work_item_types.rb b/db/migrate/20210804150320_create_base_work_item_types.rb
index b7a44eaabe0..836264aae6e 100644
--- a/db/migrate/20210804150320_create_base_work_item_types.rb
+++ b/db/migrate/20210804150320_create_base_work_item_types.rb
@@ -8,9 +8,9 @@ class CreateBaseWorkItemTypes < ActiveRecord::Migration[6.1]
self.table_name = 'work_item_types'
enum base_type: {
- issue: 0,
- incident: 1,
- test_case: 2,
+ issue: 0,
+ incident: 1,
+ test_case: 2,
requirement: 3
}
diff --git a/db/migrate/20210831203408_upsert_base_work_item_types.rb b/db/migrate/20210831203408_upsert_base_work_item_types.rb
index 314412d8d3d..9a556bd6c2c 100644
--- a/db/migrate/20210831203408_upsert_base_work_item_types.rb
+++ b/db/migrate/20210831203408_upsert_base_work_item_types.rb
@@ -6,9 +6,9 @@ class UpsertBaseWorkItemTypes < ActiveRecord::Migration[6.1]
self.table_name = 'work_item_types'
enum base_type: {
- issue: 0,
- incident: 1,
- test_case: 2,
+ issue: 0,
+ incident: 1,
+ test_case: 2,
requirement: 3
}
end
diff --git a/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb b/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb
index 77b9e5297a7..e0c9d932b38 100644
--- a/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb
+++ b/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb
@@ -7,8 +7,9 @@ class AddIndexOnNameAndIdToPublicGroups < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
- add_concurrent_index :namespaces, [:name, :id], name: INDEX_NAME,
- where: "type = 'Group' AND visibility_level = #{PUBLIC_VISIBILITY_LEVEL}"
+ add_concurrent_index :namespaces, [:name, :id],
+ name: INDEX_NAME,
+ where: "type = 'Group' AND visibility_level = #{PUBLIC_VISIBILITY_LEVEL}"
end
def down
diff --git a/db/migrate/20220316022505_create_namespace_details.rb b/db/migrate/20220316022505_create_namespace_details.rb
new file mode 100644
index 00000000000..6df8606c726
--- /dev/null
+++ b/db/migrate/20220316022505_create_namespace_details.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CreateNamespaceDetails < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :namespace_details, id: false do |t|
+ t.references :namespace, primary_key: true, null: false, default: nil, type: :bigint, index: false, foreign_key: { on_delete: :cascade } # rubocop:disable Layout/LineLength
+ t.timestamps_with_timezone null: true
+ t.integer :cached_markdown_version
+ t.text :description, limit: 255
+ t.text :description_html, limit: 255
+ end
+ end
+ end
+
+ def down
+ drop_table :namespace_details
+ end
+end
diff --git a/db/migrate/20220406113217_add_inactive_project_deletion_to_application_settings.rb b/db/migrate/20220406113217_add_inactive_project_deletion_to_application_settings.rb
index 78970d308d9..ffb0fe3f5d8 100644
--- a/db/migrate/20220406113217_add_inactive_project_deletion_to_application_settings.rb
+++ b/db/migrate/20220406113217_add_inactive_project_deletion_to_application_settings.rb
@@ -5,7 +5,7 @@ class AddInactiveProjectDeletionToApplicationSettings < Gitlab::Database::Migrat
add_column :application_settings, :delete_inactive_projects, :boolean, default: false, null: false
add_column :application_settings, :inactive_projects_delete_after_months, :integer, default: 2, null: false
add_column :application_settings, :inactive_projects_min_size_mb, :integer, default: 0, null: false
- add_column :application_settings, :inactive_projects_send_warning_email_after_months, :integer, default: 1,
- null: false
+ add_column :application_settings, :inactive_projects_send_warning_email_after_months,
+ :integer, default: 1, null: false
end
end
diff --git a/db/migrate/20220506154054_create_sync_namespace_details_trigger.rb b/db/migrate/20220506154054_create_sync_namespace_details_trigger.rb
new file mode 100644
index 00000000000..1351fe91318
--- /dev/null
+++ b/db/migrate/20220506154054_create_sync_namespace_details_trigger.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+class CreateSyncNamespaceDetailsTrigger < Gitlab::Database::Migration[2.0]
+ include Gitlab::Database::SchemaHelpers
+
+ UPDATE_TRIGGER_NAME = 'trigger_update_details_on_namespace_update'
+ INSERT_TRIGGER_NAME = 'trigger_update_details_on_namespace_insert'
+ FUNCTION_NAME = 'update_namespace_details_from_namespaces'
+
+ enable_lock_retries!
+
+ def up
+ create_trigger_function(FUNCTION_NAME, replace: true) do
+ <<~SQL
+ INSERT INTO
+ namespace_details (
+ description,
+ description_html,
+ cached_markdown_version,
+ updated_at,
+ created_at,
+ namespace_id
+ )
+ VALUES
+ (
+ NEW.description,
+ NEW.description_html,
+ NEW.cached_markdown_version,
+ NEW.updated_at,
+ NEW.updated_at,
+ NEW.id
+ ) ON CONFLICT (namespace_id) DO
+ UPDATE
+ SET
+ description = NEW.description,
+ description_html = NEW.description_html,
+ cached_markdown_version = NEW.cached_markdown_version,
+ updated_at = NEW.updated_at
+ WHERE
+ namespace_details.namespace_id = NEW.id;RETURN NULL;
+ SQL
+ end
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{UPDATE_TRIGGER_NAME}
+ AFTER UPDATE ON namespaces
+ FOR EACH ROW
+ WHEN (
+ NEW.type <> 'Project' AND (
+ OLD.description IS DISTINCT FROM NEW.description OR
+ OLD.description_html IS DISTINCT FROM NEW.description_html OR
+ OLD.cached_markdown_version IS DISTINCT FROM NEW.cached_markdown_version)
+ )
+ EXECUTE PROCEDURE #{FUNCTION_NAME}();
+ SQL
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{INSERT_TRIGGER_NAME}
+ AFTER INSERT ON namespaces
+ FOR EACH ROW
+ WHEN (NEW.type <> 'Project')
+ EXECUTE PROCEDURE #{FUNCTION_NAME}();
+ SQL
+ end
+
+ def down
+ drop_trigger(:namespaces, UPDATE_TRIGGER_NAME)
+ drop_trigger(:namespaces, INSERT_TRIGGER_NAME)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/migrate/20220513093614_add_ding_talk_into_application_settings.rb b/db/migrate/20220513093614_add_ding_talk_into_application_settings.rb
index 5a34200a3c8..4af8071f564 100644
--- a/db/migrate/20220513093614_add_ding_talk_into_application_settings.rb
+++ b/db/migrate/20220513093614_add_ding_talk_into_application_settings.rb
@@ -2,8 +2,8 @@
class AddDingTalkIntoApplicationSettings < Gitlab::Database::Migration[2.0]
def change
- add_column :application_settings, :dingtalk_integration_enabled, :boolean, null: false,
- default: false, comment: 'JiHu-specific column'
+ add_column :application_settings, :dingtalk_integration_enabled, :boolean,
+ null: false, default: false, comment: 'JiHu-specific column'
add_column :application_settings, :encrypted_dingtalk_corpid, :binary, comment: 'JiHu-specific column'
add_column :application_settings, :encrypted_dingtalk_corpid_iv, :binary, comment: 'JiHu-specific column'
add_column :application_settings, :encrypted_dingtalk_app_key, :binary, comment: 'JiHu-specific column'
diff --git a/db/migrate/20220513093615_add_ding_talk_tracker_data.rb b/db/migrate/20220513093615_add_ding_talk_tracker_data.rb
index 0a9c340fbf0..0289b983a48 100644
--- a/db/migrate/20220513093615_add_ding_talk_tracker_data.rb
+++ b/db/migrate/20220513093615_add_ding_talk_tracker_data.rb
@@ -6,7 +6,7 @@ class AddDingTalkTrackerData < Gitlab::Database::Migration[2.0]
def change
create_table :dingtalk_tracker_data, comment: 'JiHu-specific table' do |t|
t.references :integration, foreign_key: { on_delete: :cascade },
- type: :bigint, index: true, null: false, comment: 'JiHu-specific column'
+ type: :bigint, index: true, null: false, comment: 'JiHu-specific column'
t.timestamps_with_timezone
t.text :corpid, comment: 'JiHu-specific column', limit: 255
t.index :corpid, where: "(corpid IS NOT NULL)", name: INDEX_NAME, comment: 'JiHu-specific index'
diff --git a/db/migrate/20220524184149_create_sync_project_namespace_details_trigger.rb b/db/migrate/20220524184149_create_sync_project_namespace_details_trigger.rb
new file mode 100644
index 00000000000..efce35b443a
--- /dev/null
+++ b/db/migrate/20220524184149_create_sync_project_namespace_details_trigger.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+class CreateSyncProjectNamespaceDetailsTrigger < Gitlab::Database::Migration[2.0]
+ include Gitlab::Database::SchemaHelpers
+
+ UPDATE_TRIGGER_NAME = 'trigger_update_details_on_project_update'
+ INSERT_TRIGGER_NAME = 'trigger_update_details_on_project_insert'
+ FUNCTION_NAME = 'update_namespace_details_from_projects'
+
+ enable_lock_retries!
+
+ def up
+ create_trigger_function(FUNCTION_NAME, replace: true) do
+ <<~SQL
+ INSERT INTO
+ namespace_details (
+ description,
+ description_html,
+ cached_markdown_version,
+ updated_at,
+ created_at,
+ namespace_id
+ )
+ VALUES
+ (
+ NEW.description,
+ NEW.description_html,
+ NEW.cached_markdown_version,
+ NEW.updated_at,
+ NEW.updated_at,
+ NEW.project_namespace_id
+ ) ON CONFLICT (namespace_id) DO
+ UPDATE
+ SET
+ description = NEW.description,
+ description_html = NEW.description_html,
+ cached_markdown_version = NEW.cached_markdown_version,
+ updated_at = NEW.updated_at
+ WHERE
+ namespace_details.namespace_id = NEW.project_namespace_id;RETURN NULL;
+ SQL
+ end
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{UPDATE_TRIGGER_NAME}
+ AFTER UPDATE ON projects
+ FOR EACH ROW
+ WHEN (
+ OLD.description IS DISTINCT FROM NEW.description OR
+ OLD.description_html IS DISTINCT FROM NEW.description_html OR
+ OLD.cached_markdown_version IS DISTINCT FROM NEW.cached_markdown_version
+ )
+ EXECUTE PROCEDURE #{FUNCTION_NAME}();
+ SQL
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{INSERT_TRIGGER_NAME}
+ AFTER INSERT ON projects
+ FOR EACH ROW
+ EXECUTE PROCEDURE #{FUNCTION_NAME}();
+ SQL
+ end
+
+ def down
+ drop_trigger(:projects, UPDATE_TRIGGER_NAME)
+ drop_trigger(:projects, INSERT_TRIGGER_NAME)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/migrate/20220619212618_add_selective_code_owner_removals_to_project_settings.rb b/db/migrate/20220619212618_add_selective_code_owner_removals_to_project_settings.rb
new file mode 100644
index 00000000000..435a1d7a40e
--- /dev/null
+++ b/db/migrate/20220619212618_add_selective_code_owner_removals_to_project_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSelectiveCodeOwnerRemovalsToProjectSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :project_settings, :selective_code_owner_removals, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20220627061008_add_fei_shu_integration.rb b/db/migrate/20220627061008_add_fei_shu_integration.rb
index 8feedc70ce6..6a3bdb0a2e9 100644
--- a/db/migrate/20220627061008_add_fei_shu_integration.rb
+++ b/db/migrate/20220627061008_add_fei_shu_integration.rb
@@ -2,8 +2,8 @@
class AddFeiShuIntegration < Gitlab::Database::Migration[2.0]
def change
- add_column :application_settings, :feishu_integration_enabled, :boolean, null: false,
- default: false, comment: 'JiHu-specific column'
+ add_column :application_settings, :feishu_integration_enabled, :boolean,
+ null: false, default: false, comment: 'JiHu-specific column'
add_column :application_settings, :encrypted_feishu_app_key, :binary, comment: 'JiHu-specific column'
add_column :application_settings, :encrypted_feishu_app_key_iv, :binary, comment: 'JiHu-specific column'
add_column :application_settings, :encrypted_feishu_app_secret, :binary, comment: 'JiHu-specific column'
diff --git a/db/migrate/20220707105335_rename_chat_name_service_id_to_integration_id.rb b/db/migrate/20220707105335_rename_chat_name_service_id_to_integration_id.rb
new file mode 100644
index 00000000000..a6625d030a4
--- /dev/null
+++ b/db/migrate/20220707105335_rename_chat_name_service_id_to_integration_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RenameChatNameServiceIdToIntegrationId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :chat_names, :service_id, :integration_id
+ end
+
+ def down
+ undo_rename_column_concurrently :chat_names, :service_id, :integration_id
+ end
+end
diff --git a/db/migrate/20220707160707_rename_slack_integration_service_id_to_integration_id.rb b/db/migrate/20220707160707_rename_slack_integration_service_id_to_integration_id.rb
new file mode 100644
index 00000000000..d553e349fc1
--- /dev/null
+++ b/db/migrate/20220707160707_rename_slack_integration_service_id_to_integration_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RenameSlackIntegrationServiceIdToIntegrationId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :slack_integrations, :service_id, :integration_id
+ end
+
+ def down
+ undo_rename_column_concurrently :slack_integrations, :service_id, :integration_id
+ end
+end
diff --git a/db/migrate/20220707181910_create_member_roles.rb b/db/migrate/20220707181910_create_member_roles.rb
new file mode 100644
index 00000000000..271ec064f08
--- /dev/null
+++ b/db/migrate/20220707181910_create_member_roles.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateMemberRoles < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :member_roles do |t|
+ t.references :namespace,
+ index: true,
+ null: false,
+ foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.integer :base_access_level, null: false
+ t.boolean :download_code, default: false
+ end
+ end
+end
diff --git a/db/migrate/20220707181920_add_member_role_id_to_members.rb b/db/migrate/20220707181920_add_member_role_id_to_members.rb
new file mode 100644
index 00000000000..f335d2da6f5
--- /dev/null
+++ b/db/migrate/20220707181920_add_member_role_id_to_members.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddMemberRoleIdToMembers < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ add_column :members, :member_role_id, :bigint
+ end
+
+ def down
+ remove_column :members, :member_role_id
+ end
+end
diff --git a/db/migrate/20220707181930_add_member_roles_relation_to_members.rb b/db/migrate/20220707181930_add_member_roles_relation_to_members.rb
new file mode 100644
index 00000000000..ede168fe51e
--- /dev/null
+++ b/db/migrate/20220707181930_add_member_roles_relation_to_members.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddMemberRolesRelationToMembers < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+ INDEX_NAME = 'index_members_on_member_role_id'
+
+ def up
+ add_concurrent_index :members, :member_role_id, name: INDEX_NAME
+ add_concurrent_foreign_key :members, :member_roles, column: :member_role_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :members, column: :member_role_id
+ end
+
+ remove_concurrent_index_by_name :members, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220707190546_add_plan_limits_max_size_cyclonedx_report_column.rb b/db/migrate/20220707190546_add_plan_limits_max_size_cyclonedx_report_column.rb
new file mode 100644
index 00000000000..5ccc6362d2b
--- /dev/null
+++ b/db/migrate/20220707190546_add_plan_limits_max_size_cyclonedx_report_column.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddPlanLimitsMaxSizeCyclonedxReportColumn < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :plan_limits, :ci_max_artifact_size_cyclonedx, :integer, null: false, default: 1
+ end
+end
diff --git a/db/migrate/20220708150315_add_vulnerabilities_foreign_key_to_vulnerability_merge_request_links.rb b/db/migrate/20220708150315_add_vulnerabilities_foreign_key_to_vulnerability_merge_request_links.rb
index f821e2fbe3a..6a1123a2c00 100644
--- a/db/migrate/20220708150315_add_vulnerabilities_foreign_key_to_vulnerability_merge_request_links.rb
+++ b/db/migrate/20220708150315_add_vulnerabilities_foreign_key_to_vulnerability_merge_request_links.rb
@@ -4,8 +4,8 @@ class AddVulnerabilitiesForeignKeyToVulnerabilityMergeRequestLinks < Gitlab::Dat
disable_ddl_transaction!
def up
- add_concurrent_foreign_key :vulnerability_merge_request_links, :vulnerabilities, column: :vulnerability_id,
- on_delete: :cascade
+ add_concurrent_foreign_key :vulnerability_merge_request_links, :vulnerabilities,
+ column: :vulnerability_id, on_delete: :cascade
end
def down
diff --git a/db/migrate/20220708150335_add_merge_requests_foreign_key_to_vulnerability_merge_request_links.rb b/db/migrate/20220708150335_add_merge_requests_foreign_key_to_vulnerability_merge_request_links.rb
index fedda9677f1..af9cef19b75 100644
--- a/db/migrate/20220708150335_add_merge_requests_foreign_key_to_vulnerability_merge_request_links.rb
+++ b/db/migrate/20220708150335_add_merge_requests_foreign_key_to_vulnerability_merge_request_links.rb
@@ -4,8 +4,8 @@ class AddMergeRequestsForeignKeyToVulnerabilityMergeRequestLinks < Gitlab::Datab
disable_ddl_transaction!
def up
- add_concurrent_foreign_key :vulnerability_merge_request_links, :merge_requests, column: :merge_request_id,
- on_delete: :cascade
+ add_concurrent_foreign_key :vulnerability_merge_request_links, :merge_requests, column:
+ :merge_request_id, on_delete: :cascade
end
def down
diff --git a/db/migrate/20220712131513_rename_issue_tracker_data_service_id_to_integration_id.rb b/db/migrate/20220712131513_rename_issue_tracker_data_service_id_to_integration_id.rb
new file mode 100644
index 00000000000..e6a59b66df9
--- /dev/null
+++ b/db/migrate/20220712131513_rename_issue_tracker_data_service_id_to_integration_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RenameIssueTrackerDataServiceIdToIntegrationId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :issue_tracker_data, :service_id, :integration_id
+ end
+
+ def down
+ undo_rename_column_concurrently :issue_tracker_data, :service_id, :integration_id
+ end
+end
diff --git a/db/migrate/20220712144843_rename_jira_tracker_data_service_id_to_integration_id.rb b/db/migrate/20220712144843_rename_jira_tracker_data_service_id_to_integration_id.rb
new file mode 100644
index 00000000000..5971c68bd93
--- /dev/null
+++ b/db/migrate/20220712144843_rename_jira_tracker_data_service_id_to_integration_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RenameJiraTrackerDataServiceIdToIntegrationId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :jira_tracker_data, :service_id, :integration_id
+ end
+
+ def down
+ undo_rename_column_concurrently :jira_tracker_data, :service_id, :integration_id
+ end
+end
diff --git a/db/migrate/20220718083945_add_unique_project_download_limit_allowlist_to_namespace_settings.rb b/db/migrate/20220718083945_add_unique_project_download_limit_allowlist_to_namespace_settings.rb
new file mode 100644
index 00000000000..49d9a652472
--- /dev/null
+++ b/db/migrate/20220718083945_add_unique_project_download_limit_allowlist_to_namespace_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddUniqueProjectDownloadLimitAllowlistToNamespaceSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :namespace_settings, :unique_project_download_limit_allowlist,
+ :text,
+ array: true,
+ default: [],
+ null: false
+ end
+end
diff --git a/db/migrate/20220720161816_add_namespace_id_to_vulnerability_reads_table.rb b/db/migrate/20220720161816_add_namespace_id_to_vulnerability_reads_table.rb
new file mode 100644
index 00000000000..b6af71eb088
--- /dev/null
+++ b/db/migrate/20220720161816_add_namespace_id_to_vulnerability_reads_table.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddNamespaceIdToVulnerabilityReadsTable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :vulnerability_reads, :namespace_id, :bigint
+ end
+end
diff --git a/db/migrate/20220720162123_update_vulnerability_reads_triggers_to_set_namespace_id.rb b/db/migrate/20220720162123_update_vulnerability_reads_triggers_to_set_namespace_id.rb
new file mode 100644
index 00000000000..25ecf45bfd5
--- /dev/null
+++ b/db/migrate/20220720162123_update_vulnerability_reads_triggers_to_set_namespace_id.rb
@@ -0,0 +1,159 @@
+# frozen_string_literal: true
+
+class UpdateVulnerabilityReadsTriggersToSetNamespaceId < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_or_update_vulnerability_reads() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ severity smallint;
+ state smallint;
+ report_type smallint;
+ resolved_on_default_branch boolean;
+ present_on_default_branch boolean;
+ namespace_id bigint;
+ BEGIN
+ IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
+ RETURN NULL;
+ END IF;
+
+ IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch, vulnerabilities.present_on_default_branch
+ INTO
+ severity, state, report_type, resolved_on_default_branch, present_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ IF present_on_default_branch IS NOT true THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ projects.namespace_id
+ INTO
+ namespace_id
+ FROM
+ projects
+ WHERE
+ projects.id = NEW.project_id;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.vulnerability_id, namespace_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint))
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$;
+ SQL
+
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_vulnerability_reads_from_vulnerability() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ scanner_id bigint;
+ uuid uuid;
+ location_image text;
+ cluster_agent_id text;
+ casted_cluster_agent_id bigint;
+ namespace_id bigint;
+ BEGIN
+ SELECT
+ v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint), projects.namespace_id
+ INTO
+ scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, namespace_id
+ FROM
+ vulnerability_occurrences v_o
+ INNER JOIN projects ON projects.id = v_o.project_id
+ WHERE
+ v_o.vulnerability_id = NEW.id
+ LIMIT 1;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.id, namespace_id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$;
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_or_update_vulnerability_reads() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ severity smallint;
+ state smallint;
+ report_type smallint;
+ resolved_on_default_branch boolean;
+ present_on_default_branch boolean;
+ BEGIN
+ IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
+ RETURN NULL;
+ END IF;
+
+ IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN
+ RETURN NULL;
+ END IF;
+
+ SELECT
+ vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch, vulnerabilities.present_on_default_branch
+ INTO
+ severity, state, report_type, resolved_on_default_branch, present_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ IF present_on_default_branch IS NOT true THEN
+ RETURN NULL;
+ END IF;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.vulnerability_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint))
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$;
+ SQL
+
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION insert_vulnerability_reads_from_vulnerability() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ scanner_id bigint;
+ uuid uuid;
+ location_image text;
+ cluster_agent_id text;
+ casted_cluster_agent_id bigint;
+ BEGIN
+ SELECT
+ v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint)
+ INTO
+ scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id
+ FROM
+ vulnerability_occurrences v_o
+ WHERE
+ v_o.vulnerability_id = NEW.id
+ LIMIT 1;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$;
+ SQL
+ end
+end
diff --git a/db/migrate/20220720210446_add_start_date_to_issues_table.rb b/db/migrate/20220720210446_add_start_date_to_issues_table.rb
new file mode 100644
index 00000000000..315d80fa654
--- /dev/null
+++ b/db/migrate/20220720210446_add_start_date_to_issues_table.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddStartDateToIssuesTable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :issues, :start_date, :date
+ end
+end
diff --git a/db/migrate/20220722123318_update_delayed_deletion_period.rb b/db/migrate/20220722123318_update_delayed_deletion_period.rb
new file mode 100644
index 00000000000..4d928a41259
--- /dev/null
+++ b/db/migrate/20220722123318_update_delayed_deletion_period.rb
@@ -0,0 +1,27 @@
+# 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 UpdateDelayedDeletionPeriod < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ # Before 15.1 the only way to disable delayed deletion was to set
+ # the period to 0, as of 15.1 zero is no longer a valid value (1-90).
+ # This migration sets the period to a valid value and disables
+ # delayed deletion using the delayed_* boolean attributes.
+
+ def up
+ execute <<~SQL
+ UPDATE application_settings SET
+ deletion_adjourned_period = 1,
+ delayed_group_deletion = 'f',
+ delayed_project_removal ='f'
+ WHERE deletion_adjourned_period = 0;
+ SQL
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb b/db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb
new file mode 100644
index 00000000000..d25923923f2
--- /dev/null
+++ b/db/migrate/20220722150231_create_function_gitlab_schema_prevent_write.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class CreateFunctionGitlabSchemaPreventWrite < Gitlab::Database::Migration[2.0]
+ TRIGGER_FUNCTION_NAME = 'gitlab_schema_prevent_write'
+
+ enable_lock_retries!
+
+ # This migration is only to make sure that the lock-write trigger function
+ # matches what we already have on staging/production for Gitlab.com
+
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION #{TRIGGER_FUNCTION_NAME}()
+ RETURNS TRIGGER AS
+ $$
+ BEGIN
+ RAISE EXCEPTION 'Table: "%" is write protected within this Gitlab database.', TG_TABLE_NAME
+ USING ERRCODE = 'modifying_sql_data_not_permitted',
+ HINT = 'Make sure you are using the right database connection';
+ END
+ $$ LANGUAGE PLPGSQL
+ SQL
+ end
+
+ def down
+ return if Gitlab.com?
+
+ execute(<<~SQL)
+ DROP FUNCTION #{TRIGGER_FUNCTION_NAME}
+ SQL
+ end
+end
diff --git a/db/migrate/20220722203840_update_lock_writes_function_disabled_via_setting.rb b/db/migrate/20220722203840_update_lock_writes_function_disabled_via_setting.rb
new file mode 100644
index 00000000000..f78d2b7f155
--- /dev/null
+++ b/db/migrate/20220722203840_update_lock_writes_function_disabled_via_setting.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class UpdateLockWritesFunctionDisabledViaSetting < Gitlab::Database::Migration[2.0]
+ TRIGGER_FUNCTION_NAME = 'gitlab_schema_prevent_write'
+
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION #{TRIGGER_FUNCTION_NAME}()
+ RETURNS TRIGGER AS
+ $$
+ BEGIN
+ IF COALESCE(NULLIF(current_setting(CONCAT('lock_writes.', TG_TABLE_NAME), true), ''), 'true') THEN
+ RAISE EXCEPTION 'Table: "%" is write protected within this Gitlab database.', TG_TABLE_NAME
+ USING ERRCODE = 'modifying_sql_data_not_permitted',
+ HINT = 'Make sure you are using the right database connection';
+ END IF;
+ RETURN NEW;
+ END
+ $$ LANGUAGE PLPGSQL;
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION #{TRIGGER_FUNCTION_NAME}()
+ RETURNS TRIGGER AS
+ $$
+ BEGIN
+ RAISE EXCEPTION 'Table: "%" is write protected within this Gitlab database.', TG_TABLE_NAME
+ USING ERRCODE = 'modifying_sql_data_not_permitted',
+ HINT = 'Make sure you are using the right database connection';
+ END
+ $$ LANGUAGE PLPGSQL
+ SQL
+ end
+end
diff --git a/db/migrate/20220723120039_add_author_id_to_vulnerability_state_transitions.rb b/db/migrate/20220723120039_add_author_id_to_vulnerability_state_transitions.rb
new file mode 100644
index 00000000000..4b16ba2bb82
--- /dev/null
+++ b/db/migrate/20220723120039_add_author_id_to_vulnerability_state_transitions.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddAuthorIdToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :vulnerability_state_transitions, :author_id, :bigint
+ end
+end
diff --git a/db/migrate/20220726025516_add_namespace_settings_unique_project_download_limit_allowlist_size_constraint.rb b/db/migrate/20220726025516_add_namespace_settings_unique_project_download_limit_allowlist_size_constraint.rb
new file mode 100644
index 00000000000..bded83f7941
--- /dev/null
+++ b/db/migrate/20220726025516_add_namespace_settings_unique_project_download_limit_allowlist_size_constraint.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddNamespaceSettingsUniqueProjectDownloadLimitAllowlistSizeConstraint < Gitlab::Database::Migration[2.0]
+ CONSTRAINT_NAME = 'namespace_settings_unique_project_download_limit_allowlist_size'
+
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint :namespace_settings,
+ 'CARDINALITY(unique_project_download_limit_allowlist) <= 100',
+ CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :namespace_settings, CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb b/db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb
new file mode 100644
index 00000000000..18c48d1202d
--- /dev/null
+++ b/db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class EnsureSbomOccurrencesIsEmpty < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ # Ensure that the sbom_occurrences table is empty to ensure that the
+ # following migration adding a not-null column succeeds.
+ # The code which creates records in this table has not been implemented yet.
+ execute('DELETE FROM sbom_occurrences')
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb b/db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..9631dadc938
--- /dev/null
+++ b/db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddComponentIdToSbomOccurrences < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ # Code using this table has not been implemented yet.
+ # The migration prior to this one ensures that it is empty.
+ # rubocop:disable Rails/NotNullColumn
+ add_column :sbom_occurrences, :component_id, :bigint, null: false
+ # rubocop:enable Rails/NotNullColumn
+ end
+
+ def down
+ remove_column :sbom_occurrences, :component_id
+ end
+end
diff --git a/db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb b/db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb
new file mode 100644
index 00000000000..ed944fd0b90
--- /dev/null
+++ b/db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToSbomOccurrencesComponentId < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = "index_sbom_occurrences_on_component_id"
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :sbom_occurrences, :component_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :sbom_occurrences, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb b/db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..1c7341c4aa2
--- /dev/null
+++ b/db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddComponentForeignKeyToSbomOccurrences < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :sbom_occurrences,
+ :sbom_components,
+ column: :component_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :sbom_occurrences, column: :component_id
+ end
+ end
+end
diff --git a/db/migrate/20220726154016_make_component_version_nullable.rb b/db/migrate/20220726154016_make_component_version_nullable.rb
new file mode 100644
index 00000000000..8619b9dad12
--- /dev/null
+++ b/db/migrate/20220726154016_make_component_version_nullable.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class MakeComponentVersionNullable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ change_column_null :sbom_occurrences, :component_version_id, true
+ end
+end
diff --git a/db/migrate/20220726230052_remove_tmp_index_project_membership_namespace_id_column.rb b/db/migrate/20220726230052_remove_tmp_index_project_membership_namespace_id_column.rb
new file mode 100644
index 00000000000..e50665c106b
--- /dev/null
+++ b/db/migrate/20220726230052_remove_tmp_index_project_membership_namespace_id_column.rb
@@ -0,0 +1,20 @@
+# 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 RemoveTmpIndexProjectMembershipNamespaceIdColumn < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'tmp_index_for_namespace_id_migration_on_project_members'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :members, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :members, :id,
+ where: "members.member_namespace_id IS NULL and members.type = 'ProjectMember'",
+ name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220728114136_make_ssh_signature_key_nullable.rb b/db/migrate/20220728114136_make_ssh_signature_key_nullable.rb
new file mode 100644
index 00000000000..5d724e9f406
--- /dev/null
+++ b/db/migrate/20220728114136_make_ssh_signature_key_nullable.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class MakeSshSignatureKeyNullable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ change_column_null :ssh_signatures, :key_id, true
+ end
+end
diff --git a/db/migrate/20220729073603_index_personal_access_tokens_on_id_and_created_at.rb b/db/migrate/20220729073603_index_personal_access_tokens_on_id_and_created_at.rb
new file mode 100644
index 00000000000..b865f76fec1
--- /dev/null
+++ b/db/migrate/20220729073603_index_personal_access_tokens_on_id_and_created_at.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class IndexPersonalAccessTokensOnIdAndCreatedAt < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_personal_access_tokens_on_id_and_created_at'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :personal_access_tokens, [:id, :created_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :personal_access_tokens, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220802154757_add_deactivate_dormant_user_time_setting.rb b/db/migrate/20220802154757_add_deactivate_dormant_user_time_setting.rb
new file mode 100644
index 00000000000..ca887cc2255
--- /dev/null
+++ b/db/migrate/20220802154757_add_deactivate_dormant_user_time_setting.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+class AddDeactivateDormantUserTimeSetting < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :deactivate_dormant_users_period, :integer, default: 90, null: false
+ end
+end
diff --git a/db/migrate/20220803145637_create_user_project_callout.rb b/db/migrate/20220803145637_create_user_project_callout.rb
new file mode 100644
index 00000000000..1d0baf741a9
--- /dev/null
+++ b/db/migrate/20220803145637_create_user_project_callout.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateUserProjectCallout < Gitlab::Database::Migration[2.0]
+ def up
+ create_table :user_project_callouts do |t|
+ t.bigint :user_id, null: false
+ t.bigint :project_id, null: false
+ t.integer :feature_name, limit: 2, null: false
+ t.datetime_with_timezone :dismissed_at
+
+ t.index :project_id
+ t.index [:user_id, :feature_name, :project_id], unique: true, name: 'index_project_user_callouts_feature'
+ end
+ end
+
+ def down
+ drop_table :user_project_callouts
+ end
+end
diff --git a/db/migrate/20220803154543_add_project_id_fkey_for_user_project_callout.rb b/db/migrate/20220803154543_add_project_id_fkey_for_user_project_callout.rb
new file mode 100644
index 00000000000..3cea53dc127
--- /dev/null
+++ b/db/migrate/20220803154543_add_project_id_fkey_for_user_project_callout.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddProjectIdFkeyForUserProjectCallout < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :user_project_callouts, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :user_project_callouts, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20220803154758_add_user_id_fkey_for_user_project_callout.rb b/db/migrate/20220803154758_add_user_id_fkey_for_user_project_callout.rb
new file mode 100644
index 00000000000..01a05f816da
--- /dev/null
+++ b/db/migrate/20220803154758_add_user_id_fkey_for_user_project_callout.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUserIdFkeyForUserProjectCallout < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :user_project_callouts, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :user_project_callouts, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20220805154101_add_allow_run_pipelines_in_the_parent_project_setting.rb b/db/migrate/20220805154101_add_allow_run_pipelines_in_the_parent_project_setting.rb
new file mode 100644
index 00000000000..dbc76e8ccfd
--- /dev/null
+++ b/db/migrate/20220805154101_add_allow_run_pipelines_in_the_parent_project_setting.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddAllowRunPipelinesInTheParentProjectSetting < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :project_ci_cd_settings, :allow_fork_pipelines_to_run_in_parent_project, :boolean,
+ default: true, null: false
+ end
+end
diff --git a/db/migrate/20220808133824_add_timestamps_to_project_statistics.rb b/db/migrate/20220808133824_add_timestamps_to_project_statistics.rb
new file mode 100644
index 00000000000..c5125ebc8ff
--- /dev/null
+++ b/db/migrate/20220808133824_add_timestamps_to_project_statistics.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddTimestampsToProjectStatistics < Gitlab::Database::Migration[2.0]
+ def change
+ add_timestamps_with_timezone(:project_statistics, null: false, default: -> { 'NOW()' })
+ end
+end
diff --git a/db/migrate/20220808190124_add_id_token_to_ci_builds_metadata.rb b/db/migrate/20220808190124_add_id_token_to_ci_builds_metadata.rb
new file mode 100644
index 00000000000..00d27d7c516
--- /dev/null
+++ b/db/migrate/20220808190124_add_id_token_to_ci_builds_metadata.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddIdTokenToCiBuildsMetadata < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :ci_builds_metadata, :id_tokens, :jsonb, null: false, default: {}
+ end
+end
diff --git a/db/migrate/20220808194857_remove_description_html_limit.rb b/db/migrate/20220808194857_remove_description_html_limit.rb
new file mode 100644
index 00000000000..f7444594566
--- /dev/null
+++ b/db/migrate/20220808194857_remove_description_html_limit.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveDescriptionHtmlLimit < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ remove_text_limit :namespace_details, :description_html
+ remove_text_limit :namespace_details, :description
+ end
+
+ def down
+ add_text_limit :namespace_details, :description_html, 255
+ add_text_limit :namespace_details, :description, 255
+ end
+end
diff --git a/db/migrate/20220811092243_create_ml_experiments.rb b/db/migrate/20220811092243_create_ml_experiments.rb
new file mode 100644
index 00000000000..a357d62133c
--- /dev/null
+++ b/db/migrate/20220811092243_create_ml_experiments.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateMlExperiments < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ create_table :ml_experiments do |t|
+ t.timestamps_with_timezone null: false
+ t.bigint :iid, null: false
+ t.bigint :project_id, null: false
+ t.references :user, foreign_key: true, index: true, on_delete: :nullify
+ t.text :name, limit: 255, null: false
+
+ t.index [:project_id, :iid], unique: true
+ t.index [:project_id, :name], unique: true
+ end
+ end
+end
diff --git a/db/migrate/20220811092244_create_ml_candidates.rb b/db/migrate/20220811092244_create_ml_candidates.rb
new file mode 100644
index 00000000000..fe9fc293b03
--- /dev/null
+++ b/db/migrate/20220811092244_create_ml_candidates.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateMlCandidates < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ create_table :ml_candidates do |t|
+ t.timestamps_with_timezone null: false
+ t.uuid :iid, null: false
+ t.bigint :experiment_id, null: false
+ t.references :user, foreign_key: true, index: true, on_delete: :nullify
+
+ t.index [:experiment_id, :iid], unique: true
+ end
+ end
+end
diff --git a/db/migrate/20220811092245_create_ml_candidate_params.rb b/db/migrate/20220811092245_create_ml_candidate_params.rb
new file mode 100644
index 00000000000..55fc1cbe7af
--- /dev/null
+++ b/db/migrate/20220811092245_create_ml_candidate_params.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateMlCandidateParams < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :ml_candidate_params do |t|
+ t.timestamps_with_timezone null: false
+ t.references :candidate,
+ foreign_key: { to_table: :ml_candidates },
+ index: true
+ t.text :name, limit: 250, null: false
+ t.text :value, limit: 250, null: false
+ end
+ end
+end
diff --git a/db/migrate/20220811092246_create_ml_candidate_metrics.rb b/db/migrate/20220811092246_create_ml_candidate_metrics.rb
new file mode 100644
index 00000000000..a4d417f270e
--- /dev/null
+++ b/db/migrate/20220811092246_create_ml_candidate_metrics.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateMlCandidateMetrics < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :ml_candidate_metrics do |t|
+ t.timestamps_with_timezone null: false
+ t.references :candidate,
+ foreign_key: { to_table: :ml_candidates },
+ index: true
+ t.float :value
+ t.integer :step
+ t.binary :is_nan
+ t.text :name, limit: 250, null: false
+ end
+ end
+end
diff --git a/db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb b/db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb
new file mode 100644
index 00000000000..a3be644552c
--- /dev/null
+++ b/db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddMlCandidatesReferenceToExperiment < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ml_candidates, :ml_experiments, column: :experiment_id
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :ml_candidates, column: :experiment_id
+ end
+ end
+end
diff --git a/db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb b/db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb
new file mode 100644
index 00000000000..4fd832dfe14
--- /dev/null
+++ b/db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddMlExperimentsReferenceToProject < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ml_experiments, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :ml_experiments, column: :project_id
+ end
+ end
+end
diff --git a/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb b/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb
index bb444f5b407..0d610f1dde1 100644
--- a/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb
+++ b/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb
@@ -11,7 +11,7 @@ class BackfillPushEventPayloadEventIdForBigintConversion < ActiveRecord::Migrati
return unless should_run?
backfill_conversion_of_integer_to_bigint :push_event_payloads, :event_id, primary_key: :event_id,
- batch_size: 15000, sub_batch_size: 100
+ batch_size: 15000, sub_batch_size: 100
end
def down
diff --git a/db/post_migrate/20210421163509_schedule_update_jira_tracker_data_deployment_type_based_on_url.rb b/db/post_migrate/20210421163509_schedule_update_jira_tracker_data_deployment_type_based_on_url.rb
index 7d4d97acf58..0f6cf970778 100644
--- a/db/post_migrate/20210421163509_schedule_update_jira_tracker_data_deployment_type_based_on_url.rb
+++ b/db/post_migrate/20210421163509_schedule_update_jira_tracker_data_deployment_type_based_on_url.rb
@@ -1,23 +1,12 @@
# frozen_string_literal: true
class ScheduleUpdateJiraTrackerDataDeploymentTypeBasedOnUrl < ActiveRecord::Migration[6.0]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
- MIGRATION = 'UpdateJiraTrackerDataDeploymentTypeBasedOnUrl'
- DELAY_INTERVAL = 2.minutes.to_i
- BATCH_SIZE = 2_500
-
- disable_ddl_transaction!
-
def up
- say "Scheduling #{MIGRATION} jobs"
- queue_background_migration_jobs_by_range_at_intervals(
- define_batchable_model('jira_tracker_data'),
- MIGRATION,
- DELAY_INTERVAL,
- batch_size: BATCH_SIZE
- )
+ # no-op (being re-run in 20220324152945_update_jira_tracker_data_deployment_type_based_on_url.rb)
+ # due to this migration causing this issue: https://gitlab.com/gitlab-org/gitlab/-/issues/336849
+ # The migration is rescheduled in
+ # db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb
+ # Related discussion: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82103#note_862401816
end
def down
diff --git a/db/post_migrate/20210622045705_finalize_events_bigint_conversion.rb b/db/post_migrate/20210622045705_finalize_events_bigint_conversion.rb
index 715bc392c68..1f0bdfc5012 100644
--- a/db/post_migrate/20210622045705_finalize_events_bigint_conversion.rb
+++ b/db/post_migrate/20210622045705_finalize_events_bigint_conversion.rb
@@ -31,7 +31,7 @@ class FinalizeEventsBigintConversion < ActiveRecord::Migration[6.1]
add_concurrent_index TABLE_NAME, [:project_id, :id_convert_to_bigint], name: 'index_events_on_project_id_and_id_convert_to_bigint'
# This is to replace the existing "index_events_on_project_id_and_id_desc_on_merged_action" btree (project_id, id DESC) WHERE action = 7
add_concurrent_index TABLE_NAME, [:project_id, :id_convert_to_bigint], order: { id_convert_to_bigint: :desc },
- where: "action = 7", name: 'index_events_on_project_id_and_id_bigint_desc_on_merged_action'
+ where: "action = 7", name: 'index_events_on_project_id_and_id_bigint_desc_on_merged_action'
# Add a FK on `push_event_payloads(event_id)` to `id_convert_to_bigint`, the old FK (fk_36c74129da)
# will be removed when events_pkey constraint is droppped.
diff --git a/db/post_migrate/20210701141346_finalize_ci_builds_stage_id_bigint_conversion.rb b/db/post_migrate/20210701141346_finalize_ci_builds_stage_id_bigint_conversion.rb
index 161366590be..776f1ad545d 100644
--- a/db/post_migrate/20210701141346_finalize_ci_builds_stage_id_bigint_conversion.rb
+++ b/db/post_migrate/20210701141346_finalize_ci_builds_stage_id_bigint_conversion.rb
@@ -30,7 +30,7 @@ class FinalizeCiBuildsStageIdBigintConversion < ActiveRecord::Migration[6.1]
# Create a copy of the original column's FK on the new column
add_concurrent_foreign_key TABLE_NAME, :ci_stages, column: :stage_id_convert_to_bigint, on_delete: :cascade,
- reverse_lock_order: true
+ reverse_lock_order: true
with_lock_retries(raise_on_exhaustion: true) do
quoted_table_name = quote_table_name(TABLE_NAME)
diff --git a/db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb b/db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb
index dbefbeb26cb..f3ce32ad9c8 100644
--- a/db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb
+++ b/db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb
@@ -37,10 +37,10 @@ class FinalizeCiStagesBigintConversion < ActiveRecord::Migration[6.1]
fk_stage_id = concurrent_foreign_key_name(:ci_builds, :stage_id)
fk_stage_id_tmp = "#{fk_stage_id}_tmp"
add_concurrent_foreign_key :ci_builds, :ci_stages, column: :stage_id,
- target_column: :id_convert_to_bigint,
- name: fk_stage_id_tmp,
- on_delete: :cascade,
- reverse_lock_order: true
+ target_column: :id_convert_to_bigint,
+ name: fk_stage_id_tmp,
+ on_delete: :cascade,
+ reverse_lock_order: true
# Now it's time to do things in a transaction
with_lock_retries(raise_on_exhaustion: true) do
@@ -58,7 +58,7 @@ class FinalizeCiStagesBigintConversion < ActiveRecord::Migration[6.1]
# Swap defaults
execute "ALTER SEQUENCE ci_stages_id_seq OWNED BY #{TABLE_NAME}.id"
- change_column_default TABLE_NAME, :id, -> { "nextval('ci_stages_id_seq'::regclass)"}
+ change_column_default TABLE_NAME, :id, -> { "nextval('ci_stages_id_seq'::regclass)" }
change_column_default TABLE_NAME, :id_convert_to_bigint, 0
# Swap pkey constraint
diff --git a/db/post_migrate/20210708011426_finalize_ci_builds_metadata_bigint_conversion.rb b/db/post_migrate/20210708011426_finalize_ci_builds_metadata_bigint_conversion.rb
index c2444ccbc6c..3879c3c368a 100644
--- a/db/post_migrate/20210708011426_finalize_ci_builds_metadata_bigint_conversion.rb
+++ b/db/post_migrate/20210708011426_finalize_ci_builds_metadata_bigint_conversion.rb
@@ -40,7 +40,7 @@ class FinalizeCiBuildsMetadataBigintConversion < Gitlab::Database::Migration[1.0
# rubocop:enable Migration/PreventIndexCreation
add_concurrent_foreign_key TABLE_NAME, :ci_builds, column: :build_id_convert_to_bigint, on_delete: :cascade,
- reverse_lock_order: true
+ reverse_lock_order: true
with_lock_retries(raise_on_exhaustion: true) do
execute "LOCK TABLE ci_builds, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
diff --git a/db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb b/db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb
index 6dab29e10d4..289b77f0a5c 100644
--- a/db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb
+++ b/db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb
@@ -29,8 +29,8 @@ class FinalizePushEventPayloadsBigintConversion3 < ActiveRecord::Migration[6.1]
def already_swapped?
push_event_payloads_columns = columns(TABLE_NAME)
- event_id = push_event_payloads_columns.find {|c| c.name == 'event_id'}
- event_id_convert_to_bigint = push_event_payloads_columns.find {|c| c.name == 'event_id_convert_to_bigint'}
+ event_id = push_event_payloads_columns.find { |c| c.name == 'event_id' }
+ event_id_convert_to_bigint = push_event_payloads_columns.find { |c| c.name == 'event_id_convert_to_bigint' }
event_id.sql_type == 'bigint' && event_id_convert_to_bigint.sql_type == 'integer'
end
@@ -40,7 +40,7 @@ class FinalizePushEventPayloadsBigintConversion3 < ActiveRecord::Migration[6.1]
# Add a foreign key on `event_id_convert_to_bigint` before we swap the columns and drop the old FK (fk_36c74129da)
add_concurrent_foreign_key TABLE_NAME, :events, column: :event_id_convert_to_bigint,
- on_delete: :cascade, reverse_lock_order: true
+ on_delete: :cascade, reverse_lock_order: true
with_lock_retries(raise_on_exhaustion: true) do
# We'll need ACCESS EXCLUSIVE lock on the related tables,
diff --git a/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb b/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb
index 8115465e311..81e73effe7b 100644
--- a/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb
+++ b/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb
@@ -5,19 +5,23 @@ class PrepareIndexesForCiJobArtifactBigintConversion < ActiveRecord::Migration[6
def up
prepare_async_index :ci_job_artifacts, :id_convert_to_bigint, unique: true,
- name: :index_ci_job_artifact_on_id_convert_to_bigint
+ name: :index_ci_job_artifact_on_id_convert_to_bigint
- prepare_async_index :ci_job_artifacts, [:project_id, :id_convert_to_bigint], where: 'file_type = 18',
- name: :index_ci_job_artifacts_for_terraform_reports_bigint
+ prepare_async_index :ci_job_artifacts,
+ [:project_id, :id_convert_to_bigint],
+ where: 'file_type = 18', name: :index_ci_job_artifacts_for_terraform_reports_bigint
- prepare_async_index :ci_job_artifacts, :id_convert_to_bigint, where: 'file_type = 18',
- name: :index_ci_job_artifacts_id_for_terraform_reports_bigint
+ prepare_async_index :ci_job_artifacts, :id_convert_to_bigint,
+ where: 'file_type = 18',
+ name: :index_ci_job_artifacts_id_for_terraform_reports_bigint
- prepare_async_index :ci_job_artifacts, [:expire_at, :job_id_convert_to_bigint],
- name: :index_ci_job_artifacts_on_expire_at_and_job_id_bigint
+ prepare_async_index :ci_job_artifacts,
+ [:expire_at, :job_id_convert_to_bigint],
+ name: :index_ci_job_artifacts_on_expire_at_and_job_id_bigint
- prepare_async_index :ci_job_artifacts, [:job_id_convert_to_bigint, :file_type], unique: true,
- name: :index_ci_job_artifacts_on_job_id_and_file_type_bigint
+ prepare_async_index :ci_job_artifacts,
+ [:job_id_convert_to_bigint, :file_type],
+ unique: true, name: :index_ci_job_artifacts_on_job_id_and_file_type_bigint
end
def down
diff --git a/db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb b/db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb
index 98f90bafce3..ab6691dea1f 100644
--- a/db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb
+++ b/db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb
@@ -5,7 +5,7 @@ class PrepareIndexesForTaggingBigintConversion < ActiveRecord::Migration[6.1]
def up
prepare_async_index :taggings, :id_convert_to_bigint, unique: true,
- name: :index_taggings_on_id_convert_to_bigint
+ name: :index_taggings_on_id_convert_to_bigint
prepare_async_index :taggings, [:taggable_id_convert_to_bigint, :taggable_type],
name: :i_taggings_on_taggable_id_convert_to_bigint_and_taggable_type
diff --git a/db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb b/db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb
index 82af595b2d3..16f3e87000c 100644
--- a/db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb
+++ b/db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb
@@ -5,14 +5,16 @@ class PrepareIndexesForCiStageBigintConversion < ActiveRecord::Migration[6.1]
def up
prepare_async_index :ci_stages, :id_convert_to_bigint, unique: true,
- name: :index_ci_stages_on_id_convert_to_bigint
+ name: :index_ci_stages_on_id_convert_to_bigint
- prepare_async_index :ci_stages, [:pipeline_id, :id_convert_to_bigint], where: 'status in (0, 1, 2, 8, 9, 10)',
- name: :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
+ prepare_async_index :ci_stages, [:pipeline_id, :id_convert_to_bigint],
+ where: 'status in (0, 1, 2, 8, 9, 10)',
+ name: :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
end
def down
- unprepare_async_index_by_name :ci_stages, :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
+ unprepare_async_index_by_name :ci_stages,
+ :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
unprepare_async_index_by_name :ci_stages, :index_ci_stages_on_id_convert_to_bigint
end
diff --git a/db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb b/db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb
index b8f843fdd50..074ba97da65 100644
--- a/db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb
+++ b/db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb
@@ -1,32 +1,8 @@
# frozen_string_literal: true
class ScheduleCopyCiBuildsColumnsToSecurityScans2 < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- INTERVAL = 2.minutes.to_i
- BATCH_SIZE = 5_000
- MIGRATION = 'CopyCiBuildsColumnsToSecurityScans'
-
- disable_ddl_transaction!
-
- class SecurityScan < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'security_scans'
- end
-
def up
- SecurityScan.reset_column_information
-
- delete_job_tracking(MIGRATION, status: %w[pending succeeded])
-
- queue_background_migration_jobs_by_range_at_intervals(
- SecurityScan,
- MIGRATION,
- INTERVAL,
- batch_size: BATCH_SIZE,
- track_jobs: true
- )
+ # no-op: Must have run before %"15.X" as it is not compatible with decomposed CI database
end
def down
diff --git a/db/post_migrate/20210817024335_prepare_indexes_for_events_bigint_conversion.rb b/db/post_migrate/20210817024335_prepare_indexes_for_events_bigint_conversion.rb
index 1d102d6216c..e1ed28f6826 100644
--- a/db/post_migrate/20210817024335_prepare_indexes_for_events_bigint_conversion.rb
+++ b/db/post_migrate/20210817024335_prepare_indexes_for_events_bigint_conversion.rb
@@ -7,13 +7,14 @@ class PrepareIndexesForEventsBigintConversion < ActiveRecord::Migration[6.1]
def up
prepare_async_index TABLE_NAME, :id_convert_to_bigint, unique: true,
- name: :index_events_on_id_convert_to_bigint
+ name: :index_events_on_id_convert_to_bigint
prepare_async_index TABLE_NAME, [:project_id, :id_convert_to_bigint],
name: :index_events_on_project_id_and_id_convert_to_bigint
- prepare_async_index TABLE_NAME, [:project_id, :id_convert_to_bigint], order: { id_convert_to_bigint: :desc },
- where: 'action = 7', name: :index_events_on_project_id_and_id_bigint_desc_on_merged_action
+ prepare_async_index TABLE_NAME, [:project_id, :id_convert_to_bigint],
+ order: { id_convert_to_bigint: :desc },
+ where: 'action = 7', name: :index_events_on_project_id_and_id_bigint_desc_on_merged_action
end
def down
diff --git a/db/post_migrate/20210824174615_prepare_ci_builds_metadata_and_ci_build_async_indexes.rb b/db/post_migrate/20210824174615_prepare_ci_builds_metadata_and_ci_build_async_indexes.rb
index f63645b4ffa..bf95aa98295 100644
--- a/db/post_migrate/20210824174615_prepare_ci_builds_metadata_and_ci_build_async_indexes.rb
+++ b/db/post_migrate/20210824174615_prepare_ci_builds_metadata_and_ci_build_async_indexes.rb
@@ -5,13 +5,13 @@ class PrepareCiBuildsMetadataAndCiBuildAsyncIndexes < ActiveRecord::Migration[6.
def up
prepare_async_index :ci_builds_metadata, :id_convert_to_bigint, unique: true,
- name: :index_ci_builds_metadata_on_id_convert_to_bigint
+ name: :index_ci_builds_metadata_on_id_convert_to_bigint
prepare_async_index :ci_builds_metadata, :build_id_convert_to_bigint, unique: true,
- name: :index_ci_builds_metadata_on_build_id_convert_to_bigint
+ name: :index_ci_builds_metadata_on_build_id_convert_to_bigint
prepare_async_index :ci_builds_metadata, :build_id_convert_to_bigint, where: 'has_exposed_artifacts IS TRUE',
- name: :index_ci_builds_metadata_on_build_id_int8_and_exposed_artifacts
+ name: :index_ci_builds_metadata_on_build_id_int8_and_exposed_artifacts
prepare_async_index_from_sql(:ci_builds_metadata, :index_ci_builds_metadata_on_build_id_int8_where_interruptible, <<~SQL.squish)
CREATE INDEX CONCURRENTLY "index_ci_builds_metadata_on_build_id_int8_where_interruptible"
@@ -20,7 +20,7 @@ class PrepareCiBuildsMetadataAndCiBuildAsyncIndexes < ActiveRecord::Migration[6.
SQL
prepare_async_index :ci_builds, :id_convert_to_bigint, unique: true,
- name: :index_ci_builds_on_converted_id
+ name: :index_ci_builds_on_converted_id
end
def down
diff --git a/db/post_migrate/20210825193652_backfill_cadence_id_for_boards_scoped_to_iteration.rb b/db/post_migrate/20210825193652_backfill_cadence_id_for_boards_scoped_to_iteration.rb
index f350fbe3d12..1f6650140d4 100644
--- a/db/post_migrate/20210825193652_backfill_cadence_id_for_boards_scoped_to_iteration.rb
+++ b/db/post_migrate/20210825193652_backfill_cadence_id_for_boards_scoped_to_iteration.rb
@@ -20,7 +20,7 @@ class BackfillCadenceIdForBoardsScopedToIteration < Gitlab::Database::Migration[
def down
MigrationBoard.where.not(iteration_cadence_id: nil).each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck(Arel.sql('MIN(id)'), Arel.sql('MAX(id)')).first
+ range = batch.pick(Arel.sql('MIN(id)'), Arel.sql('MAX(id)'))
delay = index * DELAY
migrate_in(delay, MIGRATION, ['none', 'down', *range])
@@ -31,7 +31,7 @@ class BackfillCadenceIdForBoardsScopedToIteration < Gitlab::Database::Migration[
def schedule_backfill_project_boards
MigrationBoard.where(iteration_id: -4).where.not(project_id: nil).where(iteration_cadence_id: nil).each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck(Arel.sql('MIN(id)'), Arel.sql('MAX(id)')).first
+ range = batch.pick(Arel.sql('MIN(id)'), Arel.sql('MAX(id)'))
delay = index * DELAY
migrate_in(delay, MIGRATION, ['project', 'up', *range])
@@ -40,7 +40,7 @@ class BackfillCadenceIdForBoardsScopedToIteration < Gitlab::Database::Migration[
def schedule_backfill_group_boards
MigrationBoard.where(iteration_id: -4).where.not(group_id: nil).where(iteration_cadence_id: nil).each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck(Arel.sql('MIN(id)'), Arel.sql('MAX(id)')).first
+ range = batch.pick(Arel.sql('MIN(id)'), Arel.sql('MAX(id)'))
delay = index * DELAY
migrate_in(delay, MIGRATION, ['group', 'up', *range])
diff --git a/db/post_migrate/20210907211557_finalize_ci_builds_bigint_conversion.rb b/db/post_migrate/20210907211557_finalize_ci_builds_bigint_conversion.rb
index 7544842c196..f164cdbf379 100644
--- a/db/post_migrate/20210907211557_finalize_ci_builds_bigint_conversion.rb
+++ b/db/post_migrate/20210907211557_finalize_ci_builds_bigint_conversion.rb
@@ -200,8 +200,7 @@ class FinalizeCiBuildsBigintConversion < Gitlab::Database::Migration[1.0]
column: column,
target_column: :id_convert_to_bigint,
name: temporary_name,
- on_delete: on_delete,
- reverse_lock_order: true)
+ on_delete: on_delete)
end
end
@@ -214,9 +213,6 @@ class FinalizeCiBuildsBigintConversion < Gitlab::Database::Migration[1.0]
next unless foreign_key_exists?(from_table, TABLE_NAME, column: column, primary_key: :id, name: existing_name)
with_lock_retries do
- # Explicitly lock table in order of parent, child to attempt to avoid deadlocks
- execute "LOCK TABLE #{TABLE_NAME}, #{from_table} IN ACCESS EXCLUSIVE MODE"
-
temporary_name = "#{existing_name}_tmp"
remove_foreign_key(from_table, TABLE_NAME, column: column, primary_key: :id, name: existing_name)
diff --git a/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb b/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb
index 2e6ad12f928..3a758394d7f 100644
--- a/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb
+++ b/db/post_migrate/20210908132335_disable_job_token_scope_when_unused.rb
@@ -1,52 +1,11 @@
# frozen_string_literal: true
class DisableJobTokenScopeWhenUnused < Gitlab::Database::Migration[1.0]
- disable_ddl_transaction!
-
- class ProjectCiCdSetting < ApplicationRecord
- include EachBatch
-
- self.table_name = 'project_ci_cd_settings'
- end
-
- module Ci
- module JobToken
- class ProjectScopeLink < ApplicationRecord
- self.table_name = 'ci_job_token_project_scope_links'
- end
- end
- end
-
def up
- # Disabling job token scope after db/migrate/20210902171808_set_default_job_token_scope_false.rb
- # if users haven't configured it.
- ProjectCiCdSetting.each_batch(of: 10_000) do |settings|
- with_enabled_but_unused_scope(settings).each_batch(of: 500) do |settings_to_update|
- settings_to_update.update_all(job_token_scope_enabled: false)
- end
- end
+ # no-op: Must have run before %"15.X" as it is not compatible with decomposed CI database
end
def down
- # irreversible data migration
-
- # The migration relies on the state of `job_token_scope_enabled` and
- # updates it based on whether the feature is used or not.
- #
- # The inverse migration would be to set `job_token_scope_enabled: true`
- # for those projects that have the feature disabled and unused. But there
- # could be also existing cases where the feature is disabled and unused.
- # For example, old projects.
- end
-
- private
-
- # The presence of ProjectScopeLinks means that the job token scope
- # is configured and we need to leave it enabled. Unused job token scope
- # can be disabled since they weren't configured.
- def with_enabled_but_unused_scope(settings)
- settings
- .where(job_token_scope_enabled: true)
- .where.not(project_id: Ci::JobToken::ProjectScopeLink.select(:source_project_id))
+ # no-op
end
end
diff --git a/db/post_migrate/20211007155221_schedule_populate_status_column_of_security_scans.rb b/db/post_migrate/20211007155221_schedule_populate_status_column_of_security_scans.rb
index 03032dfbb0a..04af23446fd 100644
--- a/db/post_migrate/20211007155221_schedule_populate_status_column_of_security_scans.rb
+++ b/db/post_migrate/20211007155221_schedule_populate_status_column_of_security_scans.rb
@@ -1,21 +1,8 @@
# frozen_string_literal: true
class SchedulePopulateStatusColumnOfSecurityScans < Gitlab::Database::Migration[1.0]
- MIGRATION = 'PopulateStatusColumnOfSecurityScans'
- BATCH_SIZE = 10_000
- DELAY_INTERVAL = 2.minutes
-
- disable_ddl_transaction!
-
def up
- return unless Gitlab.ee?
-
- queue_background_migration_jobs_by_range_at_intervals(
- define_batchable_model('security_scans'),
- MIGRATION,
- DELAY_INTERVAL,
- batch_size: BATCH_SIZE
- )
+ # no-op
end
def down
diff --git a/db/post_migrate/20211208122200_schedule_backfill_ci_namespace_mirrors.rb b/db/post_migrate/20211208122200_schedule_backfill_ci_namespace_mirrors.rb
index 3d39148f402..e42b74748d7 100644
--- a/db/post_migrate/20211208122200_schedule_backfill_ci_namespace_mirrors.rb
+++ b/db/post_migrate/20211208122200_schedule_backfill_ci_namespace_mirrors.rb
@@ -1,20 +1,8 @@
# frozen_string_literal: true
class ScheduleBackfillCiNamespaceMirrors < Gitlab::Database::Migration[1.0]
- MIGRATION = 'BackfillCiNamespaceMirrors'
- BATCH_SIZE = 10_000
- DELAY_INTERVAL = 2.minutes
-
- disable_ddl_transaction!
-
def up
- queue_background_migration_jobs_by_range_at_intervals(
- Gitlab::BackgroundMigration::BackfillCiNamespaceMirrors::Namespace.base_query,
- MIGRATION,
- DELAY_INTERVAL,
- batch_size: BATCH_SIZE,
- track_jobs: true
- )
+ # no-op
end
def down
diff --git a/db/post_migrate/20211208122201_schedule_backfill_ci_project_mirrors.rb b/db/post_migrate/20211208122201_schedule_backfill_ci_project_mirrors.rb
index 5678ee9f292..2a58eda040e 100644
--- a/db/post_migrate/20211208122201_schedule_backfill_ci_project_mirrors.rb
+++ b/db/post_migrate/20211208122201_schedule_backfill_ci_project_mirrors.rb
@@ -1,20 +1,8 @@
# frozen_string_literal: true
class ScheduleBackfillCiProjectMirrors < Gitlab::Database::Migration[1.0]
- MIGRATION = 'BackfillCiProjectMirrors'
- BATCH_SIZE = 10_000
- DELAY_INTERVAL = 2.minutes
-
- disable_ddl_transaction!
-
def up
- queue_background_migration_jobs_by_range_at_intervals(
- Gitlab::BackgroundMigration::BackfillCiProjectMirrors::Project.base_query,
- MIGRATION,
- DELAY_INTERVAL,
- batch_size: BATCH_SIZE,
- track_jobs: true
- )
+ # no-op
end
def down
diff --git a/db/post_migrate/20220127132200_cleanup_backfill_ci_namespace_mirrors.rb b/db/post_migrate/20220127132200_cleanup_backfill_ci_namespace_mirrors.rb
index 65ec2f9a282..a6775251d42 100644
--- a/db/post_migrate/20220127132200_cleanup_backfill_ci_namespace_mirrors.rb
+++ b/db/post_migrate/20220127132200_cleanup_backfill_ci_namespace_mirrors.rb
@@ -1,12 +1,8 @@
# frozen_string_literal: true
class CleanupBackfillCiNamespaceMirrors < Gitlab::Database::Migration[1.0]
- MIGRATION = 'BackfillCiNamespaceMirrors'
-
- disable_ddl_transaction!
-
def up
- finalize_background_migration(MIGRATION)
+ # no-op
end
def down
diff --git a/db/post_migrate/20220127132201_cleanup_backfill_ci_project_mirrors.rb b/db/post_migrate/20220127132201_cleanup_backfill_ci_project_mirrors.rb
index 8c7d9a945ba..c0cdb74c595 100644
--- a/db/post_migrate/20220127132201_cleanup_backfill_ci_project_mirrors.rb
+++ b/db/post_migrate/20220127132201_cleanup_backfill_ci_project_mirrors.rb
@@ -1,12 +1,8 @@
# frozen_string_literal: true
class CleanupBackfillCiProjectMirrors < Gitlab::Database::Migration[1.0]
- MIGRATION = 'BackfillCiProjectMirrors'
-
- disable_ddl_transaction!
-
def up
- finalize_background_migration(MIGRATION)
+ # no-op
end
def down
diff --git a/db/post_migrate/20220213103859_remove_integrations_type.rb b/db/post_migrate/20220213103859_remove_integrations_type.rb
index c3633d1e7d3..3c420760a2d 100644
--- a/db/post_migrate/20220213103859_remove_integrations_type.rb
+++ b/db/post_migrate/20220213103859_remove_integrations_type.rb
@@ -73,7 +73,7 @@ class RemoveIntegrationsType < Gitlab::Database::Migration[1.0]
add_concurrent_index :integrations, :id, where: 'type_new is null', name: tmp_index_name
define_batchable_model(:integrations).where(type_new: nil).each_batch do |batch|
- min_id, max_id = batch.pluck(Arel.sql('MIN(id), MAX(id)')).first
+ min_id, max_id = batch.pick(Arel.sql('MIN(id), MAX(id)'))
connection.execute(<<~SQL)
WITH mapping(old_type, new_type) AS (VALUES
diff --git a/db/post_migrate/20220412143552_consume_remaining_encrypt_integration_property_jobs.rb b/db/post_migrate/20220412143552_consume_remaining_encrypt_integration_property_jobs.rb
index 69850b3a32f..2213268fa73 100644
--- a/db/post_migrate/20220412143552_consume_remaining_encrypt_integration_property_jobs.rb
+++ b/db/post_migrate/20220412143552_consume_remaining_encrypt_integration_property_jobs.rb
@@ -12,7 +12,7 @@ class ConsumeRemainingEncryptIntegrationPropertyJobs < Gitlab::Database::Migrati
relation = model.where.not(properties: nil).where(encrypted_properties: nil)
relation.each_batch(of: BATCH_SIZE) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pick('MIN(id)', 'MAX(id)')
Gitlab::BackgroundMigration::EncryptIntegrationProperties.new.perform(*range)
end
diff --git a/db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb b/db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb
index 47b1c169d74..a9bb09b3378 100644
--- a/db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb
+++ b/db/post_migrate/20220520040416_schedule_set_legacy_open_source_license_available_for_non_public_projects.rb
@@ -1,31 +1,13 @@
# frozen_string_literal: true
class ScheduleSetLegacyOpenSourceLicenseAvailableForNonPublicProjects < Gitlab::Database::Migration[2.0]
- MIGRATION = 'SetLegacyOpenSourceLicenseAvailableForNonPublicProjects'
- INTERVAL = 2.minutes
- BATCH_SIZE = 5_000
- SUB_BATCH_SIZE = 200
-
- disable_ddl_transaction!
-
restrict_gitlab_migration gitlab_schema: :gitlab_main
def up
- return unless Gitlab.com?
-
- queue_batched_background_migration(
- MIGRATION,
- :projects,
- :id,
- job_interval: INTERVAL,
- batch_size: BATCH_SIZE,
- sub_batch_size: SUB_BATCH_SIZE
- )
+ # Replaced by 20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb
end
def down
- return unless Gitlab.com?
-
- delete_batched_background_migration(MIGRATION, :projects, :id, [])
+ # Replaced by 20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb
end
end
diff --git a/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb b/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb
index f11846ebe1d..45dbc028b18 100644
--- a/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb
+++ b/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb
@@ -12,7 +12,7 @@ class FinalizeBackfillNullNoteDiscussionIds < Gitlab::Database::Migration[2.0]
Gitlab::BackgroundMigration.steal(MIGRATION)
define_batchable_model('notes').where(discussion_id: nil).each_batch(of: BATCH_SIZE) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pick('MIN(id)', 'MAX(id)')
Gitlab::BackgroundMigration::BackfillNoteDiscussionId.new.perform(*range)
end
diff --git a/db/post_migrate/20220525201022_add_temporary_index_for_vulnerability_reads_cluster_agent_id_migration.rb b/db/post_migrate/20220525201022_add_temporary_index_for_vulnerability_reads_cluster_agent_id_migration.rb
new file mode 100644
index 00000000000..b795a41e9cd
--- /dev/null
+++ b/db/post_migrate/20220525201022_add_temporary_index_for_vulnerability_reads_cluster_agent_id_migration.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddTemporaryIndexForVulnerabilityReadsClusterAgentIdMigration < Gitlab::Database::Migration[2.0]
+ INDEX_VULNERABILITY_READS_NAME = 'tmp_index_cis_vulnerability_reads_on_id'
+
+ disable_ddl_transaction!
+
+ def up
+ # this index is used in 20220525221133_schedule_backfill_vulnerability_reads_cluster_agent
+ add_concurrent_index :vulnerability_reads, :id, name: INDEX_VULNERABILITY_READS_NAME, where: 'report_type = 7'
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_VULNERABILITY_READS_NAME
+ end
+end
diff --git a/db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb b/db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb
new file mode 100644
index 00000000000..bf83781e89c
--- /dev/null
+++ b/db/post_migrate/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class ScheduleBackfillVulnerabilityReadsClusterAgent < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ BATCH_SIZE = 10_000
+ SUB_BATCH_SIZE = 1_000
+ DELAY_INTERVAL = 2.minutes
+ MIGRATION_NAME = 'BackfillVulnerabilityReadsClusterAgent'
+ BATCH_CLASS_NAME = 'BackfillVulnerabilityReadsClusterAgentBatchingStrategy'
+
+ disable_ddl_transaction!
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION_NAME,
+ :vulnerability_reads,
+ :id,
+ job_interval: DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ batch_class_name: BATCH_CLASS_NAME,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION_NAME, :vulnerability_reads, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb b/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb
new file mode 100644
index 00000000000..8f10fd61273
--- /dev/null
+++ b/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class UpdateVulnerabilitiesProjectIdIdIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'idx_vulnerabilities_partial_devops_adoption_and_default_branch'
+ OLD_INDEX_NAME = 'idx_vulnerabilities_partial_devops_adoption'
+
+ def up
+ add_concurrent_index :vulnerabilities, [:project_id, :created_at, :present_on_default_branch],
+ where: 'state != 1',
+ name: NEW_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :vulnerabilities, [:project_id, :created_at], where: 'state != 1', name: OLD_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb b/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..fe4ffbf6cc3
--- /dev/null
+++ b/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddSyncTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = "tmp_index_vulnerability_occurrences_on_id_and_scanner_id"
+ REPORT_TYPES = { cluster_image_scanning: 7, generic: 99 }.freeze
+ CLAUSE = "report_type IN (#{REPORT_TYPES.values.join(',')})"
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerability_occurrences,
+ [:id, :scanner_id],
+ where: CLAUSE,
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220614185644_update_index_vulnerabilities_project_id_id.rb b/db/post_migrate/20220614185644_update_index_vulnerabilities_project_id_id.rb
new file mode 100644
index 00000000000..142cac09a01
--- /dev/null
+++ b/db/post_migrate/20220614185644_update_index_vulnerabilities_project_id_id.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class UpdateIndexVulnerabilitiesProjectIdId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'index_vulnerabilities_project_id_and_id_on_default_branch'
+ OLD_INDEX_NAME = 'index_vulnerabilities_on_project_id_and_id'
+
+ def up
+ add_concurrent_index :vulnerabilities, [:project_id, :id],
+ where: 'present_on_default_branch IS TRUE',
+ name: NEW_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :vulnerabilities, [:project_id, :id], name: OLD_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20220621192541_add_project_id_state_severity_default_branch_index_for_vulnerabilities.rb b/db/post_migrate/20220621192541_add_project_id_state_severity_default_branch_index_for_vulnerabilities.rb
new file mode 100644
index 00000000000..76753cdd737
--- /dev/null
+++ b/db/post_migrate/20220621192541_add_project_id_state_severity_default_branch_index_for_vulnerabilities.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddProjectIdStateSeverityDefaultBranchIndexForVulnerabilities < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_vulnerabilities_project_id_state_severity_default_branch'
+
+ def up
+ add_concurrent_index :vulnerabilities, [:project_id, :state, :severity, :present_on_default_branch],
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb b/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb
index 64cdd75f5a7..1533c502b3d 100644
--- a/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb
+++ b/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb
@@ -9,10 +9,12 @@ class AddTempIndexForContainerRegistrySizeMigration < Gitlab::Database::Migratio
def up
# Temporary index used in 20220622080547_backfill_project_statistics_with_container_registry_size
# Temporary index to be remove via https://gitlab.com/gitlab-org/gitlab/-/issues/366392
- add_concurrent_index :container_repositories, [:project_id], name: INDEX_CONTAINER_REGISTRY_SIZE,
- where: "migration_state = 'import_done' OR created_at >= '2022-01-23'"
- add_concurrent_index :project_statistics, [:project_id], name: INDEX_PROJECT_STATS_CONT_REG_SIZE,
- where: "container_registry_size = 0"
+ add_concurrent_index :container_repositories, [:project_id],
+ name: INDEX_CONTAINER_REGISTRY_SIZE,
+ where: "migration_state = 'import_done' OR created_at >= '2022-01-23'"
+ add_concurrent_index :project_statistics, [:project_id],
+ name: INDEX_PROJECT_STATS_CONT_REG_SIZE,
+ where: "container_registry_size = 0"
end
def down
diff --git a/db/post_migrate/20220629124942_remove_vulnerability_occurrences_migrated_to_new_structure_column.rb b/db/post_migrate/20220629124942_remove_vulnerability_occurrences_migrated_to_new_structure_column.rb
new file mode 100644
index 00000000000..2a980290cc9
--- /dev/null
+++ b/db/post_migrate/20220629124942_remove_vulnerability_occurrences_migrated_to_new_structure_column.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveVulnerabilityOccurrencesMigratedToNewStructureColumn < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_vulnerability_occurrences_on_migrated_to_new_structure'
+
+ def up
+ with_lock_retries do
+ remove_column :vulnerability_occurrences, :migrated_to_new_structure
+ end
+ end
+
+ def down
+ unless column_exists?(:vulnerability_occurrences, :migrated_to_new_structure)
+ add_column :vulnerability_occurrences, :migrated_to_new_structure, :boolean, default: false, null: false
+ end
+
+ add_concurrent_index :vulnerability_occurrences, [:migrated_to_new_structure, :id], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220707105529_cleanup_chat_name_service_id.rb b/db/post_migrate/20220707105529_cleanup_chat_name_service_id.rb
new file mode 100644
index 00000000000..aa3af4acf31
--- /dev/null
+++ b/db/post_migrate/20220707105529_cleanup_chat_name_service_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CleanupChatNameServiceId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :chat_names, :service_id, :integration_id
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :chat_names, :service_id, :integration_id
+ end
+end
diff --git a/db/post_migrate/20220707160921_cleanup_slack_integration_service_id.rb b/db/post_migrate/20220707160921_cleanup_slack_integration_service_id.rb
new file mode 100644
index 00000000000..25b4252e48b
--- /dev/null
+++ b/db/post_migrate/20220707160921_cleanup_slack_integration_service_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CleanupSlackIntegrationServiceId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :slack_integrations, :service_id, :integration_id
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :slack_integrations, :service_id, :integration_id
+ end
+end
diff --git a/db/post_migrate/20220712131533_cleanup_issue_tracker_data_service_id.rb b/db/post_migrate/20220712131533_cleanup_issue_tracker_data_service_id.rb
new file mode 100644
index 00000000000..be304c5fe6d
--- /dev/null
+++ b/db/post_migrate/20220712131533_cleanup_issue_tracker_data_service_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CleanupIssueTrackerDataServiceId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :issue_tracker_data, :service_id, :integration_id
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :issue_tracker_data, :service_id, :integration_id
+ end
+end
diff --git a/db/post_migrate/20220712144900_cleanup_jira_tracker_data_service_id.rb b/db/post_migrate/20220712144900_cleanup_jira_tracker_data_service_id.rb
new file mode 100644
index 00000000000..90b35f03054
--- /dev/null
+++ b/db/post_migrate/20220712144900_cleanup_jira_tracker_data_service_id.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CleanupJiraTrackerDataServiceId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :jira_tracker_data, :service_id, :integration_id
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :jira_tracker_data, :service_id, :integration_id
+ end
+end
diff --git a/db/post_migrate/20220715152108_backfill_project_import_level.rb b/db/post_migrate/20220715152108_backfill_project_import_level.rb
new file mode 100644
index 00000000000..65a0dc0a58a
--- /dev/null
+++ b/db/post_migrate/20220715152108_backfill_project_import_level.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class BackfillProjectImportLevel < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ MIGRATION = 'BackfillProjectImportLevel'
+ INTERVAL = 120.seconds
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :namespaces,
+ :id,
+ job_interval: INTERVAL
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :namespaces, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220715185348_add_index_on_security_findings_id_and_partition_number.rb b/db/post_migrate/20220715185348_add_index_on_security_findings_id_and_partition_number.rb
new file mode 100644
index 00000000000..e867ef81381
--- /dev/null
+++ b/db/post_migrate/20220715185348_add_index_on_security_findings_id_and_partition_number.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnSecurityFindingsIdAndPartitionNumber < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'security_findings_partitioned_pkey'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :security_findings, [:id, :partition_number], unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :security_findings, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220715185436_add_index_on_security_findings_unique_columns.rb b/db/post_migrate/20220715185436_add_index_on_security_findings_unique_columns.rb
new file mode 100644
index 00000000000..33b069a27d4
--- /dev/null
+++ b/db/post_migrate/20220715185436_add_index_on_security_findings_unique_columns.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnSecurityFindingsUniqueColumns < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_security_findings_on_unique_columns'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :security_findings, [:uuid, :scan_id, :partition_number], unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :security_findings, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220715190612_drop_index_on_security_findings_uuid_and_scan_id.rb b/db/post_migrate/20220715190612_drop_index_on_security_findings_uuid_and_scan_id.rb
new file mode 100644
index 00000000000..a8a9bab2c84
--- /dev/null
+++ b/db/post_migrate/20220715190612_drop_index_on_security_findings_uuid_and_scan_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DropIndexOnSecurityFindingsUuidAndScanId < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_security_findings_on_uuid_and_scan_id'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :security_findings, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :security_findings, [:uuid, :scan_id], unique: true, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb b/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb
new file mode 100644
index 00000000000..c2859c68c52
--- /dev/null
+++ b/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class ChangePrimaryKeyOfSecurityFindingsTable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ ALTER TABLE security_findings DROP CONSTRAINT security_findings_pkey;
+ SQL
+
+ execute(<<~SQL)
+ ALTER TABLE security_findings ADD CONSTRAINT security_findings_pkey PRIMARY KEY USING index security_findings_partitioned_pkey;
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ ALTER TABLE security_findings DROP CONSTRAINT security_findings_pkey;
+ SQL
+
+ execute(<<~SQL)
+ ALTER TABLE security_findings ADD CONSTRAINT security_findings_pkey PRIMARY KEY (id);
+ SQL
+
+ execute(<<~SQL)
+ CREATE UNIQUE INDEX security_findings_partitioned_pkey ON security_findings USING btree(id, partition_number);
+ SQL
+ end
+end
diff --git a/db/post_migrate/20220719081542_drop_queued_at_index_from_ci_builds.rb b/db/post_migrate/20220719081542_drop_queued_at_index_from_ci_builds.rb
new file mode 100644
index 00000000000..4a16d022c70
--- /dev/null
+++ b/db/post_migrate/20220719081542_drop_queued_at_index_from_ci_builds.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropQueuedAtIndexFromCiBuilds < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_builds_on_queued_at'
+
+ def up
+ remove_concurrent_index_by_name :ci_builds, INDEX_NAME
+ end
+
+ # rubocop:disable Migration/PreventIndexCreation
+ def down
+ add_concurrent_index :ci_builds, :queued_at, name: INDEX_NAME
+ end
+ # rubocop:enable Migration/PreventIndexCreation
+end
diff --git a/db/post_migrate/20220719165537_remove_ci_runners_semver_column.rb b/db/post_migrate/20220719165537_remove_ci_runners_semver_column.rb
new file mode 100644
index 00000000000..a6929153d10
--- /dev/null
+++ b/db/post_migrate/20220719165537_remove_ci_runners_semver_column.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveCiRunnersSemverColumn < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_runners_on_id_and_semver_cidr'
+
+ def up
+ with_lock_retries do
+ remove_column :ci_runners, :semver
+ end
+ end
+
+ def down
+ with_lock_retries do
+ add_column :ci_runners, :semver, :text, null: true
+ end
+ add_text_limit :ci_runners, :semver, 16
+ add_concurrent_index :ci_runners, 'id, (semver::cidr)', name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb b/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb
new file mode 100644
index 00000000000..fb3d12840cc
--- /dev/null
+++ b/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class RemovePendingBuildsCoveringIndexFromCiBuilds < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_builds_runner_id_pending_covering'
+
+ def up
+ remove_concurrent_index_by_name :ci_builds, INDEX_NAME
+ end
+
+ # rubocop:disable Migration/PreventIndexCreation
+ def down
+ disable_statement_timeout do
+ unless index_exists_by_name?(:ci_builds, INDEX_NAME)
+ execute <<~SQL.squish
+ CREATE INDEX CONCURRENTLY #{INDEX_NAME}
+ ON ci_builds (runner_id, id)
+ INCLUDE (project_id)
+ WHERE status = 'pending' AND type = 'Ci::Build'
+ SQL
+ end
+ end
+ end
+ # rubocop:enable Migration/PreventIndexCreation
+end
diff --git a/db/post_migrate/20220720121421_remove_pat_and_ssh_enforcement_columns_from_application_settings.rb b/db/post_migrate/20220720121421_remove_pat_and_ssh_enforcement_columns_from_application_settings.rb
new file mode 100644
index 00000000000..b03cad08f35
--- /dev/null
+++ b/db/post_migrate/20220720121421_remove_pat_and_ssh_enforcement_columns_from_application_settings.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class RemovePatAndSshEnforcementColumnsFromApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ remove_column :application_settings, :enforce_pat_expiration, :boolean, default: true, null: false
+ remove_column :application_settings, :enforce_ssh_key_expiration, :boolean, default: true, null: false
+ end
+end
diff --git a/db/post_migrate/20220720123249_remove_token_column_from_ci_builds.rb b/db/post_migrate/20220720123249_remove_token_column_from_ci_builds.rb
new file mode 100644
index 00000000000..1bc13b6ea05
--- /dev/null
+++ b/db/post_migrate/20220720123249_remove_token_column_from_ci_builds.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class RemoveTokenColumnFromCiBuilds < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ remove_column :ci_builds, :token, :string
+ end
+end
diff --git a/db/post_migrate/20220720171102_add_index_on_vulnerability_reads_namespace_id.rb b/db/post_migrate/20220720171102_add_index_on_vulnerability_reads_namespace_id.rb
new file mode 100644
index 00000000000..e90fcfd3016
--- /dev/null
+++ b/db/post_migrate/20220720171102_add_index_on_vulnerability_reads_namespace_id.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnVulnerabilityReadsNamespaceId < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_vuln_reads_on_namespace_id_state_severity_and_vuln_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerability_reads,
+ [:namespace_id, :state, :severity, :vulnerability_id],
+ name: INDEX_NAME,
+ order: { vulnerability_id: :desc }
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220720171801_add_foreign_key_on_vulnerability_reads_namespace_id.rb b/db/post_migrate/20220720171801_add_foreign_key_on_vulnerability_reads_namespace_id.rb
new file mode 100644
index 00000000000..c1b6a9d6909
--- /dev/null
+++ b/db/post_migrate/20220720171801_add_foreign_key_on_vulnerability_reads_namespace_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyOnVulnerabilityReadsNamespaceId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerability_reads, :namespaces, column: :namespace_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :vulnerability_reads, column: :namespace_id
+ end
+ end
+end
diff --git a/db/post_migrate/20220721031446_schedule_disable_legacy_open_source_license_for_one_member_no_repo_projects.rb b/db/post_migrate/20220721031446_schedule_disable_legacy_open_source_license_for_one_member_no_repo_projects.rb
new file mode 100644
index 00000000000..7665d49b1d9
--- /dev/null
+++ b/db/post_migrate/20220721031446_schedule_disable_legacy_open_source_license_for_one_member_no_repo_projects.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class ScheduleDisableLegacyOpenSourceLicenseForOneMemberNoRepoProjects < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'DisableLegacyOpenSourceLicenseForOneMemberNoRepoProjects'
+ INTERVAL = 2.minutes
+ BATCH_SIZE = 5_000
+ MAX_BATCH_SIZE = 10_000
+ SUB_BATCH_SIZE = 500
+
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ return unless Gitlab.com?
+
+ queue_batched_background_migration(
+ MIGRATION,
+ :projects,
+ :id,
+ job_interval: INTERVAL,
+ batch_size: BATCH_SIZE,
+ max_batch_size: MAX_BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ delete_batched_background_migration(MIGRATION, :projects, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220721140252_prepare_partial_trigram_indexes_for_issues.rb b/db/post_migrate/20220721140252_prepare_partial_trigram_indexes_for_issues.rb
new file mode 100644
index 00000000000..00a51f3024e
--- /dev/null
+++ b/db/post_migrate/20220721140252_prepare_partial_trigram_indexes_for_issues.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class PreparePartialTrigramIndexesForIssues < Gitlab::Database::Migration[2.0]
+ TITLE_INDEX_NAME = 'index_issues_on_title_trigram_non_latin'
+ DESCRIPTION_INDEX_NAME = 'index_issues_on_description_trigram_non_latin'
+
+ def up
+ prepare_async_index :issues, :title,
+ name: TITLE_INDEX_NAME,
+ using: :gin, opclass: { description: :gin_trgm_ops },
+ where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'"
+
+ prepare_async_index :issues, :description,
+ name: DESCRIPTION_INDEX_NAME,
+ using: :gin, opclass: { description: :gin_trgm_ops },
+ where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'"
+ end
+
+ def down
+ unprepare_async_index_by_name :issues, DESCRIPTION_INDEX_NAME
+ unprepare_async_index_by_name :issues, TITLE_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220722084543_schedule_disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb b/db/post_migrate/20220722084543_schedule_disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb
new file mode 100644
index 00000000000..7fbf09846cf
--- /dev/null
+++ b/db/post_migrate/20220722084543_schedule_disable_legacy_open_source_license_for_no_issues_no_repo_projects.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class ScheduleDisableLegacyOpenSourceLicenseForNoIssuesNoRepoProjects < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'DisableLegacyOpenSourceLicenseForNoIssuesNoRepoProjects'
+ INTERVAL = 2.minutes
+ BATCH_SIZE = 5_000
+ MAX_BATCH_SIZE = 10_000
+ SUB_BATCH_SIZE = 200
+
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ return unless Gitlab.com?
+
+ queue_batched_background_migration(
+ MIGRATION,
+ :projects,
+ :id,
+ job_interval: INTERVAL,
+ batch_size: BATCH_SIZE,
+ max_batch_size: MAX_BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ delete_batched_background_migration(MIGRATION, :projects, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb b/db/post_migrate/20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb
new file mode 100644
index 00000000000..546923141e2
--- /dev/null
+++ b/db/post_migrate/20220722110026_reschedule_set_legacy_open_source_license_available_for_non_public_projects.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class RescheduleSetLegacyOpenSourceLicenseAvailableForNonPublicProjects < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'SetLegacyOpenSourceLicenseAvailableForNonPublicProjects'
+ INTERVAL = 2.minutes
+ BATCH_SIZE = 5_000
+ MAX_BATCH_SIZE = 10_000
+ SUB_BATCH_SIZE = 200
+
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ return unless Gitlab.com?
+
+ delete_batched_background_migration(MIGRATION, :projects, :id, [])
+
+ queue_batched_background_migration(
+ MIGRATION,
+ :projects,
+ :id,
+ job_interval: INTERVAL,
+ batch_size: BATCH_SIZE,
+ max_batch_size: MAX_BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ delete_batched_background_migration(MIGRATION, :projects, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220722145845_schedule_backfilling_the_namespace_id_for_vulnerability_reads.rb b/db/post_migrate/20220722145845_schedule_backfilling_the_namespace_id_for_vulnerability_reads.rb
new file mode 100644
index 00000000000..e2d1846f8f6
--- /dev/null
+++ b/db/post_migrate/20220722145845_schedule_backfilling_the_namespace_id_for_vulnerability_reads.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class ScheduleBackfillingTheNamespaceIdForVulnerabilityReads < Gitlab::Database::Migration[2.0]
+ MIGRATION_NAME = 'BackfillNamespaceIdOfVulnerabilityReads'
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION_NAME,
+ :vulnerability_reads,
+ :vulnerability_id,
+ job_interval: 2.minutes,
+ batch_size: 10_000,
+ sub_batch_size: 200
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION_NAME, :vulnerability_reads, :vulnerability_id, [])
+ end
+end
diff --git a/db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb b/db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb
new file mode 100644
index 00000000000..0deba9b3e81
--- /dev/null
+++ b/db/post_migrate/20220725150127_update_jira_tracker_data_deployment_type_based_on_url.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class UpdateJiraTrackerDataDeploymentTypeBasedOnUrl < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'UpdateJiraTrackerDataDeploymentTypeBasedOnUrl'
+ DELAY_INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 2_500
+ SUB_BATCH_SIZE = 2_500
+
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ say "Scheduling #{MIGRATION} jobs"
+ delete_queued_jobs(MIGRATION)
+ queue_batched_background_migration(
+ MIGRATION,
+ :jira_tracker_data,
+ :id,
+ job_interval: DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20220726182310_add_user_fk_to_vulnerability_state_transitions.rb b/db/post_migrate/20220726182310_add_user_fk_to_vulnerability_state_transitions.rb
new file mode 100644
index 00000000000..ad0bf6141b2
--- /dev/null
+++ b/db/post_migrate/20220726182310_add_user_fk_to_vulnerability_state_transitions.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddUserFkToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_vulnerability_state_transitions_on_author_id'
+
+ def up
+ add_concurrent_index :vulnerability_state_transitions, :author_id, name: INDEX_NAME
+ add_concurrent_foreign_key :vulnerability_state_transitions, :users, column: :author_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :vulnerability_state_transitions, column: :author_id
+ end
+
+ remove_concurrent_index_by_name :vulnerability_state_transitions, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220728134255_update_index_vulnerabilities_common_finder.rb b/db/post_migrate/20220728134255_update_index_vulnerabilities_common_finder.rb
new file mode 100644
index 00000000000..617d7661b5b
--- /dev/null
+++ b/db/post_migrate/20220728134255_update_index_vulnerabilities_common_finder.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class UpdateIndexVulnerabilitiesCommonFinder < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'index_vulnerabilities_common_finder_query_on_default_branch'
+ OLD_INDEX_NAME = 'index_vulnerabilites_common_finder_query'
+
+ def up
+ add_concurrent_index :vulnerabilities, [:project_id, :state, :report_type, :present_on_default_branch,
+ :severity, :id], name: NEW_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :vulnerabilities, [:project_id, :state, :report_type, :severity, :id], name: OLD_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20220729033851_add_partial_legacy_open_source_license_available_index.rb b/db/post_migrate/20220729033851_add_partial_legacy_open_source_license_available_index.rb
new file mode 100644
index 00000000000..c99c452c149
--- /dev/null
+++ b/db/post_migrate/20220729033851_add_partial_legacy_open_source_license_available_index.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddPartialLegacyOpenSourceLicenseAvailableIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_project_settings_on_legacy_open_source_license_available'
+
+ def up
+ add_concurrent_index :project_settings,
+ %i[legacy_open_source_license_available],
+ where: "legacy_open_source_license_available = TRUE",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name(:project_settings, INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20220729052031_add_index_on_vulnerability_reads_namespace_id_with_report_type.rb b/db/post_migrate/20220729052031_add_index_on_vulnerability_reads_namespace_id_with_report_type.rb
new file mode 100644
index 00000000000..53b2c1728e1
--- /dev/null
+++ b/db/post_migrate/20220729052031_add_index_on_vulnerability_reads_namespace_id_with_report_type.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnVulnerabilityReadsNamespaceIdWithReportType < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_vulnerability_reads_common_finder_query_with_namespace_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerability_reads,
+ [:namespace_id, :state, :report_type, :severity, :vulnerability_id],
+ name: INDEX_NAME,
+ order: { vulnerability_id: :desc }
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220801144713_add_partial_trigram_index_for_issue_title.rb b/db/post_migrate/20220801144713_add_partial_trigram_index_for_issue_title.rb
new file mode 100644
index 00000000000..c4db8232eba
--- /dev/null
+++ b/db/post_migrate/20220801144713_add_partial_trigram_index_for_issue_title.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddPartialTrigramIndexForIssueTitle < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_issues_on_title_trigram_non_latin'
+
+ def up
+ add_concurrent_index :issues, :title,
+ name: INDEX_NAME,
+ using: :gin, opclass: { description: :gin_trgm_ops },
+ where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'"
+ end
+
+ def down
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220801150028_add_partial_trigram_index_for_issue_description.rb b/db/post_migrate/20220801150028_add_partial_trigram_index_for_issue_description.rb
new file mode 100644
index 00000000000..79f25718e15
--- /dev/null
+++ b/db/post_migrate/20220801150028_add_partial_trigram_index_for_issue_description.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddPartialTrigramIndexForIssueDescription < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_issues_on_description_trigram_non_latin'
+
+ def up
+ add_concurrent_index :issues, :description,
+ name: INDEX_NAME,
+ using: :gin, opclass: { description: :gin_trgm_ops },
+ where: "title NOT SIMILAR TO '[\\u0000-\\u218F]*' OR description NOT SIMILAR TO '[\\u0000-\\u218F]*'"
+ end
+
+ def down
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220802112102_schedule_migrate_shared_vulnerability_scanners.rb b/db/post_migrate/20220802112102_schedule_migrate_shared_vulnerability_scanners.rb
new file mode 100644
index 00000000000..92ca0998bae
--- /dev/null
+++ b/db/post_migrate/20220802112102_schedule_migrate_shared_vulnerability_scanners.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class ScheduleMigrateSharedVulnerabilityScanners < Gitlab::Database::Migration[2.0]
+ MIGRATION = "MigrateSharedVulnerabilityScanners"
+ TABLE_NAME = :vulnerability_occurrences
+ BATCH_COLUMN = :id
+ DELAY_INTERVAL = 5.minutes
+ BATCH_SIZE = 1000
+ SUB_BATCH_SIZE = 100
+
+ BATCH_MIN_VALUE = 23658505
+ BATCH_MAX_VALUE = 204428752
+
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ TABLE_NAME,
+ BATCH_COLUMN,
+ job_interval: DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ max_batch_size: BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE,
+ batch_min_value: BATCH_MIN_VALUE,
+ batch_max_value: BATCH_MAX_VALUE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, TABLE_NAME, BATCH_COLUMN, [])
+ end
+end
diff --git a/db/post_migrate/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics.rb b/db/post_migrate/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics.rb
new file mode 100644
index 00000000000..46b98d319fd
--- /dev/null
+++ b/db/post_migrate/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class RescheduleBackfillContainerRegistrySizeIntoProjectStatistics < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ DELAY_INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 500
+ MIGRATION_CLASS = 'BackfillProjectStatisticsContainerRepositorySize'
+ BATCH_CLASS_NAME = 'BackfillProjectStatisticsWithContainerRegistrySizeBatchingStrategy'
+ SUB_BATCH_SIZE = 100
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.dev_or_test_env? || Gitlab.com?
+
+ # remove the original migration
+ delete_batched_background_migration(MIGRATION_CLASS, :container_repositories, :project_id, [])
+
+ # reschedule the migration
+ queue_batched_background_migration(
+ MIGRATION_CLASS,
+ :container_repositories,
+ :project_id,
+ job_interval: DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ batch_class_name: BATCH_CLASS_NAME,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ return unless Gitlab.dev_or_test_env? || Gitlab.com?
+
+ delete_batched_background_migration(MIGRATION_CLASS, :container_repositories, :project_id, [])
+ end
+end
diff --git a/db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb b/db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb
new file mode 100644
index 00000000000..81e95f531c1
--- /dev/null
+++ b/db/post_migrate/20220802132158_index_on_integration_type_new_id_when_active_and_has_group.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class IndexOnIntegrationTypeNewIdWhenActiveAndHasGroup < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_integrations_on_type_new_id_when_active_and_has_group'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :integrations,
+ [:type_new, :id, :inherit_from_id],
+ name: INDEX_NAME,
+ where: '((active = true) AND (group_id IS NOT NULL))'
+ end
+
+ def down
+ remove_concurrent_index_by_name :integrations, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220802204737_remove_deactivated_user_highest_role_stats.rb b/db/post_migrate/20220802204737_remove_deactivated_user_highest_role_stats.rb
new file mode 100644
index 00000000000..e23fbfdf7f2
--- /dev/null
+++ b/db/post_migrate/20220802204737_remove_deactivated_user_highest_role_stats.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class RemoveDeactivatedUserHighestRoleStats < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ # This migration is applicable to self-managed instances that may utilize the
+ # dormant user deactivation feature. This feature is not enabled on Gitlab.com.
+ return if Gitlab.com?
+
+ users_table = define_batchable_model('users')
+ user_highest_roles_table = define_batchable_model('user_highest_roles')
+
+ users_table.where(state: 'deactivated').each_batch do |users_batch|
+ user_ids = users_batch.pluck(:id)
+ user_highest_roles_table.where(user_id: user_ids).delete_all
+ end
+ end
+
+ def down
+ # no-op
+
+ # This migration removes entries from the UserHighestRole table and cannot be reversed
+ end
+end
diff --git a/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb b/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb
new file mode 100644
index 00000000000..fa80b2b95e7
--- /dev/null
+++ b/db/post_migrate/20220803042351_add_tmp_index_todos_attention_request_action.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddTmpIndexTodosAttentionRequestAction < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = "tmp_index_todos_attention_request_action"
+ ATTENTION_REQUESTED = 10
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :todos, [:id],
+ where: "action = #{ATTENTION_REQUESTED}",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :todos, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb b/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb
new file mode 100644
index 00000000000..d3b281b08ad
--- /dev/null
+++ b/db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CleanupMrAttentionRequestTodos < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class Todo < MigrationRecord
+ self.table_name = 'todos'
+
+ include ::EachBatch
+
+ ATTENTION_REQUESTED = 10
+ end
+
+ def up
+ Todo.where(action: Todo::ATTENTION_REQUESTED).each_batch do |todos_batch|
+ todos_batch.delete_all
+ end
+ end
+
+ def down
+ # Attention request feature has been reverted.
+ end
+end
diff --git a/db/post_migrate/20220804235614_add_comment_to_vulnerability_state_transitions.rb b/db/post_migrate/20220804235614_add_comment_to_vulnerability_state_transitions.rb
new file mode 100644
index 00000000000..3e3cb5746bc
--- /dev/null
+++ b/db/post_migrate/20220804235614_add_comment_to_vulnerability_state_transitions.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddCommentToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.0]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb
+ def change
+ add_column :vulnerability_state_transitions, :comment, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb b/db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb
new file mode 100644
index 00000000000..dd84c0620ce
--- /dev/null
+++ b/db/post_migrate/20220805001210_add_text_limit_to_vulnerability_state_transitions_comment.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToVulnerabilityStateTransitionsComment < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :vulnerability_state_transitions, :comment, 255
+ end
+
+ def down
+ remove_text_limit :vulnerability_state_transitions, :comment
+ end
+end
diff --git a/db/post_migrate/20220808072054_prepare_index_removal_security_findings.rb b/db/post_migrate/20220808072054_prepare_index_removal_security_findings.rb
new file mode 100644
index 00000000000..eb4158fa9dd
--- /dev/null
+++ b/db/post_migrate/20220808072054_prepare_index_removal_security_findings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class PrepareIndexRemovalSecurityFindings < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = :index_on_security_findings_uuid_and_id_order_desc
+
+ def up
+ prepare_async_index_removal :security_findings, [:uuid, :id], name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index_by_name :security_findings, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220808131659_remove_ci_namespace_monthly_usages_additional_amount_available_column.rb b/db/post_migrate/20220808131659_remove_ci_namespace_monthly_usages_additional_amount_available_column.rb
new file mode 100644
index 00000000000..70a1e425e0d
--- /dev/null
+++ b/db/post_migrate/20220808131659_remove_ci_namespace_monthly_usages_additional_amount_available_column.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveCiNamespaceMonthlyUsagesAdditionalAmountAvailableColumn < Gitlab::Database::Migration[2.0]
+ def up
+ remove_column :ci_namespace_monthly_usages, :additional_amount_available
+ end
+
+ def down
+ add_column :ci_namespace_monthly_usages, :additional_amount_available, :integer, default: 0, null: false
+ end
+end
diff --git a/db/post_migrate/20220810093742_add_async_tmp_index_job_artifacts_id_and_expire_at.rb b/db/post_migrate/20220810093742_add_async_tmp_index_job_artifacts_id_and_expire_at.rb
new file mode 100644
index 00000000000..5a52b26ed92
--- /dev/null
+++ b/db/post_migrate/20220810093742_add_async_tmp_index_job_artifacts_id_and_expire_at.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddAsyncTmpIndexJobArtifactsIdAndExpireAt < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_expire_at_file_type_trace'
+
+ EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE = <<~SQL
+ (EXTRACT(day FROM timezone('UTC', expire_at)) IN (21, 22, 23)
+ AND EXTRACT(minute FROM timezone('UTC', expire_at)) IN (0, 30, 45)
+ AND EXTRACT(second FROM timezone('UTC', expire_at)) = 0)
+ OR file_type = 3
+ SQL
+
+ def up
+ prepare_async_index :ci_job_artifacts, :id,
+ where: EXPIRE_AT_ON_22_MIDNIGHT_IN_TIMEZONE_OR_TRACE, name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :ci_job_artifacts, INDEX_NAME
+ end
+end
diff --git a/db/schema_migrations/20220316022505 b/db/schema_migrations/20220316022505
new file mode 100644
index 00000000000..dd6bed30e8a
--- /dev/null
+++ b/db/schema_migrations/20220316022505
@@ -0,0 +1 @@
+c974e1a600323bac9b913e9e382384c302037ed6d1fc1df3b747471810293167 \ No newline at end of file
diff --git a/db/schema_migrations/20220506154054 b/db/schema_migrations/20220506154054
new file mode 100644
index 00000000000..8240d040c25
--- /dev/null
+++ b/db/schema_migrations/20220506154054
@@ -0,0 +1 @@
+a931441890bd5d472f88dcef82bb42e3c8046a981788f2362a8deb89f4ac049a \ No newline at end of file
diff --git a/db/schema_migrations/20220524184149 b/db/schema_migrations/20220524184149
new file mode 100644
index 00000000000..b75a7640a76
--- /dev/null
+++ b/db/schema_migrations/20220524184149
@@ -0,0 +1 @@
+f28bf2a6fe412342eef053b57cce14c0681d04f9e978e37bbd505f1efa36e92e \ No newline at end of file
diff --git a/db/schema_migrations/20220525201022 b/db/schema_migrations/20220525201022
new file mode 100644
index 00000000000..7b4ce7c509c
--- /dev/null
+++ b/db/schema_migrations/20220525201022
@@ -0,0 +1 @@
+c2b2fc7674b99791f6d239e42add7db3c72f2b27e653e2348887d0178f77686a \ No newline at end of file
diff --git a/db/schema_migrations/20220525221133 b/db/schema_migrations/20220525221133
new file mode 100644
index 00000000000..0e78ee5df45
--- /dev/null
+++ b/db/schema_migrations/20220525221133
@@ -0,0 +1 @@
+b22a0dd285d383f556a5402441f3e82a6db6dd47008444b94303351b295b414e \ No newline at end of file
diff --git a/db/schema_migrations/20220603173103 b/db/schema_migrations/20220603173103
new file mode 100644
index 00000000000..cf2a199ee5b
--- /dev/null
+++ b/db/schema_migrations/20220603173103
@@ -0,0 +1 @@
+4a618d15ee56e7cb9a20385824cc63cf12f8a2eb3604c787f79356398094a3b6 \ No newline at end of file
diff --git a/db/schema_migrations/20220607082910 b/db/schema_migrations/20220607082910
new file mode 100644
index 00000000000..db9c63e20c5
--- /dev/null
+++ b/db/schema_migrations/20220607082910
@@ -0,0 +1 @@
+2ce59d4c11daec217cd55148476f123f25727c5519f0f180f68e07b4fa33be97 \ No newline at end of file
diff --git a/db/schema_migrations/20220614185644 b/db/schema_migrations/20220614185644
new file mode 100644
index 00000000000..dcc2d926276
--- /dev/null
+++ b/db/schema_migrations/20220614185644
@@ -0,0 +1 @@
+f1d4faf4d32a3271a97b389d53c9d3accbfa3fa2bd47d63257fe589efa4bb665 \ No newline at end of file
diff --git a/db/schema_migrations/20220619212618 b/db/schema_migrations/20220619212618
new file mode 100644
index 00000000000..1ecfdb6aed4
--- /dev/null
+++ b/db/schema_migrations/20220619212618
@@ -0,0 +1 @@
+34a9ec48e8480f3a235089f01944f60e93e4b87909a660f18a42bc47a3a0fe51 \ No newline at end of file
diff --git a/db/schema_migrations/20220621192541 b/db/schema_migrations/20220621192541
new file mode 100644
index 00000000000..6a638616894
--- /dev/null
+++ b/db/schema_migrations/20220621192541
@@ -0,0 +1 @@
+b5bc058c3a0217dc6a62af717861f4bce052c8b86d6c053919e2b10bcc9af845 \ No newline at end of file
diff --git a/db/schema_migrations/20220629124942 b/db/schema_migrations/20220629124942
new file mode 100644
index 00000000000..a5f9968b622
--- /dev/null
+++ b/db/schema_migrations/20220629124942
@@ -0,0 +1 @@
+d0e6dda681ec7980d1aeccd7976425edbe212b0676e6c57c6941f0ba73bbb8b4 \ No newline at end of file
diff --git a/db/schema_migrations/20220707105335 b/db/schema_migrations/20220707105335
new file mode 100644
index 00000000000..1f1a4d8b41b
--- /dev/null
+++ b/db/schema_migrations/20220707105335
@@ -0,0 +1 @@
+2f3dc1952c43a6786f8a66713ac89ca24f828f683a57f7373c91d5e629242909 \ No newline at end of file
diff --git a/db/schema_migrations/20220707105529 b/db/schema_migrations/20220707105529
new file mode 100644
index 00000000000..df01b63f89c
--- /dev/null
+++ b/db/schema_migrations/20220707105529
@@ -0,0 +1 @@
+82504ed0c287565d9b9eadf929badaa893beaac36224c7c2c7b4e14a663fa9e5 \ No newline at end of file
diff --git a/db/schema_migrations/20220707160707 b/db/schema_migrations/20220707160707
new file mode 100644
index 00000000000..f9b10cb637f
--- /dev/null
+++ b/db/schema_migrations/20220707160707
@@ -0,0 +1 @@
+772af1dd1d9d7a0cc9ec35b23db66cf2f43767f1f8351023e951090d91544d23 \ No newline at end of file
diff --git a/db/schema_migrations/20220707160921 b/db/schema_migrations/20220707160921
new file mode 100644
index 00000000000..644d56898ca
--- /dev/null
+++ b/db/schema_migrations/20220707160921
@@ -0,0 +1 @@
+ce50506f9e56f26b5e773888c0ec8d1465b3b4aed152bf8c9a20bf1215e9fa19 \ No newline at end of file
diff --git a/db/schema_migrations/20220707181910 b/db/schema_migrations/20220707181910
new file mode 100644
index 00000000000..d9aef7bdba0
--- /dev/null
+++ b/db/schema_migrations/20220707181910
@@ -0,0 +1 @@
+78bb335a94237bfb5c5401807c9fc5e8ff9ec331af0ca0d3c5626253af5cde3f \ No newline at end of file
diff --git a/db/schema_migrations/20220707181920 b/db/schema_migrations/20220707181920
new file mode 100644
index 00000000000..de6972176f9
--- /dev/null
+++ b/db/schema_migrations/20220707181920
@@ -0,0 +1 @@
+179c400efd7d31b78b4314104c5e9cbdf744c5e2966cecf724d1b7088b515fd1 \ No newline at end of file
diff --git a/db/schema_migrations/20220707181930 b/db/schema_migrations/20220707181930
new file mode 100644
index 00000000000..11594611609
--- /dev/null
+++ b/db/schema_migrations/20220707181930
@@ -0,0 +1 @@
+431392f5f88f493371b77263bbe380d08e486e8ba0d013213e6fe7fdcda3c7db \ No newline at end of file
diff --git a/db/schema_migrations/20220707190546 b/db/schema_migrations/20220707190546
new file mode 100644
index 00000000000..b46b27e60c8
--- /dev/null
+++ b/db/schema_migrations/20220707190546
@@ -0,0 +1 @@
+fd68f63f6ec50233c99b5173b69fa6ff99b1ae9b2d023cdccdff3cd94be35b36 \ No newline at end of file
diff --git a/db/schema_migrations/20220712131513 b/db/schema_migrations/20220712131513
new file mode 100644
index 00000000000..e16feb4d96c
--- /dev/null
+++ b/db/schema_migrations/20220712131513
@@ -0,0 +1 @@
+4ee9f603c04284cbc0fcb6aa47ecc0f0fe238b4d68083a51f5f170edca19608b \ No newline at end of file
diff --git a/db/schema_migrations/20220712131533 b/db/schema_migrations/20220712131533
new file mode 100644
index 00000000000..276b649097e
--- /dev/null
+++ b/db/schema_migrations/20220712131533
@@ -0,0 +1 @@
+b4ff0087acba9b91182219ea49a5a7d1bfd5b55391f0174ea62a2bfa14af03ce \ No newline at end of file
diff --git a/db/schema_migrations/20220712144843 b/db/schema_migrations/20220712144843
new file mode 100644
index 00000000000..d1bd4fbecc8
--- /dev/null
+++ b/db/schema_migrations/20220712144843
@@ -0,0 +1 @@
+2d225c96f4fbc08b2443a1e6c723d2a337ed1e10412323ba816858db03299738 \ No newline at end of file
diff --git a/db/schema_migrations/20220712144900 b/db/schema_migrations/20220712144900
new file mode 100644
index 00000000000..e84149e7b76
--- /dev/null
+++ b/db/schema_migrations/20220712144900
@@ -0,0 +1 @@
+4e19d3306807b83e4dddd3c7212b662f39c0d852826df1d22fc29c251fa0d1da \ No newline at end of file
diff --git a/db/schema_migrations/20220715152108 b/db/schema_migrations/20220715152108
new file mode 100644
index 00000000000..23d61b45334
--- /dev/null
+++ b/db/schema_migrations/20220715152108
@@ -0,0 +1 @@
+76f4adebfb71dcd51f861097ba441ae5ee3f62eeb2060f147730d4e6c6006402 \ No newline at end of file
diff --git a/db/schema_migrations/20220715185348 b/db/schema_migrations/20220715185348
new file mode 100644
index 00000000000..6df20d578f0
--- /dev/null
+++ b/db/schema_migrations/20220715185348
@@ -0,0 +1 @@
+5a8e178601b1b88bef0186269bc62f8e3b10eacb0fe8a9a11e322c244883cfde \ No newline at end of file
diff --git a/db/schema_migrations/20220715185436 b/db/schema_migrations/20220715185436
new file mode 100644
index 00000000000..31f9a069d31
--- /dev/null
+++ b/db/schema_migrations/20220715185436
@@ -0,0 +1 @@
+673e77eb5ffa49ab70088a7a43119c5f388d199e69504994c8c0a2a867ee1da3 \ No newline at end of file
diff --git a/db/schema_migrations/20220715190612 b/db/schema_migrations/20220715190612
new file mode 100644
index 00000000000..ffafb037b43
--- /dev/null
+++ b/db/schema_migrations/20220715190612
@@ -0,0 +1 @@
+bbb07db2554d2b1c7083341efcdc065a3a25ba4b042b0b3ea3cb26ec25e1e023 \ No newline at end of file
diff --git a/db/schema_migrations/20220715191629 b/db/schema_migrations/20220715191629
new file mode 100644
index 00000000000..88874ec93d3
--- /dev/null
+++ b/db/schema_migrations/20220715191629
@@ -0,0 +1 @@
+e300a6144e63f734e41b3a3ad40089dea5764ea2636ea11f5782fe86b6574229 \ No newline at end of file
diff --git a/db/schema_migrations/20220718083945 b/db/schema_migrations/20220718083945
new file mode 100644
index 00000000000..f1d247e5349
--- /dev/null
+++ b/db/schema_migrations/20220718083945
@@ -0,0 +1 @@
+42b601de66244f527b8c40182b7c9c8ba3a6ea9863582be3c499ffe2491c8d4f \ No newline at end of file
diff --git a/db/schema_migrations/20220719081542 b/db/schema_migrations/20220719081542
new file mode 100644
index 00000000000..4bd2a3008ca
--- /dev/null
+++ b/db/schema_migrations/20220719081542
@@ -0,0 +1 @@
+2d5bf23684afbd4dbf3251c4886c22eaaa144332901c1183bc474772f065c54f \ No newline at end of file
diff --git a/db/schema_migrations/20220719165537 b/db/schema_migrations/20220719165537
new file mode 100644
index 00000000000..f60f26fb705
--- /dev/null
+++ b/db/schema_migrations/20220719165537
@@ -0,0 +1 @@
+c9b214fd49c97d17f43faef4d86b811ea2ad5f573c3cb4a6725de8ee4c92262a \ No newline at end of file
diff --git a/db/schema_migrations/20220720090354 b/db/schema_migrations/20220720090354
new file mode 100644
index 00000000000..f6a34d452ec
--- /dev/null
+++ b/db/schema_migrations/20220720090354
@@ -0,0 +1 @@
+caf9b383524401d5b552d5593aa8ae51d58138759af5aebdec0825818033100d \ No newline at end of file
diff --git a/db/schema_migrations/20220720121421 b/db/schema_migrations/20220720121421
new file mode 100644
index 00000000000..da6450068ee
--- /dev/null
+++ b/db/schema_migrations/20220720121421
@@ -0,0 +1 @@
+3ccb1e6d2ab41d4d84e0582563c68b0518d57f518d1560b1bacd257a40e14034 \ No newline at end of file
diff --git a/db/schema_migrations/20220720123249 b/db/schema_migrations/20220720123249
new file mode 100644
index 00000000000..f29b38f7efe
--- /dev/null
+++ b/db/schema_migrations/20220720123249
@@ -0,0 +1 @@
+d64ae3a91253fa497f897e7843c9b86f1dec3ccb6f997c4bbe50aec96699f1d2 \ No newline at end of file
diff --git a/db/schema_migrations/20220720161816 b/db/schema_migrations/20220720161816
new file mode 100644
index 00000000000..be1e2809a3f
--- /dev/null
+++ b/db/schema_migrations/20220720161816
@@ -0,0 +1 @@
+8933e0dfff73ebef359de9512e8a89d43da37991b03500aac1d1a1ba78d6a4a9 \ No newline at end of file
diff --git a/db/schema_migrations/20220720162123 b/db/schema_migrations/20220720162123
new file mode 100644
index 00000000000..8a4c17468c0
--- /dev/null
+++ b/db/schema_migrations/20220720162123
@@ -0,0 +1 @@
+1b8fd9394fefd20a8a0ad281f10b4006063e436e3e41d5651e84b43dccd9c221 \ No newline at end of file
diff --git a/db/schema_migrations/20220720171102 b/db/schema_migrations/20220720171102
new file mode 100644
index 00000000000..f041d3d9db3
--- /dev/null
+++ b/db/schema_migrations/20220720171102
@@ -0,0 +1 @@
+4daf9a0b571968640c4b6ddfa6dbc2d71ed1632b4dc4d350cd5cab4ae53c8178 \ No newline at end of file
diff --git a/db/schema_migrations/20220720171801 b/db/schema_migrations/20220720171801
new file mode 100644
index 00000000000..ada8897b868
--- /dev/null
+++ b/db/schema_migrations/20220720171801
@@ -0,0 +1 @@
+161186e3bb37a3c03f7e6ec5f833e86bcc163af33847666006e9a0cf814eb876 \ No newline at end of file
diff --git a/db/schema_migrations/20220720210446 b/db/schema_migrations/20220720210446
new file mode 100644
index 00000000000..143d05d70f3
--- /dev/null
+++ b/db/schema_migrations/20220720210446
@@ -0,0 +1 @@
+d9ce6e056d66e6c1fb9dc6ac6340cc74cf2572edefce1a2a2cefe0556ee5db41 \ No newline at end of file
diff --git a/db/schema_migrations/20220721031446 b/db/schema_migrations/20220721031446
new file mode 100644
index 00000000000..cb58abdd70c
--- /dev/null
+++ b/db/schema_migrations/20220721031446
@@ -0,0 +1 @@
+fb37a812240cd314227b112f1c5f379fece783fddcf922ceafbf2c968c72ab30 \ No newline at end of file
diff --git a/db/schema_migrations/20220721140252 b/db/schema_migrations/20220721140252
new file mode 100644
index 00000000000..9bf2074ccc4
--- /dev/null
+++ b/db/schema_migrations/20220721140252
@@ -0,0 +1 @@
+42de6dadaff1c9666f759992488eda01c5327e5c377088ffc703b60fa37b18da \ No newline at end of file
diff --git a/db/schema_migrations/20220722084543 b/db/schema_migrations/20220722084543
new file mode 100644
index 00000000000..44d94a312b8
--- /dev/null
+++ b/db/schema_migrations/20220722084543
@@ -0,0 +1 @@
+b189304b940d01a527bba4ad8b0865ae44de1e3af2ef1b711d95993821106b6b \ No newline at end of file
diff --git a/db/schema_migrations/20220722110026 b/db/schema_migrations/20220722110026
new file mode 100644
index 00000000000..56f4699cace
--- /dev/null
+++ b/db/schema_migrations/20220722110026
@@ -0,0 +1 @@
+79c7847740cb02fffeaeae55f869889f201b7a9431693bea7249ddff9d405fb4 \ No newline at end of file
diff --git a/db/schema_migrations/20220722123318 b/db/schema_migrations/20220722123318
new file mode 100644
index 00000000000..a9b01a68114
--- /dev/null
+++ b/db/schema_migrations/20220722123318
@@ -0,0 +1 @@
+71ac60c42a546f65329eb2028d2de1252da01909b866fcc5151b928ee69f26d6 \ No newline at end of file
diff --git a/db/schema_migrations/20220722145845 b/db/schema_migrations/20220722145845
new file mode 100644
index 00000000000..458facc060d
--- /dev/null
+++ b/db/schema_migrations/20220722145845
@@ -0,0 +1 @@
+612a9cf3004e4d837749ef522ed72920275c9ddd8570b1a5a5e6ff51b49afd67 \ No newline at end of file
diff --git a/db/schema_migrations/20220722150231 b/db/schema_migrations/20220722150231
new file mode 100644
index 00000000000..fb36c04c168
--- /dev/null
+++ b/db/schema_migrations/20220722150231
@@ -0,0 +1 @@
+d5fac73cd92e84f49b41aa38e560eed36906e29e7009ff03ef59ebcf9836ee1f \ No newline at end of file
diff --git a/db/schema_migrations/20220722203840 b/db/schema_migrations/20220722203840
new file mode 100644
index 00000000000..0c719b0ce3d
--- /dev/null
+++ b/db/schema_migrations/20220722203840
@@ -0,0 +1 @@
+6a3f6ca25cac7f846c2f52388a8898bd05095f0d612bc7d4950e899880e0c8b8 \ No newline at end of file
diff --git a/db/schema_migrations/20220723120039 b/db/schema_migrations/20220723120039
new file mode 100644
index 00000000000..54be61091e3
--- /dev/null
+++ b/db/schema_migrations/20220723120039
@@ -0,0 +1 @@
+1a6a488243a8fa564f07301028477d64ca290b4ec636cfaab4816dab8bf3dd3f \ No newline at end of file
diff --git a/db/schema_migrations/20220725150127 b/db/schema_migrations/20220725150127
new file mode 100644
index 00000000000..3cbc80d8883
--- /dev/null
+++ b/db/schema_migrations/20220725150127
@@ -0,0 +1 @@
+78563f41df5a49803c59b4e41845c985fd1e5f19b1050998fb78d53a9dfe7a28 \ No newline at end of file
diff --git a/db/schema_migrations/20220726025516 b/db/schema_migrations/20220726025516
new file mode 100644
index 00000000000..58bab5467db
--- /dev/null
+++ b/db/schema_migrations/20220726025516
@@ -0,0 +1 @@
+326acd1c7e562056d29d5727869a0d0e5a5e9c387b0f54238c79c89f3947808b \ No newline at end of file
diff --git a/db/schema_migrations/20220726154012 b/db/schema_migrations/20220726154012
new file mode 100644
index 00000000000..b3e54480054
--- /dev/null
+++ b/db/schema_migrations/20220726154012
@@ -0,0 +1 @@
+6db09c05e52a9397eff77c56ab54886cd5b1ea5235425cbc83f865352dd75706 \ No newline at end of file
diff --git a/db/schema_migrations/20220726154013 b/db/schema_migrations/20220726154013
new file mode 100644
index 00000000000..6ef0bc248bb
--- /dev/null
+++ b/db/schema_migrations/20220726154013
@@ -0,0 +1 @@
+e079df21e69a855a3dc6c306e14796dacfabacc97632b859481009808a7ce133 \ No newline at end of file
diff --git a/db/schema_migrations/20220726154014 b/db/schema_migrations/20220726154014
new file mode 100644
index 00000000000..1991af185e8
--- /dev/null
+++ b/db/schema_migrations/20220726154014
@@ -0,0 +1 @@
+22c29639048e83f926b5ed2a44a14638fa70cba01f7f11a97f97ec321ae9173c \ No newline at end of file
diff --git a/db/schema_migrations/20220726154015 b/db/schema_migrations/20220726154015
new file mode 100644
index 00000000000..1eb661be563
--- /dev/null
+++ b/db/schema_migrations/20220726154015
@@ -0,0 +1 @@
+4c8d8356b977f875540bb931bfe03c811de17223bd76632ba65af53b7e227b08 \ No newline at end of file
diff --git a/db/schema_migrations/20220726154016 b/db/schema_migrations/20220726154016
new file mode 100644
index 00000000000..1df82964d21
--- /dev/null
+++ b/db/schema_migrations/20220726154016
@@ -0,0 +1 @@
+87bd0e2a2d0a9a8a45ce177ed847a15d2f015b155a1a47cd8fcf6ea00713b98c \ No newline at end of file
diff --git a/db/schema_migrations/20220726182310 b/db/schema_migrations/20220726182310
new file mode 100644
index 00000000000..fd5d282f525
--- /dev/null
+++ b/db/schema_migrations/20220726182310
@@ -0,0 +1 @@
+318684106f2976e285b6aaa1a73363badeec083a180a68973ba9d51dd89886c0 \ No newline at end of file
diff --git a/db/schema_migrations/20220726230052 b/db/schema_migrations/20220726230052
new file mode 100644
index 00000000000..985c5989f99
--- /dev/null
+++ b/db/schema_migrations/20220726230052
@@ -0,0 +1 @@
+1ca4a1260dee3a034529eeeb8a340a84b9bbc3abf0f853d46f26b6853527bbf0 \ No newline at end of file
diff --git a/db/schema_migrations/20220728114136 b/db/schema_migrations/20220728114136
new file mode 100644
index 00000000000..f5bd9962aa3
--- /dev/null
+++ b/db/schema_migrations/20220728114136
@@ -0,0 +1 @@
+eb0a6cff006f54f3b5fe12ab566dabfbefa1af46fafbfadde1b292b46e9d17c9 \ No newline at end of file
diff --git a/db/schema_migrations/20220728134255 b/db/schema_migrations/20220728134255
new file mode 100644
index 00000000000..f5ab53d70a0
--- /dev/null
+++ b/db/schema_migrations/20220728134255
@@ -0,0 +1 @@
+c868a83176c8e0024ef16e0f95d8a16a0f1b7be0c1a5d58902397cc0462a7e34 \ No newline at end of file
diff --git a/db/schema_migrations/20220729033851 b/db/schema_migrations/20220729033851
new file mode 100644
index 00000000000..b24c964cdb2
--- /dev/null
+++ b/db/schema_migrations/20220729033851
@@ -0,0 +1 @@
+0e8b193943aa02c8b700c06110725fd643378cf79715d1398238abc407639c67 \ No newline at end of file
diff --git a/db/schema_migrations/20220729052031 b/db/schema_migrations/20220729052031
new file mode 100644
index 00000000000..9305fbfade6
--- /dev/null
+++ b/db/schema_migrations/20220729052031
@@ -0,0 +1 @@
+504d33abb6bb9f8b53f33872715ce9839bd7264ef00618d033adf4d8899190b2 \ No newline at end of file
diff --git a/db/schema_migrations/20220729073603 b/db/schema_migrations/20220729073603
new file mode 100644
index 00000000000..eb69bd1ce51
--- /dev/null
+++ b/db/schema_migrations/20220729073603
@@ -0,0 +1 @@
+b0499c9b4cf3f39eec49dc7def7eaf8f1bbd03f2a34ba9eefa8440a109672136 \ No newline at end of file
diff --git a/db/schema_migrations/20220801144713 b/db/schema_migrations/20220801144713
new file mode 100644
index 00000000000..764c53e212a
--- /dev/null
+++ b/db/schema_migrations/20220801144713
@@ -0,0 +1 @@
+a332483a18eb46c1c4ce0d93b4269d630978a8c93e307f22ec5b412f3fa8f355 \ No newline at end of file
diff --git a/db/schema_migrations/20220801150028 b/db/schema_migrations/20220801150028
new file mode 100644
index 00000000000..c6d12f6a70d
--- /dev/null
+++ b/db/schema_migrations/20220801150028
@@ -0,0 +1 @@
+6515dbfcf8bc32c25e0547ea21af95c1dc2e89e3571abdef0e43e5289cd71c2c \ No newline at end of file
diff --git a/db/schema_migrations/20220802112102 b/db/schema_migrations/20220802112102
new file mode 100644
index 00000000000..b37b29b5800
--- /dev/null
+++ b/db/schema_migrations/20220802112102
@@ -0,0 +1 @@
+e5728437ae659e14906f5c0c36eea80d66e1ca056b037934b24d5a3f5489d8b7 \ No newline at end of file
diff --git a/db/schema_migrations/20220802114351 b/db/schema_migrations/20220802114351
new file mode 100644
index 00000000000..e371419c392
--- /dev/null
+++ b/db/schema_migrations/20220802114351
@@ -0,0 +1 @@
+c314412f0c5d4ad9447671a8e03e94af1a1b79718479769f763e20a689ce7d2f \ No newline at end of file
diff --git a/db/schema_migrations/20220802132158 b/db/schema_migrations/20220802132158
new file mode 100644
index 00000000000..06d7e747f30
--- /dev/null
+++ b/db/schema_migrations/20220802132158
@@ -0,0 +1 @@
+5aeb871227aa1a4c6c08c0e394d7b6324fe55ff6513e83668cf413c569b0b30f \ No newline at end of file
diff --git a/db/schema_migrations/20220802154757 b/db/schema_migrations/20220802154757
new file mode 100644
index 00000000000..a92f69e31da
--- /dev/null
+++ b/db/schema_migrations/20220802154757
@@ -0,0 +1 @@
+17d0f47b4663fdbcba617a456f713ebfe3782318abc7e46dc4a8e69bc76cf16f \ No newline at end of file
diff --git a/db/schema_migrations/20220802204737 b/db/schema_migrations/20220802204737
new file mode 100644
index 00000000000..faf1e6b89ba
--- /dev/null
+++ b/db/schema_migrations/20220802204737
@@ -0,0 +1 @@
+4de7fddbc2f44cf1450af25bd55a5f2586c3daf79b1443ec26ba9d47002707d7 \ No newline at end of file
diff --git a/db/schema_migrations/20220803042351 b/db/schema_migrations/20220803042351
new file mode 100644
index 00000000000..1b35b709eaf
--- /dev/null
+++ b/db/schema_migrations/20220803042351
@@ -0,0 +1 @@
+50c58b03d92451753cbdcb2e820e7d1ca9644f914027db46b57d2206e7832ec7 \ No newline at end of file
diff --git a/db/schema_migrations/20220803042352 b/db/schema_migrations/20220803042352
new file mode 100644
index 00000000000..011051cd5e4
--- /dev/null
+++ b/db/schema_migrations/20220803042352
@@ -0,0 +1 @@
+03d95257a9169a33a90baf28a6737f68fb999f920450a1cb90732820490be1c4 \ No newline at end of file
diff --git a/db/schema_migrations/20220803145637 b/db/schema_migrations/20220803145637
new file mode 100644
index 00000000000..36688f97184
--- /dev/null
+++ b/db/schema_migrations/20220803145637
@@ -0,0 +1 @@
+bf12037cb99a399302610f948dad48589eca4e631d82d9f26b04bae882b10020 \ No newline at end of file
diff --git a/db/schema_migrations/20220803154543 b/db/schema_migrations/20220803154543
new file mode 100644
index 00000000000..f5cfb3d91ba
--- /dev/null
+++ b/db/schema_migrations/20220803154543
@@ -0,0 +1 @@
+047147acc972ab8681f097d5060998a47e44612fde7f2137714683bd61350c2d \ No newline at end of file
diff --git a/db/schema_migrations/20220803154758 b/db/schema_migrations/20220803154758
new file mode 100644
index 00000000000..71ac8b4f301
--- /dev/null
+++ b/db/schema_migrations/20220803154758
@@ -0,0 +1 @@
+2cdf4c4fe218a5fb7061bf65643868c7b592cd3ef0d7611949e8fd86bc635c24 \ No newline at end of file
diff --git a/db/schema_migrations/20220804235614 b/db/schema_migrations/20220804235614
new file mode 100644
index 00000000000..29d78297b22
--- /dev/null
+++ b/db/schema_migrations/20220804235614
@@ -0,0 +1 @@
+699f3b81d8694e30161ce3cc58c50f6e638e89c784df9e174ba87636d49a4fc9 \ No newline at end of file
diff --git a/db/schema_migrations/20220805001210 b/db/schema_migrations/20220805001210
new file mode 100644
index 00000000000..c13eddc30ea
--- /dev/null
+++ b/db/schema_migrations/20220805001210
@@ -0,0 +1 @@
+8863596a3b18497d6f995291953afa5a0ec9c0f7d76a98758add72c8859078b5 \ No newline at end of file
diff --git a/db/schema_migrations/20220805154101 b/db/schema_migrations/20220805154101
new file mode 100644
index 00000000000..2f443da6760
--- /dev/null
+++ b/db/schema_migrations/20220805154101
@@ -0,0 +1 @@
+6b6cb1cd97434e8d172257f9ef404ed31d07fb2b9a5e27a5bc0a9cf9a175b066 \ No newline at end of file
diff --git a/db/schema_migrations/20220808072054 b/db/schema_migrations/20220808072054
new file mode 100644
index 00000000000..93ef145ba92
--- /dev/null
+++ b/db/schema_migrations/20220808072054
@@ -0,0 +1 @@
+5e489655875408b2879f44f006b420a62554e6523ca687cfa64485e0123fc25c \ No newline at end of file
diff --git a/db/schema_migrations/20220808131659 b/db/schema_migrations/20220808131659
new file mode 100644
index 00000000000..65a08ad1b7a
--- /dev/null
+++ b/db/schema_migrations/20220808131659
@@ -0,0 +1 @@
+07488e8c6ea0f3dc92e1370efb0190facf520b850e170fcd8f3ce0e2a15c096a \ No newline at end of file
diff --git a/db/schema_migrations/20220808133824 b/db/schema_migrations/20220808133824
new file mode 100644
index 00000000000..bf7755d3163
--- /dev/null
+++ b/db/schema_migrations/20220808133824
@@ -0,0 +1 @@
+bab4f4d3aaedd698400fcbd5991797530450fe845a8034b03b1bf525a61e628a \ No newline at end of file
diff --git a/db/schema_migrations/20220808190124 b/db/schema_migrations/20220808190124
new file mode 100644
index 00000000000..99b7173cbb6
--- /dev/null
+++ b/db/schema_migrations/20220808190124
@@ -0,0 +1 @@
+ab8dfd7549b2b61a5cf9d5b46935ec534ea77ec2025fdb58d03f654d81c8f6ee \ No newline at end of file
diff --git a/db/schema_migrations/20220808194857 b/db/schema_migrations/20220808194857
new file mode 100644
index 00000000000..10a35a98cb2
--- /dev/null
+++ b/db/schema_migrations/20220808194857
@@ -0,0 +1 @@
+12e5d5c0cb73c8c2fdde4f640a57ab9c70d2e41382bd6eb2e2d36c1018f299ef \ No newline at end of file
diff --git a/db/schema_migrations/20220810093742 b/db/schema_migrations/20220810093742
new file mode 100644
index 00000000000..27b700c9031
--- /dev/null
+++ b/db/schema_migrations/20220810093742
@@ -0,0 +1 @@
+ebe256fcaccd70055b08e0f5cedfffc039bcacddbf5722135ee47cb02d3babb8 \ No newline at end of file
diff --git a/db/schema_migrations/20220811092243 b/db/schema_migrations/20220811092243
new file mode 100644
index 00000000000..6640e5f1a65
--- /dev/null
+++ b/db/schema_migrations/20220811092243
@@ -0,0 +1 @@
+211eda22a78d14aaaf86345d3e33b852ba22a7dc9e41d9d683d58f162a7bdcc7 \ No newline at end of file
diff --git a/db/schema_migrations/20220811092244 b/db/schema_migrations/20220811092244
new file mode 100644
index 00000000000..824d936a09c
--- /dev/null
+++ b/db/schema_migrations/20220811092244
@@ -0,0 +1 @@
+f871847fbd494e31f13cf2fb87a1b8e9fc47c44e7f0ec9cf37f2084d19b9bf5f \ No newline at end of file
diff --git a/db/schema_migrations/20220811092245 b/db/schema_migrations/20220811092245
new file mode 100644
index 00000000000..09bd431d928
--- /dev/null
+++ b/db/schema_migrations/20220811092245
@@ -0,0 +1 @@
+0c856ce8170e4b864578f1bcb89d8930d8c1952e92356965a98e057521456968 \ No newline at end of file
diff --git a/db/schema_migrations/20220811092246 b/db/schema_migrations/20220811092246
new file mode 100644
index 00000000000..64d3153b833
--- /dev/null
+++ b/db/schema_migrations/20220811092246
@@ -0,0 +1 @@
+17bcb2fddd6331cbcec505e8094d1a400b7c3fd8b18897697aa9868689147cd7 \ No newline at end of file
diff --git a/db/schema_migrations/20220811092251 b/db/schema_migrations/20220811092251
new file mode 100644
index 00000000000..61e2afaa74a
--- /dev/null
+++ b/db/schema_migrations/20220811092251
@@ -0,0 +1 @@
+4ea4bc7e6f88561553b19c7bf4992561772506cf532cf569241a536f69e19b7f \ No newline at end of file
diff --git a/db/schema_migrations/20220811092253 b/db/schema_migrations/20220811092253
new file mode 100644
index 00000000000..fc8ad6918e9
--- /dev/null
+++ b/db/schema_migrations/20220811092253
@@ -0,0 +1 @@
+6a6eed069e051786a925b40469e7b53a563f99f0c6bfb810058511d3de8b0923 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index cc1e6dfb288..b055d831ce6 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -22,6 +22,19 @@ RETURN NULL;
END
$$;
+CREATE FUNCTION gitlab_schema_prevent_write() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+ IF COALESCE(NULLIF(current_setting(CONCAT('lock_writes.', TG_TABLE_NAME), true), ''), 'true') THEN
+ RAISE EXCEPTION 'Table: "%" is write protected within this Gitlab database.', TG_TABLE_NAME
+ USING ERRCODE = 'modifying_sql_data_not_permitted',
+ HINT = 'Make sure you are using the right database connection';
+ END IF;
+ RETURN NEW;
+END
+$$;
+
CREATE FUNCTION insert_into_loose_foreign_keys_deleted_records() RETURNS trigger
LANGUAGE plpgsql
AS $$
@@ -54,6 +67,7 @@ DECLARE
report_type smallint;
resolved_on_default_branch boolean;
present_on_default_branch boolean;
+ namespace_id bigint;
BEGIN
IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
RETURN NULL;
@@ -76,8 +90,17 @@ BEGIN
RETURN NULL;
END IF;
- INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
- VALUES (NEW.vulnerability_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint))
+ SELECT
+ projects.namespace_id
+ INTO
+ namespace_id
+ FROM
+ projects
+ WHERE
+ projects.id = NEW.project_id;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.vulnerability_id, namespace_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint))
ON CONFLICT(vulnerability_id) DO NOTHING;
RETURN NULL;
END
@@ -103,19 +126,21 @@ DECLARE
location_image text;
cluster_agent_id text;
casted_cluster_agent_id bigint;
+ namespace_id bigint;
BEGIN
SELECT
- v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint)
+ v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint), projects.namespace_id
INTO
- scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id
+ scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, namespace_id
FROM
- vulnerability_occurrences v_o
+ vulnerability_occurrences v_o
+ INNER JOIN projects ON projects.id = v_o.project_id
WHERE
v_o.vulnerability_id = NEW.id
LIMIT 1;
- INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
- VALUES (NEW.id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ INSERT INTO vulnerability_reads (vulnerability_id, namespace_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
+ VALUES (NEW.id, namespace_id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id)
ON CONFLICT(vulnerability_id) DO NOTHING;
RETURN NULL;
END
@@ -247,6 +272,74 @@ RETURN NULL;
END
$$;
+CREATE FUNCTION update_namespace_details_from_namespaces() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+INSERT INTO
+ namespace_details (
+ description,
+ description_html,
+ cached_markdown_version,
+ updated_at,
+ created_at,
+ namespace_id
+ )
+VALUES
+ (
+ NEW.description,
+ NEW.description_html,
+ NEW.cached_markdown_version,
+ NEW.updated_at,
+ NEW.updated_at,
+ NEW.id
+ ) ON CONFLICT (namespace_id) DO
+UPDATE
+SET
+ description = NEW.description,
+ description_html = NEW.description_html,
+ cached_markdown_version = NEW.cached_markdown_version,
+ updated_at = NEW.updated_at
+WHERE
+ namespace_details.namespace_id = NEW.id;RETURN NULL;
+
+END
+$$;
+
+CREATE FUNCTION update_namespace_details_from_projects() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+INSERT INTO
+ namespace_details (
+ description,
+ description_html,
+ cached_markdown_version,
+ updated_at,
+ created_at,
+ namespace_id
+ )
+VALUES
+ (
+ NEW.description,
+ NEW.description_html,
+ NEW.cached_markdown_version,
+ NEW.updated_at,
+ NEW.updated_at,
+ NEW.project_namespace_id
+ ) ON CONFLICT (namespace_id) DO
+UPDATE
+SET
+ description = NEW.description,
+ description_html = NEW.description_html,
+ cached_markdown_version = NEW.cached_markdown_version,
+ updated_at = NEW.updated_at
+WHERE
+ namespace_details.namespace_id = NEW.project_namespace_id;RETURN NULL;
+
+END
+$$;
+
CREATE FUNCTION update_vulnerability_reads_from_vulnerability() RETURNS trigger
LANGUAGE plpgsql
AS $$
@@ -11174,7 +11267,6 @@ CREATE TABLE application_settings (
elasticsearch_pause_indexing boolean DEFAULT false NOT NULL,
repository_storages_weighted jsonb DEFAULT '{}'::jsonb NOT NULL,
max_import_size integer DEFAULT 0 NOT NULL,
- enforce_pat_expiration boolean DEFAULT true NOT NULL,
compliance_frameworks smallint[] DEFAULT '{}'::smallint[] NOT NULL,
notify_on_unknown_sign_in boolean DEFAULT true NOT NULL,
default_branch_name text,
@@ -11222,7 +11314,6 @@ CREATE TABLE application_settings (
rate_limiting_response_text text,
invisible_captcha_enabled boolean DEFAULT false NOT NULL,
container_registry_cleanup_tags_service_max_list_size integer DEFAULT 200 NOT NULL,
- enforce_ssh_key_expiration boolean DEFAULT true NOT NULL,
git_two_factor_session_expiry integer DEFAULT 15 NOT NULL,
keep_latest_artifact boolean DEFAULT true NOT NULL,
notes_create_limit integer DEFAULT 300 NOT NULL,
@@ -11366,6 +11457,7 @@ CREATE TABLE application_settings (
git_rate_limit_users_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
error_tracking_access_token_encrypted text,
package_registry_cleanup_policies_worker_capacity integer DEFAULT 2 NOT NULL,
+ deactivate_dormant_users_period integer DEFAULT 90 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)),
@@ -12332,14 +12424,15 @@ ALTER SEQUENCE bulk_imports_id_seq OWNED BY bulk_imports.id;
CREATE TABLE chat_names (
id integer NOT NULL,
user_id integer NOT NULL,
- service_id integer NOT NULL,
team_id character varying NOT NULL,
team_domain character varying,
chat_id character varying NOT NULL,
chat_name character varying,
last_used_at timestamp without time zone,
created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL
+ updated_at timestamp without time zone NOT NULL,
+ integration_id integer,
+ CONSTRAINT check_2b0a0d0f0f CHECK ((integration_id IS NOT NULL))
);
CREATE SEQUENCE chat_names_id_seq
@@ -12471,7 +12564,6 @@ CREATE TABLE ci_builds (
"when" character varying,
yaml_variables text,
queued_at timestamp without time zone,
- token character varying,
lock_version integer DEFAULT 0,
coverage_regex character varying,
auto_canceled_by_id integer,
@@ -12512,7 +12604,8 @@ CREATE TABLE ci_builds_metadata (
secrets jsonb DEFAULT '{}'::jsonb NOT NULL,
build_id bigint NOT NULL,
id bigint NOT NULL,
- runtime_runner_features jsonb DEFAULT '{}'::jsonb NOT NULL
+ runtime_runner_features jsonb DEFAULT '{}'::jsonb NOT NULL,
+ id_tokens jsonb DEFAULT '{}'::jsonb NOT NULL
);
CREATE SEQUENCE ci_builds_metadata_id_seq
@@ -12766,7 +12859,6 @@ CREATE TABLE ci_namespace_monthly_usages (
id bigint NOT NULL,
namespace_id bigint NOT NULL,
date date NOT NULL,
- additional_amount_available integer DEFAULT 0 NOT NULL,
amount_used numeric(18,2) DEFAULT 0.0 NOT NULL,
notification_level smallint DEFAULT 100 NOT NULL,
shared_runners_duration integer DEFAULT 0 NOT NULL,
@@ -13154,8 +13246,6 @@ CREATE TABLE ci_runners (
maintainer_note text,
token_expires_at timestamp with time zone,
allowed_plans text[] DEFAULT '{}'::text[] NOT NULL,
- semver text,
- CONSTRAINT check_a4f24953fd CHECK ((char_length(semver) <= 16)),
CONSTRAINT check_ce275cee06 CHECK ((char_length(maintainer_note) <= 1024))
);
@@ -16509,7 +16599,6 @@ ALTER SEQUENCE issue_metrics_id_seq OWNED BY issue_metrics.id;
CREATE TABLE issue_tracker_data (
id bigint NOT NULL,
- service_id integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
encrypted_project_url character varying,
@@ -16517,7 +16606,9 @@ CREATE TABLE issue_tracker_data (
encrypted_issues_url character varying,
encrypted_issues_url_iv character varying,
encrypted_new_issue_url character varying,
- encrypted_new_issue_url_iv character varying
+ encrypted_new_issue_url_iv character varying,
+ integration_id integer,
+ CONSTRAINT check_7ca00cd891 CHECK ((integration_id IS NOT NULL))
);
CREATE SEQUENCE issue_tracker_data_id_seq
@@ -16585,6 +16676,7 @@ CREATE TABLE issues (
upvotes_count integer DEFAULT 0 NOT NULL,
work_item_type_id bigint,
namespace_id bigint,
+ start_date date,
CONSTRAINT check_fba63f706d CHECK ((lock_version IS NOT NULL))
);
@@ -16706,7 +16798,6 @@ ALTER SEQUENCE jira_imports_id_seq OWNED BY jira_imports.id;
CREATE TABLE jira_tracker_data (
id bigint NOT NULL,
- service_id integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
encrypted_url character varying,
@@ -16724,7 +16815,9 @@ CREATE TABLE jira_tracker_data (
vulnerabilities_issuetype text,
vulnerabilities_enabled boolean DEFAULT false NOT NULL,
jira_issue_transition_automatic boolean DEFAULT false NOT NULL,
+ integration_id integer,
CONSTRAINT check_0bf84b76e9 CHECK ((char_length(vulnerabilities_issuetype) <= 255)),
+ CONSTRAINT check_0fbd71d9f2 CHECK ((integration_id IS NOT NULL)),
CONSTRAINT check_214cf6a48b CHECK ((char_length(project_key) <= 255))
);
@@ -16989,6 +17082,24 @@ CREATE SEQUENCE loose_foreign_keys_deleted_records_id_seq
ALTER SEQUENCE loose_foreign_keys_deleted_records_id_seq OWNED BY loose_foreign_keys_deleted_records.id;
+CREATE TABLE member_roles (
+ id bigint NOT NULL,
+ namespace_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ base_access_level integer NOT NULL,
+ download_code boolean DEFAULT false
+);
+
+CREATE SEQUENCE member_roles_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE member_roles_id_seq OWNED BY member_roles.id;
+
CREATE TABLE member_tasks (
id bigint NOT NULL,
member_id bigint NOT NULL,
@@ -17027,7 +17138,8 @@ CREATE TABLE members (
override boolean DEFAULT false NOT NULL,
state smallint DEFAULT 0,
invite_email_success boolean DEFAULT true NOT NULL,
- member_namespace_id bigint
+ member_namespace_id bigint,
+ member_role_id bigint
);
CREATE SEQUENCE members_id_seq
@@ -17484,6 +17596,85 @@ CREATE SEQUENCE milestones_id_seq
ALTER SEQUENCE milestones_id_seq OWNED BY milestones.id;
+CREATE TABLE ml_candidate_metrics (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ candidate_id bigint,
+ value double precision,
+ step integer,
+ is_nan bytea,
+ name text NOT NULL,
+ CONSTRAINT check_3bb4a3fbd9 CHECK ((char_length(name) <= 250))
+);
+
+CREATE SEQUENCE ml_candidate_metrics_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ml_candidate_metrics_id_seq OWNED BY ml_candidate_metrics.id;
+
+CREATE TABLE ml_candidate_params (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ candidate_id bigint,
+ name text NOT NULL,
+ value text NOT NULL,
+ CONSTRAINT check_093034d049 CHECK ((char_length(name) <= 250)),
+ CONSTRAINT check_28a3c29e43 CHECK ((char_length(value) <= 250))
+);
+
+CREATE SEQUENCE ml_candidate_params_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ml_candidate_params_id_seq OWNED BY ml_candidate_params.id;
+
+CREATE TABLE ml_candidates (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ iid uuid NOT NULL,
+ experiment_id bigint NOT NULL,
+ user_id bigint
+);
+
+CREATE SEQUENCE ml_candidates_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ml_candidates_id_seq OWNED BY ml_candidates.id;
+
+CREATE TABLE ml_experiments (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ iid bigint NOT NULL,
+ project_id bigint NOT NULL,
+ user_id bigint,
+ name text NOT NULL,
+ CONSTRAINT check_ee07a0be2c CHECK ((char_length(name) <= 255))
+);
+
+CREATE SEQUENCE ml_experiments_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ml_experiments_id_seq OWNED BY ml_experiments.id;
+
CREATE TABLE namespace_admin_notes (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -17528,6 +17719,15 @@ CREATE TABLE namespace_ci_cd_settings (
allow_stale_runner_pruning boolean DEFAULT false NOT NULL
);
+CREATE TABLE namespace_details (
+ namespace_id bigint NOT NULL,
+ created_at timestamp with time zone,
+ updated_at timestamp with time zone,
+ cached_markdown_version integer,
+ description text,
+ description_html text
+);
+
CREATE TABLE namespace_limits (
additional_purchased_storage_size bigint DEFAULT 0 NOT NULL,
additional_purchased_storage_ends_on date,
@@ -17586,7 +17786,9 @@ CREATE TABLE namespace_settings (
unique_project_download_limit_interval_in_seconds integer DEFAULT 0 NOT NULL,
project_import_level smallint DEFAULT 50 NOT NULL,
include_for_free_user_cap_preview boolean DEFAULT false NOT NULL,
- CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255))
+ unique_project_download_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
+ CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255)),
+ CONSTRAINT namespace_settings_unique_project_download_limit_allowlist_size CHECK ((cardinality(unique_project_download_limit_allowlist) <= 100))
);
CREATE TABLE namespace_statistics (
@@ -18874,7 +19076,8 @@ CREATE TABLE plan_limits (
web_hook_calls_mid integer DEFAULT 0 NOT NULL,
web_hook_calls_low integer DEFAULT 0 NOT NULL,
project_ci_variables integer DEFAULT 200 NOT NULL,
- group_ci_variables integer DEFAULT 200 NOT NULL
+ group_ci_variables integer DEFAULT 200 NOT NULL,
+ ci_max_artifact_size_cyclonedx integer DEFAULT 1 NOT NULL
);
CREATE SEQUENCE plan_limits_id_seq
@@ -19286,7 +19489,8 @@ CREATE TABLE project_ci_cd_settings (
job_token_scope_enabled boolean DEFAULT false NOT NULL,
runner_token_expiration_interval integer,
separated_caches boolean DEFAULT true NOT NULL,
- opt_in_jwt boolean DEFAULT false NOT NULL
+ opt_in_jwt boolean DEFAULT false NOT NULL,
+ allow_fork_pipelines_to_run_in_parent_project boolean DEFAULT true NOT NULL
);
CREATE SEQUENCE project_ci_cd_settings_id_seq
@@ -19693,6 +19897,7 @@ CREATE TABLE project_settings (
legacy_open_source_license_available boolean DEFAULT true NOT NULL,
target_platforms character varying[] DEFAULT '{}'::character varying[] NOT NULL,
enforce_auth_checks_on_uploads boolean DEFAULT true NOT NULL,
+ selective_code_owner_removals boolean DEFAULT false NOT NULL,
CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)),
CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)),
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)),
@@ -19715,7 +19920,9 @@ CREATE TABLE project_statistics (
snippets_size bigint,
pipeline_artifacts_size bigint DEFAULT 0 NOT NULL,
uploads_size bigint DEFAULT 0 NOT NULL,
- container_registry_size bigint DEFAULT 0 NOT NULL
+ container_registry_size bigint DEFAULT 0 NOT NULL,
+ created_at timestamp with time zone DEFAULT now() NOT NULL,
+ updated_at timestamp with time zone DEFAULT now() NOT NULL
);
CREATE SEQUENCE project_statistics_id_seq
@@ -20577,11 +20784,12 @@ CREATE TABLE sbom_occurrences (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
- component_version_id bigint NOT NULL,
+ component_version_id bigint,
project_id bigint NOT NULL,
pipeline_id bigint,
source_id bigint,
- commit_sha bytea NOT NULL
+ commit_sha bytea NOT NULL,
+ component_id bigint NOT NULL
);
CREATE SEQUENCE sbom_occurrences_id_seq
@@ -20882,7 +21090,6 @@ ALTER SEQUENCE shards_id_seq OWNED BY shards.id;
CREATE TABLE slack_integrations (
id integer NOT NULL,
- service_id integer NOT NULL,
team_id character varying NOT NULL,
team_name character varying NOT NULL,
alias character varying NOT NULL,
@@ -20892,7 +21099,9 @@ CREATE TABLE slack_integrations (
bot_user_id text,
encrypted_bot_access_token bytea,
encrypted_bot_access_token_iv bytea,
- CONSTRAINT check_bc553aea8a CHECK ((char_length(bot_user_id) <= 255))
+ integration_id integer,
+ CONSTRAINT check_bc553aea8a CHECK ((char_length(bot_user_id) <= 255)),
+ CONSTRAINT check_c9ca9ae80d CHECK ((integration_id IS NOT NULL))
);
CREATE SEQUENCE slack_integrations_id_seq
@@ -21103,7 +21312,7 @@ CREATE TABLE ssh_signatures (
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
project_id bigint NOT NULL,
- key_id bigint NOT NULL,
+ key_id bigint,
verification_status smallint DEFAULT 0 NOT NULL,
commit_sha bytea NOT NULL
);
@@ -21781,6 +21990,23 @@ CREATE SEQUENCE user_preferences_id_seq
ALTER SEQUENCE user_preferences_id_seq OWNED BY user_preferences.id;
+CREATE TABLE user_project_callouts (
+ id bigint NOT NULL,
+ user_id bigint NOT NULL,
+ project_id bigint NOT NULL,
+ feature_name smallint NOT NULL,
+ dismissed_at timestamp with time zone
+);
+
+CREATE SEQUENCE user_project_callouts_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE user_project_callouts_id_seq OWNED BY user_project_callouts.id;
+
CREATE TABLE user_statuses (
user_id integer NOT NULL,
cached_markdown_version integer,
@@ -22331,7 +22557,6 @@ CREATE TABLE vulnerability_occurrences (
cve text,
location jsonb,
detection_method smallint DEFAULT 0 NOT NULL,
- migrated_to_new_structure boolean DEFAULT false 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)),
@@ -22361,6 +22586,7 @@ CREATE TABLE vulnerability_reads (
location_image text,
cluster_agent_id text,
casted_cluster_agent_id bigint,
+ namespace_id bigint,
CONSTRAINT check_380451bdbe CHECK ((char_length(location_image) <= 2048)),
CONSTRAINT check_a105eb825a CHECK ((char_length(cluster_agent_id) <= 10))
);
@@ -22423,7 +22649,10 @@ CREATE TABLE vulnerability_state_transitions (
to_state smallint NOT NULL,
from_state smallint NOT NULL,
created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL
+ updated_at timestamp with time zone NOT NULL,
+ author_id bigint,
+ comment text,
+ CONSTRAINT check_fca4a7ca39 CHECK ((char_length(comment) <= 255))
);
CREATE SEQUENCE vulnerability_state_transitions_id_seq
@@ -23278,6 +23507,8 @@ ALTER TABLE ONLY lists ALTER COLUMN id SET DEFAULT nextval('lists_id_seq'::regcl
ALTER TABLE ONLY loose_foreign_keys_deleted_records ALTER COLUMN id SET DEFAULT nextval('loose_foreign_keys_deleted_records_id_seq'::regclass);
+ALTER TABLE ONLY member_roles ALTER COLUMN id SET DEFAULT nextval('member_roles_id_seq'::regclass);
+
ALTER TABLE ONLY member_tasks ALTER COLUMN id SET DEFAULT nextval('member_tasks_id_seq'::regclass);
ALTER TABLE ONLY members ALTER COLUMN id SET DEFAULT nextval('members_id_seq'::regclass);
@@ -23316,6 +23547,14 @@ ALTER TABLE ONLY metrics_users_starred_dashboards ALTER COLUMN id SET DEFAULT ne
ALTER TABLE ONLY milestones ALTER COLUMN id SET DEFAULT nextval('milestones_id_seq'::regclass);
+ALTER TABLE ONLY ml_candidate_metrics ALTER COLUMN id SET DEFAULT nextval('ml_candidate_metrics_id_seq'::regclass);
+
+ALTER TABLE ONLY ml_candidate_params ALTER COLUMN id SET DEFAULT nextval('ml_candidate_params_id_seq'::regclass);
+
+ALTER TABLE ONLY ml_candidates ALTER COLUMN id SET DEFAULT nextval('ml_candidates_id_seq'::regclass);
+
+ALTER TABLE ONLY ml_experiments ALTER COLUMN id SET DEFAULT nextval('ml_experiments_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);
@@ -23658,6 +23897,8 @@ ALTER TABLE ONLY user_permission_export_uploads ALTER COLUMN id SET DEFAULT next
ALTER TABLE ONLY user_preferences ALTER COLUMN id SET DEFAULT nextval('user_preferences_id_seq'::regclass);
+ALTER TABLE ONLY user_project_callouts ALTER COLUMN id SET DEFAULT nextval('user_project_callouts_id_seq'::regclass);
+
ALTER TABLE ONLY user_statuses ALTER COLUMN user_id SET DEFAULT nextval('user_statuses_user_id_seq'::regclass);
ALTER TABLE ONLY user_synced_attributes_metadata ALTER COLUMN id SET DEFAULT nextval('user_synced_attributes_metadata_id_seq'::regclass);
@@ -25253,6 +25494,9 @@ ALTER TABLE ONLY lists
ALTER TABLE ONLY loose_foreign_keys_deleted_records
ADD CONSTRAINT loose_foreign_keys_deleted_records_pkey PRIMARY KEY (partition, id);
+ALTER TABLE ONLY member_roles
+ ADD CONSTRAINT member_roles_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY member_tasks
ADD CONSTRAINT member_tasks_pkey PRIMARY KEY (id);
@@ -25322,6 +25566,18 @@ ALTER TABLE ONLY milestone_releases
ALTER TABLE ONLY milestones
ADD CONSTRAINT milestones_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ml_candidate_metrics
+ ADD CONSTRAINT ml_candidate_metrics_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY ml_candidate_params
+ ADD CONSTRAINT ml_candidate_params_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY ml_candidates
+ ADD CONSTRAINT ml_candidates_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY ml_experiments
+ ADD CONSTRAINT ml_experiments_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY namespace_admin_notes
ADD CONSTRAINT namespace_admin_notes_pkey PRIMARY KEY (id);
@@ -25334,6 +25590,9 @@ ALTER TABLE ONLY namespace_bans
ALTER TABLE ONLY namespace_ci_cd_settings
ADD CONSTRAINT namespace_ci_cd_settings_pkey PRIMARY KEY (namespace_id);
+ALTER TABLE ONLY namespace_details
+ ADD CONSTRAINT namespace_details_pkey PRIMARY KEY (namespace_id);
+
ALTER TABLE ONLY namespace_limits
ADD CONSTRAINT namespace_limits_pkey PRIMARY KEY (namespace_id);
@@ -25764,7 +26023,7 @@ ALTER TABLE ONLY scim_oauth_access_tokens
ADD CONSTRAINT scim_oauth_access_tokens_pkey PRIMARY KEY (id);
ALTER TABLE ONLY security_findings
- ADD CONSTRAINT security_findings_pkey PRIMARY KEY (id);
+ ADD CONSTRAINT security_findings_pkey PRIMARY KEY (id, partition_number);
ALTER TABLE ONLY security_orchestration_policy_configurations
ADD CONSTRAINT security_orchestration_policy_configurations_pkey PRIMARY KEY (id);
@@ -25940,6 +26199,9 @@ ALTER TABLE ONLY user_permission_export_uploads
ALTER TABLE ONLY user_preferences
ADD CONSTRAINT user_preferences_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY user_project_callouts
+ ADD CONSTRAINT user_project_callouts_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY user_statuses
ADD CONSTRAINT user_statuses_pkey PRIMARY KEY (user_id);
@@ -27210,7 +27472,7 @@ CREATE UNIQUE INDEX idx_vuln_signatures_on_occurrences_id_and_signature_sha ON v
CREATE UNIQUE INDEX idx_vuln_signatures_uniqueness_signature_sha ON vulnerability_finding_signatures USING btree (finding_id, algorithm_type, signature_sha);
-CREATE INDEX idx_vulnerabilities_partial_devops_adoption ON vulnerabilities USING btree (project_id, created_at) WHERE (state <> 1);
+CREATE INDEX idx_vulnerabilities_partial_devops_adoption_and_default_branch ON vulnerabilities USING btree (project_id, created_at, present_on_default_branch) WHERE (state <> 1);
CREATE UNIQUE INDEX idx_vulnerability_ext_issue_links_on_vulne_id_and_ext_issue ON vulnerability_external_issue_links USING btree (vulnerability_id, external_type, external_project_key, external_issue_key);
@@ -27498,9 +27760,9 @@ CREATE INDEX index_bulk_import_failures_on_correlation_id_value ON bulk_import_f
CREATE INDEX index_bulk_imports_on_user_id ON bulk_imports USING btree (user_id);
-CREATE UNIQUE INDEX index_chat_names_on_service_id_and_team_id_and_chat_id ON chat_names USING btree (service_id, team_id, chat_id);
+CREATE UNIQUE INDEX index_chat_names_on_integration_id_and_team_id_and_chat_id ON chat_names USING btree (integration_id, team_id, chat_id);
-CREATE UNIQUE INDEX index_chat_names_on_user_id_and_service_id ON chat_names USING btree (user_id, service_id);
+CREATE UNIQUE INDEX index_chat_names_on_user_id_and_integration_id ON chat_names USING btree (user_id, integration_id);
CREATE UNIQUE INDEX index_chat_teams_on_namespace_id ON chat_teams USING btree (namespace_id);
@@ -27538,8 +27800,6 @@ CREATE INDEX index_ci_builds_on_project_id_and_id ON ci_builds USING btree (proj
CREATE INDEX index_ci_builds_on_project_id_and_name_and_ref ON ci_builds USING btree (project_id, name, ref) WHERE (((type)::text = 'Ci::Build'::text) AND ((status)::text = 'success'::text) AND ((retried = false) OR (retried IS NULL)));
-CREATE INDEX index_ci_builds_on_queued_at ON ci_builds USING btree (queued_at);
-
CREATE INDEX index_ci_builds_on_resource_group_and_status_and_commit_id ON ci_builds USING btree (resource_group_id, status, commit_id) WHERE (resource_group_id IS NOT NULL);
CREATE INDEX index_ci_builds_on_runner_id_and_id_desc ON ci_builds USING btree (runner_id, id DESC);
@@ -27560,8 +27820,6 @@ CREATE INDEX index_ci_builds_on_user_id_and_created_at_and_type_eq_ci_build ON c
CREATE INDEX index_ci_builds_project_id_and_status_for_live_jobs_partial2 ON ci_builds USING btree (project_id, status) WHERE (((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])));
-CREATE INDEX index_ci_builds_runner_id_pending_covering ON ci_builds USING btree (runner_id, id) INCLUDE (project_id) WHERE (((status)::text = 'pending'::text) AND ((type)::text = 'Ci::Build'::text));
-
CREATE INDEX index_ci_builds_runner_id_running ON ci_builds USING btree (runner_id) WHERE (((status)::text = 'running'::text) AND ((type)::text = 'Ci::Build'::text));
CREATE UNIQUE INDEX index_ci_builds_runner_session_on_build_id ON ci_builds_runner_session USING btree (build_id);
@@ -27748,8 +28006,6 @@ CREATE INDEX index_ci_runners_on_created_at_desc_and_id_desc ON ci_runners USING
CREATE INDEX index_ci_runners_on_description_trigram ON ci_runners USING gin (description gin_trgm_ops);
-CREATE INDEX index_ci_runners_on_id_and_semver_cidr ON ci_runners USING btree (id, ((semver)::cidr));
-
CREATE INDEX index_ci_runners_on_locked ON ci_runners USING btree (locked);
CREATE INDEX index_ci_runners_on_runner_type ON ci_runners USING btree (runner_type);
@@ -28494,6 +28750,8 @@ CREATE INDEX index_integrations_on_type_new ON integrations USING btree (type_ne
CREATE INDEX index_integrations_on_type_new_and_instance_partial ON integrations USING btree (type_new, instance) WHERE (instance = true);
+CREATE INDEX index_integrations_on_type_new_id_when_active_and_has_group ON integrations USING btree (type_new, id, inherit_from_id) WHERE ((active = true) AND (group_id IS NOT NULL));
+
CREATE INDEX index_integrations_on_type_new_id_when_active_and_has_project ON integrations USING btree (type_new, id) WHERE ((active = true) AND (project_id IS NOT NULL));
CREATE INDEX index_integrations_on_unique_group_id_and_type_new ON integrations USING btree (group_id, type_new);
@@ -28540,7 +28798,7 @@ CREATE INDEX index_issue_metrics_on_issue_id_and_timestamps ON issue_metrics USI
CREATE INDEX index_issue_on_project_id_state_id_and_blocking_issues_count ON issues USING btree (project_id, state_id, blocking_issues_count);
-CREATE INDEX index_issue_tracker_data_on_service_id ON issue_tracker_data USING btree (service_id);
+CREATE INDEX index_issue_tracker_data_on_integration_id ON issue_tracker_data USING btree (integration_id);
CREATE UNIQUE INDEX index_issue_user_mentions_on_note_id ON issue_user_mentions USING btree (note_id) WHERE (note_id IS NOT NULL);
@@ -28554,6 +28812,8 @@ CREATE INDEX index_issues_on_confidential ON issues USING btree (confidential);
CREATE INDEX index_issues_on_description_trigram ON issues USING gin (description gin_trgm_ops);
+CREATE INDEX index_issues_on_description_trigram_non_latin ON issues USING gin (description gin_trgm_ops) WHERE (((title)::text !~ similar_escape('[\u0000-\u218F]*'::text, NULL::text)) OR (description !~ similar_escape('[\u0000-\u218F]*'::text, NULL::text)));
+
CREATE INDEX index_issues_on_duplicated_to_id ON issues USING btree (duplicated_to_id) WHERE (duplicated_to_id IS NOT NULL);
CREATE INDEX index_issues_on_id_and_weight ON issues USING btree (id, weight);
@@ -28588,6 +28848,8 @@ CREATE INDEX index_issues_on_sprint_id ON issues USING btree (sprint_id);
CREATE INDEX index_issues_on_title_trigram ON issues USING gin (title gin_trgm_ops);
+CREATE INDEX index_issues_on_title_trigram_non_latin ON issues USING gin (title gin_trgm_ops) WHERE (((title)::text !~ similar_escape('[\u0000-\u218F]*'::text, NULL::text)) OR (description !~ similar_escape('[\u0000-\u218F]*'::text, NULL::text)));
+
CREATE INDEX index_issues_on_updated_at ON issues USING btree (updated_at);
CREATE INDEX index_issues_on_updated_by_id ON issues USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL);
@@ -28604,7 +28866,7 @@ CREATE INDEX index_jira_imports_on_project_id_and_jira_project_key ON jira_impor
CREATE INDEX index_jira_imports_on_user_id ON jira_imports USING btree (user_id);
-CREATE INDEX index_jira_tracker_data_on_service_id ON jira_tracker_data USING btree (service_id);
+CREATE INDEX index_jira_tracker_data_on_integration_id ON jira_tracker_data USING btree (integration_id);
CREATE INDEX index_job_artifact_states_failed_verification ON ci_job_artifact_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
@@ -28696,6 +28958,8 @@ CREATE INDEX index_lists_on_user_id ON lists USING btree (user_id);
CREATE INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ON ONLY loose_foreign_keys_deleted_records USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1);
+CREATE INDEX index_member_roles_on_namespace_id ON member_roles USING btree (namespace_id);
+
CREATE INDEX index_member_tasks_on_member_id ON member_tasks USING btree (member_id);
CREATE UNIQUE INDEX index_member_tasks_on_member_id_and_project_id ON member_tasks USING btree (member_id, project_id);
@@ -28712,6 +28976,8 @@ CREATE UNIQUE INDEX index_members_on_invite_token ON members USING btree (invite
CREATE INDEX index_members_on_member_namespace_id ON members USING btree (member_namespace_id);
+CREATE INDEX index_members_on_member_role_id ON members USING btree (member_role_id);
+
CREATE INDEX index_members_on_non_requested_non_invited_and_state_awaiting ON members USING btree (source_id) WHERE ((requested_at IS NULL) AND (invite_token IS NULL) AND (access_level > 5) AND (state = 1));
CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at);
@@ -28870,6 +29136,20 @@ CREATE INDEX index_milestones_on_title_trigram ON milestones USING gin (title gi
CREATE INDEX index_mirror_data_non_scheduled_or_started ON project_mirror_data USING btree (next_execution_timestamp, retry_count) WHERE ((status)::text <> ALL ('{scheduled,started}'::text[]));
+CREATE INDEX index_ml_candidate_metrics_on_candidate_id ON ml_candidate_metrics USING btree (candidate_id);
+
+CREATE INDEX index_ml_candidate_params_on_candidate_id ON ml_candidate_params USING btree (candidate_id);
+
+CREATE UNIQUE INDEX index_ml_candidates_on_experiment_id_and_iid ON ml_candidates USING btree (experiment_id, iid);
+
+CREATE INDEX index_ml_candidates_on_user_id ON ml_candidates USING btree (user_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 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));
@@ -29212,6 +29492,8 @@ CREATE INDEX index_path_locks_on_user_id ON path_locks USING btree (user_id);
CREATE INDEX index_pe_approval_rules_on_required_approvals_and_created_at ON protected_environment_approval_rules USING btree (required_approvals, created_at);
+CREATE INDEX index_personal_access_tokens_on_id_and_created_at ON personal_access_tokens USING btree (id, created_at);
+
CREATE UNIQUE INDEX index_personal_access_tokens_on_token_digest ON personal_access_tokens USING btree (token_digest);
CREATE INDEX index_personal_access_tokens_on_user_id ON personal_access_tokens USING btree (user_id);
@@ -29318,6 +29600,8 @@ CREATE UNIQUE INDEX index_project_repository_states_on_project_id ON project_rep
CREATE INDEX index_project_repository_storage_moves_on_project_id ON project_repository_storage_moves USING btree (project_id);
+CREATE INDEX index_project_settings_on_legacy_open_source_license_available ON project_settings USING btree (legacy_open_source_license_available) WHERE (legacy_open_source_license_available = true);
+
CREATE INDEX index_project_settings_on_project_id_partially ON project_settings USING btree (project_id) WHERE (has_vulnerabilities IS TRUE);
CREATE UNIQUE INDEX index_project_settings_on_push_rule_id ON project_settings USING btree (push_rule_id);
@@ -29342,6 +29626,8 @@ CREATE UNIQUE INDEX index_project_topics_on_project_id_and_topic_id ON project_t
CREATE INDEX index_project_topics_on_topic_id ON project_topics USING btree (topic_id);
+CREATE UNIQUE INDEX index_project_user_callouts_feature ON user_project_callouts USING btree (user_id, feature_name, 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));
CREATE INDEX index_projects_api_created_at_id_desc ON projects USING btree (created_at, id DESC);
@@ -29630,6 +29916,8 @@ CREATE UNIQUE INDEX index_saved_replies_on_name_text_pattern_ops ON saved_replie
CREATE INDEX index_sbom_component_versions_on_component_id ON sbom_component_versions USING btree (component_id);
+CREATE INDEX index_sbom_occurrences_on_component_id ON sbom_occurrences USING btree (component_id);
+
CREATE INDEX index_sbom_occurrences_on_component_version_id ON sbom_occurrences USING btree (component_version_id);
CREATE INDEX index_sbom_occurrences_on_pipeline_id ON sbom_occurrences USING btree (pipeline_id);
@@ -29662,7 +29950,7 @@ CREATE INDEX index_security_findings_on_scanner_id ON security_findings USING bt
CREATE INDEX index_security_findings_on_severity ON security_findings USING btree (severity);
-CREATE UNIQUE INDEX index_security_findings_on_uuid_and_scan_id ON security_findings USING btree (uuid, scan_id);
+CREATE UNIQUE INDEX index_security_findings_on_unique_columns ON security_findings USING btree (uuid, scan_id, partition_number);
CREATE INDEX index_security_scans_on_created_at ON security_scans USING btree (created_at);
@@ -29706,7 +29994,7 @@ CREATE UNIQUE INDEX index_shards_on_name ON shards USING btree (name);
CREATE UNIQUE INDEX index_site_profile_secret_variables_on_site_profile_id_and_key ON dast_site_profile_secret_variables USING btree (dast_site_profile_id, key);
-CREATE INDEX index_slack_integrations_on_service_id ON slack_integrations USING btree (service_id);
+CREATE INDEX index_slack_integrations_on_integration_id ON slack_integrations USING btree (integration_id);
CREATE UNIQUE INDEX index_slack_integrations_on_team_id_and_alias ON slack_integrations USING btree (team_id, alias);
@@ -29978,6 +30266,8 @@ CREATE INDEX index_user_preferences_on_gitpod_enabled ON user_preferences USING
CREATE UNIQUE INDEX index_user_preferences_on_user_id ON user_preferences USING btree (user_id);
+CREATE INDEX index_user_project_callouts_on_project_id ON user_project_callouts USING btree (project_id);
+
CREATE INDEX index_user_statuses_on_clear_status_at_not_null ON user_statuses USING btree (clear_status_at) WHERE (clear_status_at IS NOT NULL);
CREATE INDEX index_user_statuses_on_user_id ON user_statuses USING btree (user_id);
@@ -30054,9 +30344,11 @@ CREATE UNIQUE INDEX index_vuln_historical_statistics_on_project_id_and_date ON v
CREATE INDEX index_vuln_reads_on_casted_cluster_agent_id_where_it_is_null ON vulnerability_reads USING btree (casted_cluster_agent_id) WHERE (casted_cluster_agent_id IS NOT NULL);
+CREATE INDEX index_vuln_reads_on_namespace_id_state_severity_and_vuln_id ON vulnerability_reads USING btree (namespace_id, state, severity, vulnerability_id DESC);
+
CREATE INDEX index_vuln_reads_on_project_id_state_severity_and_vuln_id ON vulnerability_reads USING btree (project_id, state, severity, vulnerability_id DESC);
-CREATE INDEX index_vulnerabilites_common_finder_query ON vulnerabilities USING btree (project_id, state, report_type, severity, id);
+CREATE INDEX index_vulnerabilities_common_finder_query_on_default_branch ON vulnerabilities USING btree (project_id, state, report_type, present_on_default_branch, severity, id);
CREATE INDEX index_vulnerabilities_on_author_id ON vulnerabilities USING btree (author_id);
@@ -30072,8 +30364,6 @@ CREATE INDEX index_vulnerabilities_on_last_edited_by_id ON vulnerabilities USING
CREATE INDEX index_vulnerabilities_on_milestone_id ON vulnerabilities USING btree (milestone_id);
-CREATE INDEX index_vulnerabilities_on_project_id_and_id ON vulnerabilities USING btree (project_id, id);
-
CREATE INDEX index_vulnerabilities_on_project_id_and_id_active_cis ON vulnerabilities USING btree (project_id, id) WHERE ((report_type = 7) AND (state = ANY (ARRAY[1, 4])));
CREATE INDEX index_vulnerabilities_on_project_id_and_state_and_severity ON vulnerabilities USING btree (project_id, state, severity);
@@ -30088,6 +30378,10 @@ CREATE INDEX index_vulnerabilities_on_state_case_id_desc ON vulnerabilities USIN
CREATE INDEX index_vulnerabilities_on_updated_by_id ON vulnerabilities USING btree (updated_by_id);
+CREATE INDEX index_vulnerabilities_project_id_and_id_on_default_branch ON vulnerabilities USING btree (project_id, id) WHERE (present_on_default_branch IS TRUE);
+
+CREATE INDEX index_vulnerabilities_project_id_state_severity_default_branch ON vulnerabilities USING btree (project_id, state, severity, present_on_default_branch);
+
CREATE INDEX index_vulnerability_exports_on_author_id ON vulnerability_exports USING btree (author_id);
CREATE INDEX index_vulnerability_exports_on_file_store ON vulnerability_exports USING btree (file_store);
@@ -30150,8 +30444,6 @@ CREATE INDEX index_vulnerability_occurrences_on_location_k8s_agent_id ON vulnera
CREATE INDEX index_vulnerability_occurrences_on_location_k8s_cluster_id ON vulnerability_occurrences USING gin ((((location -> 'kubernetes_resource'::text) -> 'cluster_id'::text))) WHERE (report_type = 7);
-CREATE INDEX index_vulnerability_occurrences_on_migrated_to_new_structure ON vulnerability_occurrences USING btree (migrated_to_new_structure, id);
-
CREATE INDEX index_vulnerability_occurrences_on_primary_identifier_id ON vulnerability_occurrences USING btree (primary_identifier_id);
CREATE INDEX index_vulnerability_occurrences_on_project_fingerprint ON vulnerability_occurrences USING btree (project_fingerprint);
@@ -30164,6 +30456,8 @@ CREATE INDEX index_vulnerability_occurrences_on_vulnerability_id ON vulnerabilit
CREATE INDEX index_vulnerability_reads_common_finder_query ON vulnerability_reads USING btree (project_id, state, report_type, severity, vulnerability_id DESC);
+CREATE INDEX index_vulnerability_reads_common_finder_query_with_namespace_id ON vulnerability_reads USING btree (namespace_id, state, report_type, severity, vulnerability_id DESC);
+
CREATE INDEX index_vulnerability_reads_on_cluster_agent_id ON vulnerability_reads USING btree (cluster_agent_id) WHERE (report_type = 7);
CREATE INDEX index_vulnerability_reads_on_location_image ON vulnerability_reads USING btree (location_image) WHERE (report_type = ANY (ARRAY[2, 7]));
@@ -30182,6 +30476,8 @@ CREATE UNIQUE INDEX index_vulnerability_scanners_on_project_id_and_external_id O
CREATE INDEX index_vulnerability_state_transitions_id_and_vulnerability_id ON vulnerability_state_transitions USING btree (vulnerability_id, id);
+CREATE INDEX index_vulnerability_state_transitions_on_author_id ON vulnerability_state_transitions USING btree (author_id);
+
CREATE INDEX index_vulnerability_statistics_on_latest_pipeline_id ON vulnerability_statistics USING btree (latest_pipeline_id);
CREATE INDEX index_vulnerability_statistics_on_letter_grade ON vulnerability_statistics USING btree (letter_grade);
@@ -30308,12 +30604,12 @@ CREATE INDEX tmp_index_ci_job_artifacts_on_expire_at_where_locked_unknown ON ci_
CREATE INDEX tmp_index_ci_job_artifacts_on_id_where_trace_and_expire_at ON ci_job_artifacts USING btree (id) WHERE ((file_type = 3) AND (expire_at = ANY (ARRAY['2021-04-22 00:00:00+00'::timestamp with time zone, '2021-05-22 00:00:00+00'::timestamp with time zone, '2021-06-22 00:00:00+00'::timestamp with time zone, '2022-01-22 00:00:00+00'::timestamp with time zone, '2022-02-22 00:00:00+00'::timestamp with time zone, '2022-03-22 00:00:00+00'::timestamp with time zone, '2022-04-22 00:00:00+00'::timestamp with time zone])));
+CREATE INDEX tmp_index_cis_vulnerability_reads_on_id ON vulnerability_reads USING btree (id) WHERE (report_type = 7);
+
CREATE INDEX tmp_index_container_repositories_on_id_migration_state ON container_repositories USING btree (id, migration_state);
CREATE INDEX tmp_index_for_namespace_id_migration_on_group_members ON members USING btree (id) WHERE ((member_namespace_id IS NULL) AND ((type)::text = 'GroupMember'::text));
-CREATE INDEX tmp_index_for_namespace_id_migration_on_project_members ON members USING btree (id) WHERE ((member_namespace_id IS NULL) AND ((type)::text = 'ProjectMember'::text));
-
CREATE INDEX tmp_index_for_null_project_namespace_id ON projects USING btree (id) WHERE (project_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));
@@ -30332,6 +30628,10 @@ CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING
CREATE INDEX tmp_index_project_statistics_cont_registry_size ON project_statistics USING btree (project_id) WHERE (container_registry_size = 0);
+CREATE INDEX tmp_index_todos_attention_request_action ON todos USING btree (id) WHERE (action = 10);
+
+CREATE INDEX tmp_index_vulnerability_occurrences_on_id_and_scanner_id ON vulnerability_occurrences USING btree (id, scanner_id) WHERE (report_type = ANY (ARRAY[7, 99]));
+
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);
@@ -31690,6 +31990,14 @@ CREATE TRIGGER trigger_projects_parent_id_on_insert AFTER INSERT ON projects FOR
CREATE TRIGGER trigger_projects_parent_id_on_update AFTER UPDATE ON projects FOR EACH ROW WHEN ((old.namespace_id IS DISTINCT FROM new.namespace_id)) EXECUTE FUNCTION insert_projects_sync_event();
+CREATE TRIGGER trigger_update_details_on_namespace_insert AFTER INSERT ON namespaces FOR EACH ROW WHEN (((new.type)::text <> 'Project'::text)) EXECUTE FUNCTION update_namespace_details_from_namespaces();
+
+CREATE TRIGGER trigger_update_details_on_namespace_update AFTER UPDATE ON namespaces FOR EACH ROW WHEN ((((new.type)::text <> 'Project'::text) AND (((old.description)::text IS DISTINCT FROM (new.description)::text) OR (old.description_html IS DISTINCT FROM new.description_html) OR (old.cached_markdown_version IS DISTINCT FROM new.cached_markdown_version)))) EXECUTE FUNCTION update_namespace_details_from_namespaces();
+
+CREATE TRIGGER trigger_update_details_on_project_insert AFTER INSERT ON projects FOR EACH ROW EXECUTE FUNCTION update_namespace_details_from_projects();
+
+CREATE TRIGGER trigger_update_details_on_project_update AFTER UPDATE ON projects FOR EACH ROW WHEN (((old.description IS DISTINCT FROM new.description) OR (old.description_html IS DISTINCT FROM new.description_html) OR (old.cached_markdown_version IS DISTINCT FROM new.cached_markdown_version))) EXECUTE FUNCTION update_namespace_details_from_projects();
+
CREATE TRIGGER trigger_update_has_issues_on_vulnerability_issue_links_delete AFTER DELETE ON vulnerability_issue_links FOR EACH ROW EXECUTE FUNCTION unset_has_issues_on_vulnerability_reads();
CREATE TRIGGER trigger_update_has_issues_on_vulnerability_issue_links_update AFTER INSERT ON vulnerability_issue_links FOR EACH ROW EXECUTE FUNCTION set_has_issues_on_vulnerability_reads();
@@ -31700,9 +32008,6 @@ CREATE TRIGGER trigger_update_vulnerability_reads_on_vulnerability_update AFTER
CREATE TRIGGER users_loose_fk_trigger AFTER DELETE ON users REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
-ALTER TABLE ONLY chat_names
- ADD CONSTRAINT fk_00797a2bf9 FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY deployments
ADD CONSTRAINT fk_009fd21147 FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE NOT VALID;
@@ -31880,6 +32185,12 @@ ALTER TABLE ONLY approvals
ALTER TABLE ONLY namespaces
ADD CONSTRAINT fk_319256d87a FOREIGN KEY (file_template_project_id) REFERENCES projects(id) ON DELETE SET NULL;
+ALTER TABLE ONLY issue_tracker_data
+ ADD CONSTRAINT fk_33921c0ee1 FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY user_project_callouts
+ ADD CONSTRAINT fk_33b4814f6b FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY namespaces
ADD CONSTRAINT fk_3448c97865 FOREIGN KEY (push_rule_id) REFERENCES push_rules(id) ON DELETE SET NULL;
@@ -31956,6 +32267,9 @@ ALTER TABLE ONLY sbom_occurrences
ADD CONSTRAINT fk_4b88e5b255 FOREIGN KEY (component_version_id) REFERENCES sbom_component_versions(id) ON DELETE CASCADE;
ALTER TABLE ONLY vulnerability_reads
+ ADD CONSTRAINT fk_4f593f6c62 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY vulnerability_reads
ADD CONSTRAINT fk_5001652292 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY alert_management_alerts
@@ -31979,6 +32293,9 @@ ALTER TABLE ONLY merge_request_metrics
ALTER TABLE ONLY vulnerability_feedback
ADD CONSTRAINT fk_563ff1912e FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE SET NULL;
+ALTER TABLE ONLY ml_candidates
+ ADD CONSTRAINT fk_56d6ed4d3d FOREIGN KEY (experiment_id) REFERENCES ml_experiments(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY deploy_keys_projects
ADD CONSTRAINT fk_58a901ca7e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -31988,6 +32305,9 @@ ALTER TABLE ONLY dast_scanner_profiles_builds
ALTER TABLE ONLY issue_assignees
ADD CONSTRAINT fk_5e0c8d9154 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+ALTER TABLE ONLY members
+ ADD CONSTRAINT fk_5e12d50db3 FOREIGN KEY (member_role_id) REFERENCES member_roles(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY csv_issue_imports
ADD CONSTRAINT fk_5e1572387c FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -32195,6 +32515,9 @@ ALTER TABLE ONLY vulnerability_occurrences
ALTER TABLE ONLY protected_branch_merge_access_levels
ADD CONSTRAINT fk_98f3d044fe FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY chat_names
+ ADD CONSTRAINT fk_99a1348daf FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY notes
ADD CONSTRAINT fk_99e097b079 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -32270,6 +32593,9 @@ ALTER TABLE ONLY member_tasks
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_ad525e1f87 FOREIGN KEY (merge_user_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY ml_experiments
+ ADD CONSTRAINT fk_ad89c59858 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY merge_request_metrics
ADD CONSTRAINT fk_ae440388cc FOREIGN KEY (latest_closed_by_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -32387,12 +32713,18 @@ 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 jira_tracker_data
+ ADD CONSTRAINT fk_c98abcd54c FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY external_approval_rules_protected_branches
ADD CONSTRAINT fk_c9a037a926 FOREIGN KEY (external_approval_rule_id) REFERENCES external_approval_rules(id) ON DELETE CASCADE;
ALTER TABLE ONLY external_approval_rules_protected_branches
ADD CONSTRAINT fk_ca2ffb55e6 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE;
+ALTER TABLE ONLY slack_integrations
+ ADD CONSTRAINT fk_cbe270434e FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY external_status_checks_protected_branches
ADD CONSTRAINT fk_cc0dcc36d1 FOREIGN KEY (external_status_check_id) REFERENCES external_status_checks(id) ON DELETE CASCADE;
@@ -32450,6 +32782,9 @@ ALTER TABLE ONLY ci_pipelines
ALTER TABLE ONLY system_note_metadata
ADD CONSTRAINT fk_d83a918cb1 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE;
+ALTER TABLE ONLY sbom_occurrences
+ ADD CONSTRAINT fk_d857c6edc1 FOREIGN KEY (component_id) REFERENCES sbom_components(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY todos
ADD CONSTRAINT fk_d94154aa95 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -32489,6 +32824,9 @@ ALTER TABLE ONLY gitlab_subscriptions
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_e719a85f8a FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY vulnerability_state_transitions
+ ADD CONSTRAINT fk_e719dc63df FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY issue_links
ADD CONSTRAINT fk_e71bb44f1f FOREIGN KEY (target_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -32561,6 +32899,9 @@ ALTER TABLE ONLY analytics_devops_adoption_segments
ALTER TABLE ONLY boards_epic_list_user_preferences
ADD CONSTRAINT fk_f5f2fe5c1f FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+ALTER TABLE ONLY user_project_callouts
+ ADD CONSTRAINT fk_f62dd11a33 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY cluster_agents
ADD CONSTRAINT fk_f7d43dee13 FOREIGN KEY (created_by_user_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -32765,6 +33106,9 @@ 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;
@@ -32792,6 +33136,9 @@ 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;
@@ -33326,9 +33673,6 @@ ALTER TABLE ONLY dast_scanner_profiles
ALTER TABLE ONLY vulnerability_historical_statistics
ADD CONSTRAINT fk_rails_72b73ed023 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-ALTER TABLE ONLY slack_integrations
- ADD CONSTRAINT fk_rails_73db19721a FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY custom_emoji
ADD CONSTRAINT fk_rails_745925b412 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -33617,9 +33961,6 @@ ALTER TABLE ONLY vulnerability_user_mentions
ALTER TABLE ONLY todos
ADD CONSTRAINT fk_rails_a27c483435 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
-ALTER TABLE ONLY jira_tracker_data
- ADD CONSTRAINT fk_rails_a299066916 FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY protected_environments
ADD CONSTRAINT fk_rails_a354313d11 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -33875,21 +34216,24 @@ ALTER TABLE ONLY boards_epic_board_positions
ALTER TABLE ONLY vulnerability_finding_links
ADD CONSTRAINT fk_rails_cbdfde27ce FOREIGN KEY (vulnerability_occurrence_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE;
+ALTER TABLE ONLY namespace_details
+ ADD CONSTRAINT fk_rails_cc11a451f8 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY issues_self_managed_prometheus_alert_events
ADD CONSTRAINT fk_rails_cc5d88bbb0 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
ALTER TABLE ONLY operations_strategies_user_lists
ADD CONSTRAINT fk_rails_ccb7e4bc0b FOREIGN KEY (user_list_id) REFERENCES operations_user_lists(id) ON DELETE CASCADE;
-ALTER TABLE ONLY issue_tracker_data
- ADD CONSTRAINT fk_rails_ccc0840427 FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY resource_milestone_events
ADD CONSTRAINT fk_rails_cedf8cce4d FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY resource_iteration_events
ADD CONSTRAINT fk_rails_cee126f66c FOREIGN KEY (iteration_id) REFERENCES sprints(id) ON DELETE CASCADE;
+ALTER TABLE ONLY member_roles
+ ADD CONSTRAINT fk_rails_cf0ee35814 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY upload_states
ADD CONSTRAINT fk_rails_d00f153613 FOREIGN KEY (upload_id) REFERENCES uploads(id) ON DELETE CASCADE;
@@ -33926,6 +34270,9 @@ ALTER TABLE ONLY alert_management_alert_assignees
ALTER TABLE ONLY geo_hashed_storage_attachments_events
ADD CONSTRAINT fk_rails_d496b088e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_candidate_params
+ ADD CONSTRAINT fk_rails_d4a51d1185 FOREIGN KEY (candidate_id) REFERENCES ml_candidates(id);
+
ALTER TABLE ONLY merge_request_reviewers
ADD CONSTRAINT fk_rails_d9fec24b9d FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
@@ -34073,6 +34420,9 @@ ALTER TABLE ONLY project_relation_exports
ALTER TABLE ONLY label_priorities
ADD CONSTRAINT fk_rails_ef916d14fa FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ml_candidate_metrics
+ ADD CONSTRAINT fk_rails_efb613a25a FOREIGN KEY (candidate_id) REFERENCES ml_candidates(id);
+
ALTER TABLE ONLY fork_network_members
ADD CONSTRAINT fk_rails_efccadc4ec FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;