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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 18:40:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 18:40:28 +0300
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /db
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'db')
-rw-r--r--db/docs/broadcast_messages.yml4
-rw-r--r--db/docs/ci_job_token_project_scope_links.yml4
-rw-r--r--db/docs/ci_runner_versions.yml9
-rw-r--r--db/docs/ci_secure_file_states.yml9
-rw-r--r--db/docs/clusters_applications_elastic_stacks.yml9
-rw-r--r--db/docs/clusters_integration_elasticstack.yml9
-rw-r--r--db/docs/namespace_bans.yml9
-rw-r--r--db/docs/project_relation_export_uploads.yml9
-rw-r--r--db/docs/project_relation_exports.yml9
-rw-r--r--db/docs/project_tracing_settings.yml9
-rw-r--r--db/docs/sbom_component_versions.yml11
-rw-r--r--db/docs/sbom_components.yml11
-rw-r--r--db/docs/sbom_occurrences.yml11
-rw-r--r--db/docs/sbom_sources.yml11
-rw-r--r--db/docs/user_namespace_callouts.yml10
-rw-r--r--db/docs/vulnerability_merge_request_links.yml9
-rw-r--r--db/fixtures/development/06_teams.rb2
-rw-r--r--db/fixtures/development/33_triage_ops.rb48
-rw-r--r--db/migrate/20220523162734_add_vulnerability_reads_casted_cluster_agent_column.rb9
-rw-r--r--db/migrate/20220523163734_update_vulnerability_reads_trigger_functions.rb81
-rw-r--r--db/migrate/20220524164122_limit_project_and_group_variables.rb8
-rw-r--r--db/migrate/20220531024905_add_operations_access_levels_to_project_feature.rb24
-rw-r--r--db/migrate/20220531140515_add_applies_to_all_protected_branches_to_approval_project_rule.rb7
-rw-r--r--db/migrate/20220608074738_add_max_repository_downloads_limit_to_application_settings.rb15
-rw-r--r--db/migrate/20220610140605_change_public_projects_cost_factor.rb35
-rw-r--r--db/migrate/20220613054349_add_unique_project_download_limit_settings_to_namespace_settings.rb12
-rw-r--r--db/migrate/20220614120415_add_toggle_opt_in_jwt.rb7
-rw-r--r--db/migrate/20220616182001_create_sbom_components.rb11
-rw-r--r--db/migrate/20220616182015_create_sbom_component_versions.rb15
-rw-r--r--db/migrate/20220616182016_create_sbom_sources.rb12
-rw-r--r--db/migrate/20220616182038_create_sbom_occurrences.rb14
-rw-r--r--db/migrate/20220616183240_add_sbom_component_versions_foreign_key_to_sbom_occurrences.rb18
-rw-r--r--db/migrate/20220616183309_add_sbom_source_foreign_key_to_sbom_occurrences.rb15
-rw-r--r--db/migrate/20220616183310_add_project_foreign_key_to_sbom_occurrences.rb15
-rw-r--r--db/migrate/20220617123135_drop_temp_index_on_projects_on_id_and_runners_token.rb21
-rw-r--r--db/migrate/20220617123144_drop_temp_index_on_projects_on_id_and_runners_token_encrypted.rb21
-rw-r--r--db/migrate/20220617141347_create_ci_secure_file_states.rb34
-rw-r--r--db/migrate/20220619182308_create_project_relation_exports.rb20
-rw-r--r--db/migrate/20220619184931_create_project_relation_export_uploads.rb15
-rw-r--r--db/migrate/20220621202616_add_partial_index_on_oauth_access_tokens_revoked_at.rb19
-rw-r--r--db/migrate/20220624081524_add_ci_runner_versions_table.rb16
-rw-r--r--db/migrate/20220624090458_add_index_on_runner_version.rb15
-rw-r--r--db/migrate/20220627061008_add_fei_shu_integration.rb12
-rw-r--r--db/migrate/20220627122229_create_user_namespace_callouts.rb16
-rw-r--r--db/migrate/20220627122230_add_foreign_keys_to_user_namespace_callouts.rb28
-rw-r--r--db/migrate/20220627140315_add_last_feature_flag_updated_at_to_operations_feature_flags_clients.rb7
-rw-r--r--db/migrate/20220627171538_add_error_tracking_settings.rb21
-rw-r--r--db/migrate/20220628110214_add_namespace_id_column_to_issues_table.rb13
-rw-r--r--db/migrate/20220628120708_create_namespace_bans.rb15
-rw-r--r--db/migrate/20220628121644_add_namespace_bans_namespace_id_foreign_key.rb15
-rw-r--r--db/migrate/20220628121712_add_namespace_bans_user_id_foreign_key.rb15
-rw-r--r--db/migrate/20220629220129_increase_webauthn_xid_length.rb17
-rw-r--r--db/migrate/20220630202329_add_partial_index_on_oauth_access_tokens_revoked_at_with_order.rb20
-rw-r--r--db/migrate/20220701173859_remove_not_null_constraints_from_requirements.rb19
-rw-r--r--db/migrate/20220703182234_add_findings_partition_number_to_security_scans.rb9
-rw-r--r--db/migrate/20220703182254_add_partition_number_to_security_findings.rb9
-rw-r--r--db/migrate/20220704034050_add_users_allowlist_to_git_rate_limits.rb11
-rw-r--r--db/migrate/20220704034105_add_application_settings_git_users_allowlist_max_usernames_constraint.rb15
-rw-r--r--db/migrate/20220705145349_add_project_import_level_to_namespace_settings.rb9
-rw-r--r--db/migrate/20220706191627_add_encrypted_error_tracking_access_token.rb17
-rw-r--r--db/migrate/20220708100532_add_unique_index_on_ci_runner_versions_on_status_and_version.rb15
-rw-r--r--db/migrate/20220708132701_create_vulnerability_merge_request_links.rb29
-rw-r--r--db/migrate/20220708142744_add_composite_index_for_protected_environments.rb16
-rw-r--r--db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb16
-rw-r--r--db/migrate/20220708150315_add_vulnerabilities_foreign_key_to_vulnerability_merge_request_links.rb16
-rw-r--r--db/migrate/20220708150335_add_merge_requests_foreign_key_to_vulnerability_merge_request_links.rb16
-rw-r--r--db/migrate/20220708184822_cleanup_backfill_draft_status_on_merge_requests.rb14
-rw-r--r--db/migrate/20220712025712_update_insert_or_update_vulnerability_reads_function.rb86
-rw-r--r--db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb56
-rw-r--r--db/migrate/20220712094945_add_include_for_free_user_cap_preview_to_namespace_settings.rb13
-rw-r--r--db/migrate/20220713175658_add_packages_cleanup_policies_worker_capacity_to_application_settings.rb11
-rw-r--r--db/migrate/20220713175737_add_application_settings_packages_cleanup_policies_worker_capacity_constraint.rb17
-rw-r--r--db/migrate/20220713175812_add_enabled_policies_index_to_packages_cleanup_policies.rb18
-rw-r--r--db/migrate/20220714105122_update_default_project_import_level_on_namespace_settings.rb13
-rw-r--r--db/migrate/20220714142424_update_trigger_update_vulnerability_reads_on_vulnerability_update.rb48
-rw-r--r--db/post_migrate/20220523164734_add_foreign_key_to_vulnerability_reads_casted_cluster_agent_id.rb16
-rw-r--r--db/post_migrate/20220523165734_add_index_to_vulnerability_reads_casted_cluster_agent_id.rb15
-rw-r--r--db/post_migrate/20220531035113_populate_operation_visibility_permissions.rb29
-rw-r--r--db/post_migrate/20220601151900_schedule_backfill_ci_runner_semver.rb31
-rw-r--r--db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb18
-rw-r--r--db/post_migrate/20220606082910_add_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb20
-rw-r--r--db/post_migrate/20220617123022_add_unique_index_on_projects_on_runners_token.rb18
-rw-r--r--db/post_migrate/20220617123034_add_unique_index_on_projects_on_runners_token_encrypted.rb18
-rw-r--r--db/post_migrate/20220617123105_drop_index_on_projects_on_runners_token.rb17
-rw-r--r--db/post_migrate/20220617123113_drop_index_on_projects_on_runners_token_encrypted.rb17
-rw-r--r--db/post_migrate/20220617142124_add_index_on_installable_package_files.rb20
-rw-r--r--db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb22
-rw-r--r--db/post_migrate/20220620060633_finalize_orphaned_routes_cleanup.rb22
-rw-r--r--db/post_migrate/20220620132300_update_last_run_date_for_iterations_cadences.rb19
-rw-r--r--db/post_migrate/20220620151740_add_indexes_issues_on_project_id_and_closed_at.rb31
-rw-r--r--db/post_migrate/20220621040800_backfill_imported_issue_search_data.rb11
-rw-r--r--db/post_migrate/20220621082245_remove_tmp_index_on_routes_namespace_id_column.rb18
-rw-r--r--db/post_migrate/20220621092245_validate_not_null_constraint_on_routes_namespace_id_column.rb14
-rw-r--r--db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb22
-rw-r--r--db/post_migrate/20220622080547_backfill_project_statistics_with_container_registry_size.rb33
-rw-r--r--db/post_migrate/20220624062300_delete_backfill_ci_runner_semver_migration.rb19
-rw-r--r--db/post_migrate/20220627090231_schedule_disable_legacy_open_source_license_for_inactive_public_projects.rb33
-rw-r--r--db/post_migrate/20220627152642_queue_update_delayed_project_removal_to_null_for_user_namespace.rb25
-rw-r--r--db/post_migrate/20220627223041_add_post_migrate_test_table.rb13
-rw-r--r--db/post_migrate/20220628012902_finalise_project_namespace_members.rb22
-rw-r--r--db/post_migrate/20220628110823_add_issues_namespace_id_fk_and_index.rb22
-rw-r--r--db/post_migrate/20220628111752_drop_token_index_from_ci_builds.rb17
-rw-r--r--db/post_migrate/20220628122622_rename_builds_sidekiq_queues_to_namespaces.rb22
-rw-r--r--db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb46
-rw-r--r--db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb18
-rw-r--r--db/post_migrate/20220630085003_drop_project_successfull_pages_deploy_index_from_ci_builds.rb21
-rw-r--r--db/post_migrate/20220630091409_add_index_on_events_for_contribution_analytics_optimization.rb15
-rw-r--r--db/post_migrate/20220630151641_schedule_set_correct_vulnerability_state.rb29
-rw-r--r--db/post_migrate/20220701085523_schedule_index_on_events_for_contribution_analytics_optimization.rb13
-rw-r--r--db/post_migrate/20220703182314_add_check_constraint_for_security_findings_partition_number.rb15
-rw-r--r--db/post_migrate/20220704044408_remove_foreign_key_in_project_tracing_settings.rb16
-rw-r--r--db/post_migrate/20220704045440_drop_project_tracing_settings_table.rb17
-rw-r--r--db/post_migrate/20220705114635_drop_index_on_ci_runner_versions_on_version.rb15
-rw-r--r--db/post_migrate/20220705180843_validate_requirements_issue_id_not_null.rb15
-rw-r--r--db/post_migrate/20220706065245_remove_foreign_key_in_clusters_applications_elastic_stacks.rb16
-rw-r--r--db/post_migrate/20220706065611_remove_foreign_key_in_clusters_integration_elasticstack.rb16
-rw-r--r--db/post_migrate/20220706070804_drop_clusters_applications_elastic_stacks_table.rb17
-rw-r--r--db/post_migrate/20220706071304_drop_clusters_integration_elasticstack_table.rb22
-rw-r--r--db/post_migrate/20220706115138_create_async_index_on_security_findings.rb22
-rw-r--r--db/post_migrate/20220706122719_create_index_on_security_findings_uuid_id_desc.rb23
-rw-r--r--db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb27
-rw-r--r--db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb35
-rw-r--r--db/post_migrate/20220708100508_drop_index_on_ci_runner_versions_on_status.rb15
-rw-r--r--db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb15
-rw-r--r--db/post_migrate/20220714122311_add_async_index_on_security_findings_id_and_partition_number.rb15
-rw-r--r--db/post_migrate/20220714122418_add_async_index_on_security_findings_unique_columns.rb15
-rw-r--r--db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb19
-rw-r--r--db/post_migrate/20220715160023_drop_post_migration_test_table.rb13
-rw-r--r--db/post_migrate/20220715163254_update_notes_in_past.rb22
-rw-r--r--db/schema_migrations/202205231627341
-rw-r--r--db/schema_migrations/202205231637341
-rw-r--r--db/schema_migrations/202205231647341
-rw-r--r--db/schema_migrations/202205231657341
-rw-r--r--db/schema_migrations/202205241641221
-rw-r--r--db/schema_migrations/202205310249051
-rw-r--r--db/schema_migrations/202205310351131
-rw-r--r--db/schema_migrations/202205311405151
-rw-r--r--db/schema_migrations/202206011519001
-rw-r--r--db/schema_migrations/202206011529161
-rw-r--r--db/schema_migrations/202206060829101
-rw-r--r--db/schema_migrations/202206080747381
-rw-r--r--db/schema_migrations/202206101406051
-rw-r--r--db/schema_migrations/202206130543491
-rw-r--r--db/schema_migrations/202206141204151
-rw-r--r--db/schema_migrations/202206161820011
-rw-r--r--db/schema_migrations/202206161820151
-rw-r--r--db/schema_migrations/202206161820161
-rw-r--r--db/schema_migrations/202206161820381
-rw-r--r--db/schema_migrations/202206161832401
-rw-r--r--db/schema_migrations/202206161833091
-rw-r--r--db/schema_migrations/202206161833101
-rw-r--r--db/schema_migrations/202206171230221
-rw-r--r--db/schema_migrations/202206171230341
-rw-r--r--db/schema_migrations/202206171231051
-rw-r--r--db/schema_migrations/202206171231131
-rw-r--r--db/schema_migrations/202206171231351
-rw-r--r--db/schema_migrations/202206171231441
-rw-r--r--db/schema_migrations/202206171413471
-rw-r--r--db/schema_migrations/202206171421241
-rw-r--r--db/schema_migrations/202206171432281
-rw-r--r--db/schema_migrations/202206191823081
-rw-r--r--db/schema_migrations/202206191849311
-rw-r--r--db/schema_migrations/202206200606331
-rw-r--r--db/schema_migrations/202206201323001
-rw-r--r--db/schema_migrations/202206201517401
-rw-r--r--db/schema_migrations/202206210408001
-rw-r--r--db/schema_migrations/202206210822451
-rw-r--r--db/schema_migrations/202206210922451
-rw-r--r--db/schema_migrations/202206212026161
-rw-r--r--db/schema_migrations/202206220705471
-rw-r--r--db/schema_migrations/202206220805471
-rw-r--r--db/schema_migrations/202206240623001
-rw-r--r--db/schema_migrations/202206240815241
-rw-r--r--db/schema_migrations/202206240904581
-rw-r--r--db/schema_migrations/202206270610081
-rw-r--r--db/schema_migrations/202206270902311
-rw-r--r--db/schema_migrations/202206271222291
-rw-r--r--db/schema_migrations/202206271222301
-rw-r--r--db/schema_migrations/202206271403151
-rw-r--r--db/schema_migrations/202206271526421
-rw-r--r--db/schema_migrations/202206271715381
-rw-r--r--db/schema_migrations/202206272230411
-rw-r--r--db/schema_migrations/202206280129021
-rw-r--r--db/schema_migrations/202206281102141
-rw-r--r--db/schema_migrations/202206281108231
-rw-r--r--db/schema_migrations/202206281117521
-rw-r--r--db/schema_migrations/202206281207081
-rw-r--r--db/schema_migrations/202206281216441
-rw-r--r--db/schema_migrations/202206281217121
-rw-r--r--db/schema_migrations/202206281226221
-rw-r--r--db/schema_migrations/202206291844021
-rw-r--r--db/schema_migrations/202206292201291
-rw-r--r--db/schema_migrations/202206300500501
-rw-r--r--db/schema_migrations/202206300850031
-rw-r--r--db/schema_migrations/202206300914091
-rw-r--r--db/schema_migrations/202206301516411
-rw-r--r--db/schema_migrations/202206302023291
-rw-r--r--db/schema_migrations/202207010855231
-rw-r--r--db/schema_migrations/202207011738591
-rw-r--r--db/schema_migrations/202207031822341
-rw-r--r--db/schema_migrations/202207031822541
-rw-r--r--db/schema_migrations/202207031823141
-rw-r--r--db/schema_migrations/202207040340501
-rw-r--r--db/schema_migrations/202207040341051
-rw-r--r--db/schema_migrations/202207040444081
-rw-r--r--db/schema_migrations/202207040454401
-rw-r--r--db/schema_migrations/202207051146351
-rw-r--r--db/schema_migrations/202207051453491
-rw-r--r--db/schema_migrations/202207051808431
-rw-r--r--db/schema_migrations/202207060652451
-rw-r--r--db/schema_migrations/202207060656111
-rw-r--r--db/schema_migrations/202207060708041
-rw-r--r--db/schema_migrations/202207060713041
-rw-r--r--db/schema_migrations/202207061151381
-rw-r--r--db/schema_migrations/202207061227191
-rw-r--r--db/schema_migrations/202207061322381
-rw-r--r--db/schema_migrations/202207061916271
-rw-r--r--db/schema_migrations/202207070753001
-rw-r--r--db/schema_migrations/202207081005081
-rw-r--r--db/schema_migrations/202207081005321
-rw-r--r--db/schema_migrations/202207081327011
-rw-r--r--db/schema_migrations/202207081427441
-rw-r--r--db/schema_migrations/202207081428031
-rw-r--r--db/schema_migrations/202207081503151
-rw-r--r--db/schema_migrations/202207081503351
-rw-r--r--db/schema_migrations/202207081848221
-rw-r--r--db/schema_migrations/202207120257121
-rw-r--r--db/schema_migrations/202207120319231
-rw-r--r--db/schema_migrations/202207120949451
-rw-r--r--db/schema_migrations/202207131335151
-rw-r--r--db/schema_migrations/202207131756581
-rw-r--r--db/schema_migrations/202207131757371
-rw-r--r--db/schema_migrations/202207131758121
-rw-r--r--db/schema_migrations/202207141051221
-rw-r--r--db/schema_migrations/202207141223111
-rw-r--r--db/schema_migrations/202207141224181
-rw-r--r--db/schema_migrations/202207141424241
-rw-r--r--db/schema_migrations/202207150545061
-rw-r--r--db/schema_migrations/202207151600231
-rw-r--r--db/schema_migrations/202207151632541
-rw-r--r--db/structure.sql590
241 files changed, 2928 insertions, 173 deletions
diff --git a/db/docs/broadcast_messages.yml b/db/docs/broadcast_messages.yml
index da8693df4fc..1e4c181d48f 100644
--- a/db/docs/broadcast_messages.yml
+++ b/db/docs/broadcast_messages.yml
@@ -3,7 +3,7 @@ table_name: broadcast_messages
classes:
- BroadcastMessage
feature_categories:
-- navigation
-description: TODO
+- onboarding
+description: GitLab can display broadcast messages to users of a GitLab instance
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/f1ecf53c1e55fbbc66cb2d7d12fb411cbfc2ace8
milestone: '6.3'
diff --git a/db/docs/ci_job_token_project_scope_links.yml b/db/docs/ci_job_token_project_scope_links.yml
index e073b63e924..993d392bb93 100644
--- a/db/docs/ci_job_token_project_scope_links.yml
+++ b/db/docs/ci_job_token_project_scope_links.yml
@@ -3,7 +3,7 @@ table_name: ci_job_token_project_scope_links
classes:
- Ci::JobToken::ProjectScopeLink
feature_categories:
-- pipeline_authoring
-description: TODO
+- continuous_integration
+description: The connection between a source project, which defines the job token scope, and a target project, which is the one allowed to be accessed by the job token.
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62733
milestone: '14.0'
diff --git a/db/docs/ci_runner_versions.yml b/db/docs/ci_runner_versions.yml
new file mode 100644
index 00000000000..e0221e3956f
--- /dev/null
+++ b/db/docs/ci_runner_versions.yml
@@ -0,0 +1,9 @@
+---
+table_name: ci_runner_versions
+classes:
+- Ci::RunnerVersion
+feature_categories:
+- runner_fleet
+description: Information about used Ci::Runner versions
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90982
+milestone: '15.2'
diff --git a/db/docs/ci_secure_file_states.yml b/db/docs/ci_secure_file_states.yml
new file mode 100644
index 00000000000..5e8a748e52a
--- /dev/null
+++ b/db/docs/ci_secure_file_states.yml
@@ -0,0 +1,9 @@
+---
+table_name: ci_secure_file_states
+classes:
+- Geo::CiSecureFileState
+feature_categories:
+- pipeline_authoring
+description: Stores verification state for Geo replicated Project-level Secure Files.
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90510
+milestone: '15.2'
diff --git a/db/docs/clusters_applications_elastic_stacks.yml b/db/docs/clusters_applications_elastic_stacks.yml
deleted file mode 100644
index 97943a9516b..00000000000
--- a/db/docs/clusters_applications_elastic_stacks.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-table_name: clusters_applications_elastic_stacks
-classes:
-- Clusters::Applications::ElasticStack
-feature_categories:
-- kubernetes_management
-description: (Deprecated) A GitLab managed Elastic Stack installation in a Kubernetes cluster
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/18015
-milestone: '12.5'
diff --git a/db/docs/clusters_integration_elasticstack.yml b/db/docs/clusters_integration_elasticstack.yml
deleted file mode 100644
index 2c2261a53e2..00000000000
--- a/db/docs/clusters_integration_elasticstack.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-table_name: clusters_integration_elasticstack
-classes:
-- Clusters::Integrations::ElasticStack
-feature_categories:
-- configure
-description: TODO
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61077
-milestone: '13.12'
diff --git a/db/docs/namespace_bans.yml b/db/docs/namespace_bans.yml
new file mode 100644
index 00000000000..7e11738ab81
--- /dev/null
+++ b/db/docs/namespace_bans.yml
@@ -0,0 +1,9 @@
+---
+table_name: namespace_bans
+classes:
+ - NamespaceBan
+feature_categories:
+ - instance_resiliency
+description: Contains users banned from namespaces
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91271
+milestone: "15.2"
diff --git a/db/docs/project_relation_export_uploads.yml b/db/docs/project_relation_export_uploads.yml
new file mode 100644
index 00000000000..369f6d281ee
--- /dev/null
+++ b/db/docs/project_relation_export_uploads.yml
@@ -0,0 +1,9 @@
+---
+table_name: project_relation_export_uploads
+classes:
+- Projects::ImportExport::RelationExportUpload
+feature_categories:
+- importers
+description: Used to store relation export files location
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90624
+milestone: '15.2'
diff --git a/db/docs/project_relation_exports.yml b/db/docs/project_relation_exports.yml
new file mode 100644
index 00000000000..7014d4cae0d
--- /dev/null
+++ b/db/docs/project_relation_exports.yml
@@ -0,0 +1,9 @@
+---
+table_name: project_relation_exports
+classes:
+- Projects::ImportExport::RelationExport
+feature_categories:
+- importers
+description: Used to track the generation of relation export files for projects
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90624
+milestone: '15.2'
diff --git a/db/docs/project_tracing_settings.yml b/db/docs/project_tracing_settings.yml
deleted file mode 100644
index 1a864dc7eae..00000000000
--- a/db/docs/project_tracing_settings.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-table_name: project_tracing_settings
-classes:
-- ProjectTracingSetting
-feature_categories:
-- tracing
-description: TODO
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7903
-milestone: '11.5'
diff --git a/db/docs/sbom_component_versions.yml b/db/docs/sbom_component_versions.yml
new file mode 100644
index 00000000000..7fb9b7fcec5
--- /dev/null
+++ b/db/docs/sbom_component_versions.yml
@@ -0,0 +1,11 @@
+---
+table_name: sbom_component_versions
+classes:
+- Sbom::ComponentVersion
+feature_categories:
+- container_scanning
+- dependency_scanning
+- license_compliance
+description: Stores version information for software components produced by a Software Bill of Materials (SBoM)
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90809
+milestone: '15.2'
diff --git a/db/docs/sbom_components.yml b/db/docs/sbom_components.yml
new file mode 100644
index 00000000000..8860c253cd5
--- /dev/null
+++ b/db/docs/sbom_components.yml
@@ -0,0 +1,11 @@
+---
+table_name: sbom_components
+classes:
+- Sbom::Component
+feature_categories:
+- container_scanning
+- dependency_scanning
+- license_compliance
+description: Stores information about software components produced by a Software Bill of Materials (SBoM)
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90809
+milestone: '15.2'
diff --git a/db/docs/sbom_occurrences.yml b/db/docs/sbom_occurrences.yml
new file mode 100644
index 00000000000..82d9e21aa42
--- /dev/null
+++ b/db/docs/sbom_occurrences.yml
@@ -0,0 +1,11 @@
+---
+table_name: sbom_occurrences
+classes:
+- Sbom::Occurrence
+feature_categories:
+- container_scanning
+- dependency_scanning
+- license_compliance
+description: Tracks each occurrence of an SBoM component
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90814
+milestone: '15.2'
diff --git a/db/docs/sbom_sources.yml b/db/docs/sbom_sources.yml
new file mode 100644
index 00000000000..514386536da
--- /dev/null
+++ b/db/docs/sbom_sources.yml
@@ -0,0 +1,11 @@
+---
+table_name: sbom_sources
+classes:
+- Sbom::Source
+feature_categories:
+- container_scanning
+- dependency_scanning
+- license_compliance
+description: Stores information about where an SBoM component originated from
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90812
+milestone: '15.2'
diff --git a/db/docs/user_namespace_callouts.yml b/db/docs/user_namespace_callouts.yml
new file mode 100644
index 00000000000..5038ecce3bc
--- /dev/null
+++ b/db/docs/user_namespace_callouts.yml
@@ -0,0 +1,10 @@
+
+---
+table_name: user_namespace_callouts
+classes:
+- Users::NamespaceCallout
+feature_categories:
+- navigation
+description: Contains records of which users have dismissed a callout, grouped by namespace.
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91092
+milestone: '15.2'
diff --git a/db/docs/vulnerability_merge_request_links.yml b/db/docs/vulnerability_merge_request_links.yml
new file mode 100644
index 00000000000..7c9d958303f
--- /dev/null
+++ b/db/docs/vulnerability_merge_request_links.yml
@@ -0,0 +1,9 @@
+---
+table_name: vulnerability_merge_request_links
+classes:
+- Vulnerabilities::MergeRequestLink
+feature_categories:
+- vulnerability_management
+description: Join table between Vulnerabilities and Merge Requests
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92096
+milestone: '15.2'
diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb
index 7aaaa48d6d4..71fe0df70f4 100644
--- a/db/fixtures/development/06_teams.rb
+++ b/db/fixtures/development/06_teams.rb
@@ -4,7 +4,7 @@ Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
Group.not_mass_generated.each do |group|
User.not_mass_generated.sample(4).each do |user|
- if group.add_user(user, Gitlab::Access.values.sample).persisted?
+ if group.add_member(user, Gitlab::Access.values.sample).persisted?
print '.'
else
print 'F'
diff --git a/db/fixtures/development/33_triage_ops.rb b/db/fixtures/development/33_triage_ops.rb
index aaf92315125..b2dd3861169 100644
--- a/db/fixtures/development/33_triage_ops.rb
+++ b/db/fixtures/development/33_triage_ops.rb
@@ -11,29 +11,31 @@ class Gitlab::Seeder::TriageOps
puts "Updating settings to allow web hooks to localhost"
ApplicationSetting.current_without_cache.update!(allow_local_requests_from_web_hooks_and_services: true)
- Sidekiq::Testing.inline! do
- puts "Ensuring required groups"
- ensure_group('gitlab-com')
- ensure_group('gitlab-com/gl-security/appsec')
- ensure_group('gitlab-jh/jh-team')
- ensure_group('gitlab-org')
- ensure_group('gitlab-org/gitlab-core-team/community-members')
- ensure_group('gitlab-org/security')
-
- puts "Ensuring required projects"
- ensure_project('gitlab-org/gitlab')
- ensure_project('gitlab-org/security/gitlab')
-
- puts "Ensuring required bot user"
- ensure_bot_user
-
- puts "Setting up webhooks"
- ensure_webhook_for('gitlab-com')
- ensure_webhook_for('gitlab-org')
-
- puts "Ensuring work type labels"
- ensure_work_type_labels_for('gitlab-com')
- ensure_work_type_labels_for('gitlab-org')
+ Sidekiq::Worker.skipping_transaction_check do
+ Sidekiq::Testing.inline! do
+ puts "Ensuring required groups"
+ ensure_group('gitlab-com')
+ ensure_group('gitlab-com/gl-security/appsec')
+ ensure_group('gitlab-jh/jh-team')
+ ensure_group('gitlab-org')
+ ensure_group('gitlab-org/gitlab-core-team/community-members')
+ ensure_group('gitlab-org/security')
+
+ puts "Ensuring required projects"
+ ensure_project('gitlab-org/gitlab')
+ ensure_project('gitlab-org/security/gitlab')
+
+ puts "Ensuring required bot user"
+ ensure_bot_user
+
+ puts "Setting up webhooks"
+ ensure_webhook_for('gitlab-com')
+ ensure_webhook_for('gitlab-org')
+
+ puts "Ensuring work type labels"
+ ensure_work_type_labels_for('gitlab-com')
+ ensure_work_type_labels_for('gitlab-org')
+ end
end
end
diff --git a/db/migrate/20220523162734_add_vulnerability_reads_casted_cluster_agent_column.rb b/db/migrate/20220523162734_add_vulnerability_reads_casted_cluster_agent_column.rb
new file mode 100644
index 00000000000..ce222906e25
--- /dev/null
+++ b/db/migrate/20220523162734_add_vulnerability_reads_casted_cluster_agent_column.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddVulnerabilityReadsCastedClusterAgentColumn < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :vulnerability_reads, :casted_cluster_agent_id, :bigint
+ end
+end
diff --git a/db/migrate/20220523163734_update_vulnerability_reads_trigger_functions.rb b/db/migrate/20220523163734_update_vulnerability_reads_trigger_functions.rb
new file mode 100644
index 00000000000..645d19c8f51
--- /dev/null
+++ b/db/migrate/20220523163734_update_vulnerability_reads_trigger_functions.rb
@@ -0,0 +1,81 @@
+# frozen_string_literal: true
+
+class UpdateVulnerabilityReadsTriggerFunctions < Gitlab::Database::Migration[2.0]
+ AGENT_ID_VALUE = "NEW.location->'kubernetes_resource'->>'agent_id'"
+ CASTED_AGENT_ID_VALUE = "CAST(#{AGENT_ID_VALUE} AS bigint)"
+
+ def up
+ update_insert_or_update_vulnerability_reads_function(with_casted_cluster_agent_id: true)
+ update_update_location_from_vulnerability_occurrences_function(with_casted_cluster_agent_id: true)
+ end
+
+ def down
+ update_insert_or_update_vulnerability_reads_function(with_casted_cluster_agent_id: false)
+ update_update_location_from_vulnerability_occurrences_function(with_casted_cluster_agent_id: false)
+ end
+
+ private
+
+ def update_insert_or_update_vulnerability_reads_function(with_casted_cluster_agent_id: false)
+ insert_fields = with_casted_cluster_agent_id ? 'cluster_agent_id, casted_cluster_agent_id' : 'cluster_agent_id'
+ insert_values = with_casted_cluster_agent_id ? [AGENT_ID_VALUE, CASTED_AGENT_ID_VALUE].join(', ') : AGENT_ID_VALUE
+
+ 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;
+ 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
+ INTO
+ severity, state, report_type, resolved_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, #{insert_fields})
+ VALUES (NEW.vulnerability_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', #{insert_values})
+ ON CONFLICT(vulnerability_id) DO NOTHING;
+ RETURN NULL;
+ END
+ $$;
+ SQL
+ end
+
+ def update_update_location_from_vulnerability_occurrences_function(with_casted_cluster_agent_id: false)
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION update_location_from_vulnerability_occurrences()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ BEGIN
+ UPDATE
+ vulnerability_reads
+ SET
+ location_image = NEW.location->>'image',
+ #{with_casted_cluster_agent_id ? "casted_cluster_agent_id = #{CASTED_AGENT_ID_VALUE}," : ''}
+ cluster_agent_id = #{AGENT_ID_VALUE}
+ WHERE
+ vulnerability_id = NEW.vulnerability_id;
+ RETURN NULL;
+
+ END
+ $$;
+ SQL
+ end
+end
diff --git a/db/migrate/20220524164122_limit_project_and_group_variables.rb b/db/migrate/20220524164122_limit_project_and_group_variables.rb
new file mode 100644
index 00000000000..e8776e35730
--- /dev/null
+++ b/db/migrate/20220524164122_limit_project_and_group_variables.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class LimitProjectAndGroupVariables < Gitlab::Database::Migration[2.0]
+ def change
+ add_column(:plan_limits, :project_ci_variables, :integer, default: 200, null: false)
+ add_column(:plan_limits, :group_ci_variables, :integer, default: 200, null: false)
+ end
+end
diff --git a/db/migrate/20220531024905_add_operations_access_levels_to_project_feature.rb b/db/migrate/20220531024905_add_operations_access_levels_to_project_feature.rb
new file mode 100644
index 00000000000..68921cd1468
--- /dev/null
+++ b/db/migrate/20220531024905_add_operations_access_levels_to_project_feature.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddOperationsAccessLevelsToProjectFeature < Gitlab::Database::Migration[2.0]
+ OPERATIONS_DEFAULT_VALUE = 20
+
+ enable_lock_retries!
+
+ # rubocop:disable Layout/LineLength
+ def up
+ add_column :project_features, :monitor_access_level, :integer, null: false, default: OPERATIONS_DEFAULT_VALUE
+ add_column :project_features, :infrastructure_access_level, :integer, null: false, default: OPERATIONS_DEFAULT_VALUE
+ add_column :project_features, :feature_flags_access_level, :integer, null: false, default: OPERATIONS_DEFAULT_VALUE
+ add_column :project_features, :environments_access_level, :integer, null: false, default: OPERATIONS_DEFAULT_VALUE
+ add_column :project_features, :releases_access_level, :integer, null: false, default: OPERATIONS_DEFAULT_VALUE
+ end
+
+ def down
+ remove_column :project_features, :monitor_access_level
+ remove_column :project_features, :infrastructure_access_level
+ remove_column :project_features, :feature_flags_access_level
+ remove_column :project_features, :environments_access_level
+ remove_column :project_features, :releases_access_level
+ end
+end
diff --git a/db/migrate/20220531140515_add_applies_to_all_protected_branches_to_approval_project_rule.rb b/db/migrate/20220531140515_add_applies_to_all_protected_branches_to_approval_project_rule.rb
new file mode 100644
index 00000000000..4015d3fa1f7
--- /dev/null
+++ b/db/migrate/20220531140515_add_applies_to_all_protected_branches_to_approval_project_rule.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddAppliesToAllProtectedBranchesToApprovalProjectRule < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :approval_project_rules, :applies_to_all_protected_branches, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20220608074738_add_max_repository_downloads_limit_to_application_settings.rb b/db/migrate/20220608074738_add_max_repository_downloads_limit_to_application_settings.rb
new file mode 100644
index 00000000000..9252262c26f
--- /dev/null
+++ b/db/migrate/20220608074738_add_max_repository_downloads_limit_to_application_settings.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddMaxRepositoryDownloadsLimitToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :max_number_of_repository_downloads,
+ :smallint,
+ default: 0,
+ null: false
+
+ add_column :application_settings, :max_number_of_repository_downloads_within_time_period,
+ :integer,
+ default: 0,
+ null: false
+ end
+end
diff --git a/db/migrate/20220610140605_change_public_projects_cost_factor.rb b/db/migrate/20220610140605_change_public_projects_cost_factor.rb
new file mode 100644
index 00000000000..cf0c275828c
--- /dev/null
+++ b/db/migrate/20220610140605_change_public_projects_cost_factor.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class ChangePublicProjectsCostFactor < Gitlab::Database::Migration[2.0]
+ # This migration updates SaaS Runner cost factors for public projects.
+ # Previously we had a disabled cost factor for public projects, meaning
+ # that no CI minutes were counted by default. With a low cost factor
+ # we count CI minutes consumption at a very low rate to prevent
+ # abuses.
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_ci
+
+ DISABLED_COST_FACTOR = 0
+ LOW_COST_FACTOR = 0.008
+
+ class Runner < MigrationRecord
+ self.table_name = 'ci_runners'
+
+ scope :shared, -> { where(runner_type: 1) }
+ end
+
+ def up
+ return unless Gitlab.com?
+
+ Runner.shared.where(public_projects_minutes_cost_factor: DISABLED_COST_FACTOR)
+ .update_all(public_projects_minutes_cost_factor: LOW_COST_FACTOR)
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ Runner.shared.where(public_projects_minutes_cost_factor: LOW_COST_FACTOR)
+ .update_all(public_projects_minutes_cost_factor: DISABLED_COST_FACTOR)
+ end
+end
diff --git a/db/migrate/20220613054349_add_unique_project_download_limit_settings_to_namespace_settings.rb b/db/migrate/20220613054349_add_unique_project_download_limit_settings_to_namespace_settings.rb
new file mode 100644
index 00000000000..7e821cb17a2
--- /dev/null
+++ b/db/migrate/20220613054349_add_unique_project_download_limit_settings_to_namespace_settings.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddUniqueProjectDownloadLimitSettingsToNamespaceSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_settings, :unique_project_download_limit, :smallint,
+ default: 0, null: false
+ add_column :namespace_settings, :unique_project_download_limit_interval_in_seconds, :integer,
+ default: 0, null: false
+ end
+end
diff --git a/db/migrate/20220614120415_add_toggle_opt_in_jwt.rb b/db/migrate/20220614120415_add_toggle_opt_in_jwt.rb
new file mode 100644
index 00000000000..40e07504ac6
--- /dev/null
+++ b/db/migrate/20220614120415_add_toggle_opt_in_jwt.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddToggleOptInJwt < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :project_ci_cd_settings, :opt_in_jwt, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20220616182001_create_sbom_components.rb b/db/migrate/20220616182001_create_sbom_components.rb
new file mode 100644
index 00000000000..59e8e76393a
--- /dev/null
+++ b/db/migrate/20220616182001_create_sbom_components.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class CreateSbomComponents < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :sbom_components do |t|
+ t.timestamps_with_timezone
+ t.integer :component_type, null: false, limit: 2
+ t.text :name, null: false, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20220616182015_create_sbom_component_versions.rb b/db/migrate/20220616182015_create_sbom_component_versions.rb
new file mode 100644
index 00000000000..aea99c8c0ce
--- /dev/null
+++ b/db/migrate/20220616182015_create_sbom_component_versions.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateSbomComponentVersions < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :sbom_component_versions do |t|
+ t.timestamps_with_timezone
+ t.references :component,
+ index: true,
+ null: false,
+ foreign_key: { to_table: :sbom_components, on_delete: :cascade }
+
+ t.text :version, null: false, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20220616182016_create_sbom_sources.rb b/db/migrate/20220616182016_create_sbom_sources.rb
new file mode 100644
index 00000000000..b4fe9519f7b
--- /dev/null
+++ b/db/migrate/20220616182016_create_sbom_sources.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateSbomSources < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :sbom_sources do |t|
+ t.timestamps_with_timezone
+ t.integer :source_type, null: false, limit: 2
+ t.jsonb :source, null: false, default: {}
+ t.binary :fingerprint, null: false
+ end
+ end
+end
diff --git a/db/migrate/20220616182038_create_sbom_occurrences.rb b/db/migrate/20220616182038_create_sbom_occurrences.rb
new file mode 100644
index 00000000000..8fc80970d45
--- /dev/null
+++ b/db/migrate/20220616182038_create_sbom_occurrences.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateSbomOccurrences < Gitlab::Database::Migration[2.0]
+ def change
+ create_table :sbom_occurrences do |t|
+ t.timestamps_with_timezone
+ t.bigint :component_version_id, null: false, index: true
+ t.bigint :project_id, null: false, index: true
+ t.bigint :pipeline_id, index: true
+ t.bigint :source_id, index: true
+ t.binary :commit_sha, null: false
+ end
+ end
+end
diff --git a/db/migrate/20220616183240_add_sbom_component_versions_foreign_key_to_sbom_occurrences.rb b/db/migrate/20220616183240_add_sbom_component_versions_foreign_key_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..abaf9939456
--- /dev/null
+++ b/db/migrate/20220616183240_add_sbom_component_versions_foreign_key_to_sbom_occurrences.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddSbomComponentVersionsForeignKeyToSbomOccurrences < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :sbom_occurrences,
+ :sbom_component_versions,
+ column: :component_version_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :sbom_occurrences, column: :component_version_id
+ end
+ end
+end
diff --git a/db/migrate/20220616183309_add_sbom_source_foreign_key_to_sbom_occurrences.rb b/db/migrate/20220616183309_add_sbom_source_foreign_key_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..3818e5f51c7
--- /dev/null
+++ b/db/migrate/20220616183309_add_sbom_source_foreign_key_to_sbom_occurrences.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddSbomSourceForeignKeyToSbomOccurrences < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :sbom_occurrences, :sbom_sources, column: :source_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :sbom_occurrences, column: :source_id
+ end
+ end
+end
diff --git a/db/migrate/20220616183310_add_project_foreign_key_to_sbom_occurrences.rb b/db/migrate/20220616183310_add_project_foreign_key_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..d2e32ffbb3f
--- /dev/null
+++ b/db/migrate/20220616183310_add_project_foreign_key_to_sbom_occurrences.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddProjectForeignKeyToSbomOccurrences < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :sbom_occurrences, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :sbom_occurrences, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20220617123135_drop_temp_index_on_projects_on_id_and_runners_token.rb b/db/migrate/20220617123135_drop_temp_index_on_projects_on_id_and_runners_token.rb
new file mode 100644
index 00000000000..c860a2208fe
--- /dev/null
+++ b/db/migrate/20220617123135_drop_temp_index_on_projects_on_id_and_runners_token.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class DropTempIndexOnProjectsOnIdAndRunnersToken < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TEMP_INDEX_NAME = 'tmp_index_projects_on_id_and_runners_token'
+
+ def up
+ finalize_background_migration 'ResetDuplicateCiRunnersTokenValuesOnProjects'
+
+ remove_concurrent_index_by_name :projects, TEMP_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :projects,
+ [:id, :runners_token],
+ where: "runners_token IS NOT NULL",
+ unique: false,
+ name: TEMP_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220617123144_drop_temp_index_on_projects_on_id_and_runners_token_encrypted.rb b/db/migrate/20220617123144_drop_temp_index_on_projects_on_id_and_runners_token_encrypted.rb
new file mode 100644
index 00000000000..254a73a9b1f
--- /dev/null
+++ b/db/migrate/20220617123144_drop_temp_index_on_projects_on_id_and_runners_token_encrypted.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class DropTempIndexOnProjectsOnIdAndRunnersTokenEncrypted < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TEMP_INDEX_NAME = 'tmp_index_projects_on_id_and_runners_token_encrypted'
+
+ def up
+ finalize_background_migration 'ResetDuplicateCiRunnersTokenEncryptedValuesOnProjects'
+
+ remove_concurrent_index_by_name :projects, TEMP_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :projects,
+ [:id, :runners_token_encrypted],
+ where: "runners_token_encrypted IS NOT NULL",
+ unique: false,
+ name: TEMP_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220617141347_create_ci_secure_file_states.rb b/db/migrate/20220617141347_create_ci_secure_file_states.rb
new file mode 100644
index 00000000000..63cbcca2913
--- /dev/null
+++ b/db/migrate/20220617141347_create_ci_secure_file_states.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+# rubocop:disable Layout/LineLength
+
+class CreateCiSecureFileStates < Gitlab::Database::Migration[2.0]
+ VERIFICATION_STATE_INDEX_NAME = "index_ci_secure_file_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_ci_secure_file_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_ci_secure_file_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_ci_secure_file_states_needs_verification"
+
+ enable_lock_retries!
+
+ def up
+ create_table :ci_secure_file_states, id: false do |t|
+ t.datetime_with_timezone :verification_started_at
+ t.datetime_with_timezone :verification_retry_at
+ t.datetime_with_timezone :verified_at
+ t.references :ci_secure_file, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :verification_state, default: 0, limit: 2, null: false
+ t.integer :verification_retry_count, limit: 2
+ t.binary :verification_checksum, using: 'verification_checksum::bytea'
+ t.text :verification_failure, limit: 255
+
+ t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
+ t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
+ t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
+ t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
+ end
+ end
+
+ def down
+ drop_table :ci_secure_file_states
+ end
+end
+# rubocop:enable Layout/LineLength
diff --git a/db/migrate/20220619182308_create_project_relation_exports.rb b/db/migrate/20220619182308_create_project_relation_exports.rb
new file mode 100644
index 00000000000..7b92ca5110f
--- /dev/null
+++ b/db/migrate/20220619182308_create_project_relation_exports.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class CreateProjectRelationExports < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ UNIQUE_INDEX_NAME = 'index_project_export_job_relation'
+
+ def change
+ create_table :project_relation_exports do |t|
+ t.references :project_export_job, null: false, foreign_key: { on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.integer :status, limit: 2, null: false, default: 0
+ t.text :relation, null: false, limit: 255
+ t.text :jid, limit: 255
+ t.text :export_error, limit: 300
+
+ t.index [:project_export_job_id, :relation], unique: true, name: UNIQUE_INDEX_NAME
+ end
+ end
+end
diff --git a/db/migrate/20220619184931_create_project_relation_export_uploads.rb b/db/migrate/20220619184931_create_project_relation_export_uploads.rb
new file mode 100644
index 00000000000..03abf980f13
--- /dev/null
+++ b/db/migrate/20220619184931_create_project_relation_export_uploads.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateProjectRelationExportUploads < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ INDEX = 'index_project_relation_export_upload_id'
+
+ def change
+ create_table :project_relation_export_uploads do |t|
+ t.references :project_relation_export, null: false, foreign_key: { on_delete: :cascade }, index: { name: INDEX }
+ t.timestamps_with_timezone null: false
+ t.text :export_file, null: false, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20220621202616_add_partial_index_on_oauth_access_tokens_revoked_at.rb b/db/migrate/20220621202616_add_partial_index_on_oauth_access_tokens_revoked_at.rb
new file mode 100644
index 00000000000..2222698dcea
--- /dev/null
+++ b/db/migrate/20220621202616_add_partial_index_on_oauth_access_tokens_revoked_at.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddPartialIndexOnOauthAccessTokensRevokedAt < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'partial_index_resource_owner_id_created_at_token_not_revoked'
+ EXISTING_INDEX_NAME = 'index_oauth_access_tokens_on_resource_owner_id'
+
+ def up
+ add_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at],
+ name: INDEX_NAME, where: 'revoked_at IS NULL'
+ remove_concurrent_index :oauth_access_tokens, :resource_owner_id, name: EXISTING_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :oauth_access_tokens, :resource_owner_id, name: EXISTING_INDEX_NAME
+ remove_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220624081524_add_ci_runner_versions_table.rb b/db/migrate/20220624081524_add_ci_runner_versions_table.rb
new file mode 100644
index 00000000000..844c5898d75
--- /dev/null
+++ b/db/migrate/20220624081524_add_ci_runner_versions_table.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddCiRunnerVersionsTable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ create_table :ci_runner_versions, id: false do |t|
+ t.text :version, primary_key: true, index: true, null: false, limit: 2048
+ t.integer :status, null: true, limit: 2, index: true
+ end
+ end
+
+ def down
+ drop_table :ci_runner_versions, if_exists: true
+ end
+end
diff --git a/db/migrate/20220624090458_add_index_on_runner_version.rb b/db/migrate/20220624090458_add_index_on_runner_version.rb
new file mode 100644
index 00000000000..e28bf0d8a76
--- /dev/null
+++ b/db/migrate/20220624090458_add_index_on_runner_version.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnRunnerVersion < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_runners_on_version'
+
+ def up
+ add_concurrent_index :ci_runners, :version, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_runners, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220627061008_add_fei_shu_integration.rb b/db/migrate/20220627061008_add_fei_shu_integration.rb
new file mode 100644
index 00000000000..8feedc70ce6
--- /dev/null
+++ b/db/migrate/20220627061008_add_fei_shu_integration.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+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, :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'
+ add_column :application_settings, :encrypted_feishu_app_secret_iv, :binary, comment: 'JiHu-specific column'
+ end
+end
diff --git a/db/migrate/20220627122229_create_user_namespace_callouts.rb b/db/migrate/20220627122229_create_user_namespace_callouts.rb
new file mode 100644
index 00000000000..fc85c02d2db
--- /dev/null
+++ b/db/migrate/20220627122229_create_user_namespace_callouts.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateUserNamespaceCallouts < Gitlab::Database::Migration[2.0]
+ def up
+ create_table :user_namespace_callouts do |t|
+ t.bigint :user_id, null: false
+ t.bigint :namespace_id, null: false, index: true
+ t.datetime_with_timezone :dismissed_at
+ t.integer :feature_name, limit: 2, null: false
+ end
+ end
+
+ def down
+ drop_table :user_namespace_callouts
+ end
+end
diff --git a/db/migrate/20220627122230_add_foreign_keys_to_user_namespace_callouts.rb b/db/migrate/20220627122230_add_foreign_keys_to_user_namespace_callouts.rb
new file mode 100644
index 00000000000..f78eb978a9b
--- /dev/null
+++ b/db/migrate/20220627122230_add_foreign_keys_to_user_namespace_callouts.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class AddForeignKeysToUserNamespaceCallouts < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :user_namespace_callouts, :users,
+ column: :user_id,
+ on_delete: :cascade
+
+ add_concurrent_foreign_key :user_namespace_callouts, :namespaces,
+ column: :namespace_id,
+ on_delete: :cascade
+
+ add_concurrent_index :user_namespace_callouts, [:user_id, :feature_name, :namespace_id],
+ unique: true,
+ name: 'index_ns_user_callouts_feature'
+ end
+
+ def down
+ remove_concurrent_index_by_name :user_namespace_callouts, 'index_ns_user_callouts_feature'
+
+ with_lock_retries do
+ remove_foreign_key :user_namespace_callouts, column: :user_id
+ remove_foreign_key :user_namespace_callouts, column: :namespace_id
+ end
+ end
+end
diff --git a/db/migrate/20220627140315_add_last_feature_flag_updated_at_to_operations_feature_flags_clients.rb b/db/migrate/20220627140315_add_last_feature_flag_updated_at_to_operations_feature_flags_clients.rb
new file mode 100644
index 00000000000..9309f4899ab
--- /dev/null
+++ b/db/migrate/20220627140315_add_last_feature_flag_updated_at_to_operations_feature_flags_clients.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddLastFeatureFlagUpdatedAtToOperationsFeatureFlagsClients < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :operations_feature_flags_clients, :last_feature_flag_updated_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20220627171538_add_error_tracking_settings.rb b/db/migrate/20220627171538_add_error_tracking_settings.rb
new file mode 100644
index 00000000000..f3bf086b58a
--- /dev/null
+++ b/db/migrate/20220627171538_add_error_tracking_settings.rb
@@ -0,0 +1,21 @@
+# 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 AddErrorTrackingSettings < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_column :application_settings, :error_tracking_enabled, :boolean,
+ default: false, null: false, if_not_exists: true
+
+ add_column :application_settings, :error_tracking_api_url, :text, if_not_exists: true
+ add_text_limit :application_settings, :error_tracking_api_url, 255
+ end
+
+ def down
+ remove_column :application_settings, :error_tracking_enabled, if_exists: true
+ remove_column :application_settings, :error_tracking_api_url, if_exists: true
+ end
+end
diff --git a/db/migrate/20220628110214_add_namespace_id_column_to_issues_table.rb b/db/migrate/20220628110214_add_namespace_id_column_to_issues_table.rb
new file mode 100644
index 00000000000..111ef8babae
--- /dev/null
+++ b/db/migrate/20220628110214_add_namespace_id_column_to_issues_table.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddNamespaceIdColumnToIssuesTable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ add_column :issues, :namespace_id, :bigint
+ end
+
+ def down
+ remove_column :issues, :namespace_id
+ end
+end
diff --git a/db/migrate/20220628120708_create_namespace_bans.rb b/db/migrate/20220628120708_create_namespace_bans.rb
new file mode 100644
index 00000000000..657d13f6448
--- /dev/null
+++ b/db/migrate/20220628120708_create_namespace_bans.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateNamespaceBans < Gitlab::Database::Migration[2.0]
+ UNIQUE_INDEX_NAME = 'index_namespace_bans_on_namespace_id_and_user_id'
+
+ def change
+ create_table :namespace_bans do |t|
+ t.bigint :namespace_id, null: false
+ t.bigint :user_id, null: false, index: true
+ t.timestamps_with_timezone
+
+ t.index [:namespace_id, :user_id], unique: true, name: UNIQUE_INDEX_NAME
+ end
+ end
+end
diff --git a/db/migrate/20220628121644_add_namespace_bans_namespace_id_foreign_key.rb b/db/migrate/20220628121644_add_namespace_bans_namespace_id_foreign_key.rb
new file mode 100644
index 00000000000..30928123618
--- /dev/null
+++ b/db/migrate/20220628121644_add_namespace_bans_namespace_id_foreign_key.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddNamespaceBansNamespaceIdForeignKey < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :namespace_bans, :namespaces, column: :namespace_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :namespace_bans, column: :namespace_id
+ end
+ end
+end
diff --git a/db/migrate/20220628121712_add_namespace_bans_user_id_foreign_key.rb b/db/migrate/20220628121712_add_namespace_bans_user_id_foreign_key.rb
new file mode 100644
index 00000000000..16a73c29cae
--- /dev/null
+++ b/db/migrate/20220628121712_add_namespace_bans_user_id_foreign_key.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddNamespaceBansUserIdForeignKey < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :namespace_bans, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :namespace_bans, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20220629220129_increase_webauthn_xid_length.rb b/db/migrate/20220629220129_increase_webauthn_xid_length.rb
new file mode 100644
index 00000000000..c5b107ce3f6
--- /dev/null
+++ b/db/migrate/20220629220129_increase_webauthn_xid_length.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class IncreaseWebauthnXidLength < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ new_constraint_name = check_constraint_name(:webauthn_registrations, :credential_xid, 'max_length_v3')
+ add_text_limit :webauthn_registrations, :credential_xid, 1364, constraint_name: new_constraint_name
+
+ prev_constraint_name = check_constraint_name(:webauthn_registrations, :credential_xid, 'max_length_v2')
+ remove_text_limit :webauthn_registrations, :credential_xid, constraint_name: prev_constraint_name
+ end
+
+ def down
+ # no-op: Danger of failling if there are records with length(credential_xid) > 1364
+ end
+end
diff --git a/db/migrate/20220630202329_add_partial_index_on_oauth_access_tokens_revoked_at_with_order.rb b/db/migrate/20220630202329_add_partial_index_on_oauth_access_tokens_revoked_at_with_order.rb
new file mode 100644
index 00000000000..03eb8c2f29d
--- /dev/null
+++ b/db/migrate/20220630202329_add_partial_index_on_oauth_access_tokens_revoked_at_with_order.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddPartialIndexOnOauthAccessTokensRevokedAtWithOrder < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'partial_index_user_id_app_id_created_at_token_not_revoked'
+ EXISTING_INDEX_NAME = 'partial_index_resource_owner_id_created_at_token_not_revoked'
+
+ def up
+ add_concurrent_index :oauth_access_tokens, [:resource_owner_id, :application_id, :created_at],
+ name: INDEX_NAME, where: 'revoked_at IS NULL'
+ remove_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at], name: EXISTING_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at],
+ name: EXISTING_INDEX_NAME, where: 'revoked_at IS NULL'
+ remove_concurrent_index :oauth_access_tokens, [:resource_owner_id, :application_id, :created_at], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220701173859_remove_not_null_constraints_from_requirements.rb b/db/migrate/20220701173859_remove_not_null_constraints_from_requirements.rb
new file mode 100644
index 00000000000..97b223f1800
--- /dev/null
+++ b/db/migrate/20220701173859_remove_not_null_constraints_from_requirements.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RemoveNotNullConstraintsFromRequirements < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ change_column_null :requirements, :created_at, true
+ change_column_null :requirements, :updated_at, true
+ change_column_null :requirements, :title, true
+ change_column_null :requirements, :state, true
+ end
+
+ def down
+ # No OP
+ # The columns could have nil values again at this point. Rolling back
+ # would cause an exception, also we cannot insert data and modify the schema within the same migration.
+ # More details at https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91611#note_1017066470
+ end
+end
diff --git a/db/migrate/20220703182234_add_findings_partition_number_to_security_scans.rb b/db/migrate/20220703182234_add_findings_partition_number_to_security_scans.rb
new file mode 100644
index 00000000000..f7d50a6d5cf
--- /dev/null
+++ b/db/migrate/20220703182234_add_findings_partition_number_to_security_scans.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddFindingsPartitionNumberToSecurityScans < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :security_scans, :findings_partition_number, :integer, default: 1, null: false
+ end
+end
diff --git a/db/migrate/20220703182254_add_partition_number_to_security_findings.rb b/db/migrate/20220703182254_add_partition_number_to_security_findings.rb
new file mode 100644
index 00000000000..85ff4f2eb7c
--- /dev/null
+++ b/db/migrate/20220703182254_add_partition_number_to_security_findings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPartitionNumberToSecurityFindings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :security_findings, :partition_number, :integer, default: 1, null: false
+ end
+end
diff --git a/db/migrate/20220704034050_add_users_allowlist_to_git_rate_limits.rb b/db/migrate/20220704034050_add_users_allowlist_to_git_rate_limits.rb
new file mode 100644
index 00000000000..7dd1bb45e4c
--- /dev/null
+++ b/db/migrate/20220704034050_add_users_allowlist_to_git_rate_limits.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddUsersAllowlistToGitRateLimits < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings, :git_rate_limit_users_allowlist,
+ :text,
+ array: true,
+ default: [],
+ null: false
+ end
+end
diff --git a/db/migrate/20220704034105_add_application_settings_git_users_allowlist_max_usernames_constraint.rb b/db/migrate/20220704034105_add_application_settings_git_users_allowlist_max_usernames_constraint.rb
new file mode 100644
index 00000000000..ceb3807f817
--- /dev/null
+++ b/db/migrate/20220704034105_add_application_settings_git_users_allowlist_max_usernames_constraint.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddApplicationSettingsGitUsersAllowlistMaxUsernamesConstraint < Gitlab::Database::Migration[2.0]
+ CONSTRAINT_NAME = 'app_settings_git_rate_limit_users_allowlist_max_usernames'
+
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint :application_settings, 'CARDINALITY(git_rate_limit_users_allowlist) <= 100', CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :application_settings, CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20220705145349_add_project_import_level_to_namespace_settings.rb b/db/migrate/20220705145349_add_project_import_level_to_namespace_settings.rb
new file mode 100644
index 00000000000..e46f0221782
--- /dev/null
+++ b/db/migrate/20220705145349_add_project_import_level_to_namespace_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectImportLevelToNamespaceSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ add_column :namespace_settings, :project_import_level, :smallint, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20220706191627_add_encrypted_error_tracking_access_token.rb b/db/migrate/20220706191627_add_encrypted_error_tracking_access_token.rb
new file mode 100644
index 00000000000..b73556e6caa
--- /dev/null
+++ b/db/migrate/20220706191627_add_encrypted_error_tracking_access_token.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddEncryptedErrorTrackingAccessToken < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_column :application_settings, :error_tracking_access_token_encrypted, :text, if_not_exists: true
+ add_text_limit :application_settings, :error_tracking_access_token_encrypted, 255
+ end
+
+ def down
+ remove_column :application_settings, :error_tracking_access_token_encrypted, if_exists: true
+ end
+end
diff --git a/db/migrate/20220708100532_add_unique_index_on_ci_runner_versions_on_status_and_version.rb b/db/migrate/20220708100532_add_unique_index_on_ci_runner_versions_on_status_and_version.rb
new file mode 100644
index 00000000000..663614a321b
--- /dev/null
+++ b/db/migrate/20220708100532_add_unique_index_on_ci_runner_versions_on_status_and_version.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexOnCiRunnerVersionsOnStatusAndVersion < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_runner_versions_on_unique_status_and_version'
+
+ def up
+ add_concurrent_index :ci_runner_versions, [:status, :version], name: INDEX_NAME, unique: true
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_runner_versions, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220708132701_create_vulnerability_merge_request_links.rb b/db/migrate/20220708132701_create_vulnerability_merge_request_links.rb
new file mode 100644
index 00000000000..51fe15bee6e
--- /dev/null
+++ b/db/migrate/20220708132701_create_vulnerability_merge_request_links.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityMergeRequestLinks < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = "unique_vuln_merge_request_link_vuln_id_and_mr_id"
+
+ def up
+ create_table :vulnerability_merge_request_links do |t|
+ t.bigint :vulnerability_id, null: false
+ t.integer :merge_request_id, null: false
+
+ t.index :merge_request_id
+ t.timestamps_with_timezone null: false
+ end
+
+ add_index(
+ :vulnerability_merge_request_links,
+ %i[vulnerability_id merge_request_id],
+ unique: true,
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ drop_table(
+ :vulnerability_merge_request_links,
+ if_exists: true
+ )
+ end
+end
diff --git a/db/migrate/20220708142744_add_composite_index_for_protected_environments.rb b/db/migrate/20220708142744_add_composite_index_for_protected_environments.rb
new file mode 100644
index 00000000000..ab93f5ca9ca
--- /dev/null
+++ b/db/migrate/20220708142744_add_composite_index_for_protected_environments.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddCompositeIndexForProtectedEnvironments < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ # skips the `required_` part because index limit is 63 characters
+ INDEX_NAME = 'index_protected_environments_on_approval_count_and_created_at'
+
+ def up
+ add_concurrent_index :protected_environments, %i[required_approval_count created_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :protected_environments, %i[required_approval_count created_at], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb b/db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb
new file mode 100644
index 00000000000..6952489588d
--- /dev/null
+++ b/db/migrate/20220708142803_add_composite_index_for_protected_environment_approval_rules.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddCompositeIndexForProtectedEnvironmentApprovalRules < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ # uses `pe_` instead of `protected_environment_` because index limit is 63 characters
+ INDEX_NAME = 'index_pe_approval_rules_on_required_approvals_and_created_at'
+
+ def up
+ add_concurrent_index :protected_environment_approval_rules, %i[required_approvals created_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :protected_environment_approval_rules, %i[required_approvals created_at], name: INDEX_NAME
+ 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
new file mode 100644
index 00000000000..f821e2fbe3a
--- /dev/null
+++ b/db/migrate/20220708150315_add_vulnerabilities_foreign_key_to_vulnerability_merge_request_links.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddVulnerabilitiesForeignKeyToVulnerabilityMergeRequestLinks < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerability_merge_request_links, :vulnerabilities, column: :vulnerability_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :vulnerability_merge_request_links, column: :vulnerability_id
+ end
+ end
+end
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
new file mode 100644
index 00000000000..fedda9677f1
--- /dev/null
+++ b/db/migrate/20220708150335_add_merge_requests_foreign_key_to_vulnerability_merge_request_links.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddMergeRequestsForeignKeyToVulnerabilityMergeRequestLinks < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerability_merge_request_links, :merge_requests, column: :merge_request_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :vulnerability_merge_request_links, column: :merge_request_id
+ end
+ end
+end
diff --git a/db/migrate/20220708184822_cleanup_backfill_draft_status_on_merge_requests.rb b/db/migrate/20220708184822_cleanup_backfill_draft_status_on_merge_requests.rb
new file mode 100644
index 00000000000..5d91054763e
--- /dev/null
+++ b/db/migrate/20220708184822_cleanup_backfill_draft_status_on_merge_requests.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CleanupBackfillDraftStatusOnMergeRequests < Gitlab::Database::Migration[2.0]
+ def up
+ # no-op
+ #
+ # moved to post-deployment migration:
+ # db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20220712025712_update_insert_or_update_vulnerability_reads_function.rb b/db/migrate/20220712025712_update_insert_or_update_vulnerability_reads_function.rb
new file mode 100644
index 00000000000..55aeacfbecd
--- /dev/null
+++ b/db/migrate/20220712025712_update_insert_or_update_vulnerability_reads_function.rb
@@ -0,0 +1,86 @@
+# frozen_string_literal: true
+
+class UpdateInsertOrUpdateVulnerabilityReadsFunction < Gitlab::Database::Migration[2.0]
+ FUNCTION_NAME = 'insert_or_update_vulnerability_reads'
+
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION #{FUNCTION_NAME}() 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
+ end
+
+ def down
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION #{FUNCTION_NAME}() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ severity smallint;
+ state smallint;
+ report_type smallint;
+ resolved_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
+ INTO
+ severity, state, report_type, resolved_on_default_branch
+ FROM
+ vulnerabilities
+ WHERE
+ vulnerabilities.id = NEW.vulnerability_id;
+
+ 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
+ end
+end
diff --git a/db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb b/db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb
new file mode 100644
index 00000000000..68769f9e4e3
--- /dev/null
+++ b/db/migrate/20220712031923_create_vulnerability_reads_for_an_existing_vulnerability_record.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityReadsForAnExistingVulnerabilityRecord < Gitlab::Database::Migration[2.0]
+ include Gitlab::Database::SchemaHelpers
+
+ FUNCTION_NAME = 'insert_vulnerability_reads_from_vulnerability'
+ TRIGGER_NAME = 'trigger_insert_vulnerability_reads_from_vulnerability'
+
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ CREATE FUNCTION #{FUNCTION_NAME}() 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
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{TRIGGER_NAME}
+ AFTER UPDATE ON vulnerabilities
+ FOR EACH ROW
+ WHEN (
+ OLD.present_on_default_branch IS NOT true AND NEW.present_on_default_branch IS true
+ )
+ EXECUTE PROCEDURE #{FUNCTION_NAME}();
+ SQL
+ end
+
+ def down
+ drop_trigger(:vulnerabilities, TRIGGER_NAME)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/migrate/20220712094945_add_include_for_free_user_cap_preview_to_namespace_settings.rb b/db/migrate/20220712094945_add_include_for_free_user_cap_preview_to_namespace_settings.rb
new file mode 100644
index 00000000000..79e71827408
--- /dev/null
+++ b/db/migrate/20220712094945_add_include_for_free_user_cap_preview_to_namespace_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddIncludeForFreeUserCapPreviewToNamespaceSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ add_column :namespace_settings, :include_for_free_user_cap_preview, :boolean, null: false, default: false
+ end
+
+ def down
+ remove_column :namespace_settings, :include_for_free_user_cap_preview
+ end
+end
diff --git a/db/migrate/20220713175658_add_packages_cleanup_policies_worker_capacity_to_application_settings.rb b/db/migrate/20220713175658_add_packages_cleanup_policies_worker_capacity_to_application_settings.rb
new file mode 100644
index 00000000000..8768786410a
--- /dev/null
+++ b/db/migrate/20220713175658_add_packages_cleanup_policies_worker_capacity_to_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddPackagesCleanupPoliciesWorkerCapacityToApplicationSettings < Gitlab::Database::Migration[2.0]
+ def change
+ add_column :application_settings,
+ :package_registry_cleanup_policies_worker_capacity,
+ :integer,
+ default: 2,
+ null: false
+ end
+end
diff --git a/db/migrate/20220713175737_add_application_settings_packages_cleanup_policies_worker_capacity_constraint.rb b/db/migrate/20220713175737_add_application_settings_packages_cleanup_policies_worker_capacity_constraint.rb
new file mode 100644
index 00000000000..9aba85570ea
--- /dev/null
+++ b/db/migrate/20220713175737_add_application_settings_packages_cleanup_policies_worker_capacity_constraint.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddApplicationSettingsPackagesCleanupPoliciesWorkerCapacityConstraint < Gitlab::Database::Migration[2.0]
+ CONSTRAINT_NAME = 'app_settings_pkg_registry_cleanup_pol_worker_capacity_gte_zero'
+
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint :application_settings,
+ 'package_registry_cleanup_policies_worker_capacity >= 0',
+ CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :application_settings, CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20220713175812_add_enabled_policies_index_to_packages_cleanup_policies.rb b/db/migrate/20220713175812_add_enabled_policies_index_to_packages_cleanup_policies.rb
new file mode 100644
index 00000000000..fe4162e8ac3
--- /dev/null
+++ b/db/migrate/20220713175812_add_enabled_policies_index_to_packages_cleanup_policies.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddEnabledPoliciesIndexToPackagesCleanupPolicies < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'idx_enabled_pkgs_cleanup_policies_on_next_run_at_project_id'
+
+ def up
+ add_concurrent_index :packages_cleanup_policies,
+ [:next_run_at, :project_id],
+ where: "keep_n_duplicated_package_files <> 'all'",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_cleanup_policies, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220714105122_update_default_project_import_level_on_namespace_settings.rb b/db/migrate/20220714105122_update_default_project_import_level_on_namespace_settings.rb
new file mode 100644
index 00000000000..30357ded9ce
--- /dev/null
+++ b/db/migrate/20220714105122_update_default_project_import_level_on_namespace_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class UpdateDefaultProjectImportLevelOnNamespaceSettings < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ change_column :namespace_settings, :project_import_level, :smallint, default: 50, null: false
+ end
+
+ def down
+ change_column :namespace_settings, :project_import_level, :smallint, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20220714142424_update_trigger_update_vulnerability_reads_on_vulnerability_update.rb b/db/migrate/20220714142424_update_trigger_update_vulnerability_reads_on_vulnerability_update.rb
new file mode 100644
index 00000000000..00fc4ac1ed6
--- /dev/null
+++ b/db/migrate/20220714142424_update_trigger_update_vulnerability_reads_on_vulnerability_update.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+class UpdateTriggerUpdateVulnerabilityReadsOnVulnerabilityUpdate < Gitlab::Database::Migration[2.0]
+ include Gitlab::Database::SchemaHelpers
+
+ TRIGGER_NAME = 'trigger_update_vulnerability_reads_on_vulnerability_update'
+ FUNCTION_NAME = 'update_vulnerability_reads_from_vulnerability'
+
+ enable_lock_retries!
+
+ def up
+ drop_trigger(:vulnerabilities, TRIGGER_NAME)
+
+ # If the vulnerability record was not already marked as `present_on_default_branch`,
+ # we shouldn't try to update `vulnerability_records` since there will be no records
+ # anyway.
+ execute(<<~SQL)
+ CREATE TRIGGER #{TRIGGER_NAME}
+ AFTER UPDATE ON vulnerabilities
+ FOR EACH ROW
+ WHEN (
+ OLD.present_on_default_branch IS TRUE AND
+ (
+ OLD.severity IS DISTINCT FROM NEW.severity OR
+ OLD.state IS DISTINCT FROM NEW.state OR
+ OLD.resolved_on_default_branch IS DISTINCT FROM NEW.resolved_on_default_branch
+ )
+ )
+ EXECUTE PROCEDURE #{FUNCTION_NAME}();
+ SQL
+ end
+
+ def down
+ drop_trigger(:vulnerabilities, TRIGGER_NAME)
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{TRIGGER_NAME}
+ AFTER UPDATE ON vulnerabilities
+ FOR EACH ROW
+ WHEN (
+ OLD.severity IS DISTINCT FROM NEW.severity OR
+ OLD.state IS DISTINCT FROM NEW.state OR
+ OLD.resolved_on_default_branch IS DISTINCT FROM NEW.resolved_on_default_branch
+ )
+ EXECUTE PROCEDURE #{FUNCTION_NAME}();
+ SQL
+ end
+end
diff --git a/db/post_migrate/20220523164734_add_foreign_key_to_vulnerability_reads_casted_cluster_agent_id.rb b/db/post_migrate/20220523164734_add_foreign_key_to_vulnerability_reads_casted_cluster_agent_id.rb
new file mode 100644
index 00000000000..364570973ab
--- /dev/null
+++ b/db/post_migrate/20220523164734_add_foreign_key_to_vulnerability_reads_casted_cluster_agent_id.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToVulnerabilityReadsCastedClusterAgentId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerability_reads, :cluster_agents,
+ column: :casted_cluster_agent_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :vulnerability_reads, :cluster_agents, column: :casted_cluster_agent_id
+ end
+ end
+end
diff --git a/db/post_migrate/20220523165734_add_index_to_vulnerability_reads_casted_cluster_agent_id.rb b/db/post_migrate/20220523165734_add_index_to_vulnerability_reads_casted_cluster_agent_id.rb
new file mode 100644
index 00000000000..51842af3f12
--- /dev/null
+++ b/db/post_migrate/20220523165734_add_index_to_vulnerability_reads_casted_cluster_agent_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToVulnerabilityReadsCastedClusterAgentId < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_cis_vulnerability_reads_on_cluster_agent_id'
+
+ def up
+ add_concurrent_index :vulnerability_reads, :casted_cluster_agent_id, name: INDEX_NAME, where: 'report_type = 7'
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220531035113_populate_operation_visibility_permissions.rb b/db/post_migrate/20220531035113_populate_operation_visibility_permissions.rb
new file mode 100644
index 00000000000..1d385b13f75
--- /dev/null
+++ b/db/post_migrate/20220531035113_populate_operation_visibility_permissions.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class PopulateOperationVisibilityPermissions < Gitlab::Database::Migration[2.0]
+ BATCH_SIZE = 50_000
+ MAX_BATCH_SIZE = 50_000
+ SUB_BATCH_SIZE = 1_000
+ INTERVAL = 2.minutes
+ MIGRATION = 'PopulateOperationVisibilityPermissionsFromOperations'
+
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :project_features,
+ :id,
+ job_interval: INTERVAL,
+ batch_size: BATCH_SIZE,
+ max_batch_size: MAX_BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :project_features, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220601151900_schedule_backfill_ci_runner_semver.rb b/db/post_migrate/20220601151900_schedule_backfill_ci_runner_semver.rb
new file mode 100644
index 00000000000..9c62ec1b87b
--- /dev/null
+++ b/db/post_migrate/20220601151900_schedule_backfill_ci_runner_semver.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class ScheduleBackfillCiRunnerSemver < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_ci
+
+ MIGRATION = 'BackfillCiRunnerSemver'
+ INTERVAL = 2.minutes.freeze
+ BATCH_SIZE = 500
+ MAX_BATCH_SIZE = 10_000
+ SUB_BATCH_SIZE = 100
+
+ disable_ddl_transaction!
+
+ def up
+ # Disabled background migration introduced in same milestone as it was decided to change approach
+ # and the semver column will no longer be needed
+ # queue_batched_background_migration(
+ # MIGRATION,
+ # :ci_runners,
+ # :id,
+ # job_interval: INTERVAL,
+ # batch_size: BATCH_SIZE,
+ # max_batch_size: MAX_BATCH_SIZE,
+ # sub_batch_size: SUB_BATCH_SIZE
+ # )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :ci_runners, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb b/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb
new file mode 100644
index 00000000000..aa860959c20
--- /dev/null
+++ b/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddUserIdAndIpAddressSuccessIndexToAuthenticationEvents < Gitlab::Database::Migration[2.0]
+ OLD_INDEX_NAME = 'index_authentication_events_on_user_id'
+ NEW_INDEX_NAME = 'index_authentication_events_on_user_and_ip_address_and_result'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :authentication_events, [:user_id, :ip_address, :result], name: NEW_INDEX_NAME
+ remove_concurrent_index_by_name :authentication_events, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :authentication_events, :user_id, name: OLD_INDEX_NAME
+ remove_concurrent_index_by_name :authentication_events, NEW_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220606082910_add_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb b/db/post_migrate/20220606082910_add_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..1207b51f190
--- /dev/null
+++ b/db/post_migrate/20220606082910_add_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences < 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
+ prepare_async_index :vulnerability_occurrences,
+ [:id, :scanner_id],
+ where: CLAUSE,
+ name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index_by_name :vulnerability_occurrences, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617123022_add_unique_index_on_projects_on_runners_token.rb b/db/post_migrate/20220617123022_add_unique_index_on_projects_on_runners_token.rb
new file mode 100644
index 00000000000..1e0409b16ea
--- /dev/null
+++ b/db/post_migrate/20220617123022_add_unique_index_on_projects_on_runners_token.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexOnProjectsOnRunnersToken < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_uniq_projects_on_runners_token'
+
+ def up
+ add_concurrent_index :projects,
+ :runners_token,
+ name: INDEX_NAME,
+ unique: true
+ end
+
+ def down
+ remove_concurrent_index_by_name :projects, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617123034_add_unique_index_on_projects_on_runners_token_encrypted.rb b/db/post_migrate/20220617123034_add_unique_index_on_projects_on_runners_token_encrypted.rb
new file mode 100644
index 00000000000..b9ba570606e
--- /dev/null
+++ b/db/post_migrate/20220617123034_add_unique_index_on_projects_on_runners_token_encrypted.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexOnProjectsOnRunnersTokenEncrypted < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_uniq_projects_on_runners_token_encrypted'
+
+ def up
+ add_concurrent_index :projects,
+ :runners_token_encrypted,
+ name: INDEX_NAME,
+ unique: true
+ end
+
+ def down
+ remove_concurrent_index_by_name :projects, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617123105_drop_index_on_projects_on_runners_token.rb b/db/post_migrate/20220617123105_drop_index_on_projects_on_runners_token.rb
new file mode 100644
index 00000000000..6b76a92a9f4
--- /dev/null
+++ b/db/post_migrate/20220617123105_drop_index_on_projects_on_runners_token.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropIndexOnProjectsOnRunnersToken < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_projects_on_runners_token'
+
+ def up
+ remove_concurrent_index_by_name :projects, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :projects,
+ :runners_token,
+ name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617123113_drop_index_on_projects_on_runners_token_encrypted.rb b/db/post_migrate/20220617123113_drop_index_on_projects_on_runners_token_encrypted.rb
new file mode 100644
index 00000000000..213f55bfcc4
--- /dev/null
+++ b/db/post_migrate/20220617123113_drop_index_on_projects_on_runners_token_encrypted.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropIndexOnProjectsOnRunnersTokenEncrypted < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_projects_on_runners_token_encrypted'
+
+ def up
+ remove_concurrent_index_by_name :projects, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :projects,
+ :runners_token_encrypted,
+ name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb b/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb
new file mode 100644
index 00000000000..e74c6c0935e
--- /dev/null
+++ b/db/post_migrate/20220617142124_add_index_on_installable_package_files.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddIndexOnInstallablePackageFiles < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'idx_pkgs_installable_package_files_on_package_id_id_file_name'
+ # See https://gitlab.com/gitlab-org/gitlab/-/blob/e3ed2c1f65df2e137fc714485d7d42264a137968/app/models/packages/package_file.rb#L16
+ DEFAULT_STATUS = 0
+
+ def up
+ add_concurrent_index :packages_package_files,
+ [:package_id, :id, :file_name],
+ where: "(status = #{DEFAULT_STATUS})",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_package_files, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb b/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb
new file mode 100644
index 00000000000..d1e70f04468
--- /dev/null
+++ b/db/post_migrate/20220617143228_replace_packages_index_on_project_id_and_status.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ReplacePackagesIndexOnProjectIdAndStatus < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'index_packages_packages_on_project_id_and_status_and_id'
+ OLD_INDEX_NAME = 'index_packages_packages_on_project_id_and_status'
+
+ def up
+ add_concurrent_index :packages_packages,
+ [:project_id, :status, :id],
+ name: NEW_INDEX_NAME
+ remove_concurrent_index_by_name :packages_packages, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :packages_packages,
+ [:project_id, :status],
+ name: OLD_INDEX_NAME
+ remove_concurrent_index_by_name :packages_packages, NEW_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220620060633_finalize_orphaned_routes_cleanup.rb b/db/post_migrate/20220620060633_finalize_orphaned_routes_cleanup.rb
new file mode 100644
index 00000000000..4a3218af2c0
--- /dev/null
+++ b/db/post_migrate/20220620060633_finalize_orphaned_routes_cleanup.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class FinalizeOrphanedRoutesCleanup < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ MIGRATION = 'CleanupOrphanedRoutes'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: MIGRATION,
+ table_name: :routes,
+ column_name: :id,
+ job_arguments: []
+ )
+ end
+
+ def down
+ # noop
+ end
+end
diff --git a/db/post_migrate/20220620132300_update_last_run_date_for_iterations_cadences.rb b/db/post_migrate/20220620132300_update_last_run_date_for_iterations_cadences.rb
new file mode 100644
index 00000000000..50b0b25d469
--- /dev/null
+++ b/db/post_migrate/20220620132300_update_last_run_date_for_iterations_cadences.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class UpdateLastRunDateForIterationsCadences < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ execute <<~SQL
+ UPDATE iterations_cadences SET last_run_date=CURRENT_DATE WHERE automatic=true;
+ SQL
+ end
+
+ def down
+ # no op
+ # 'last_run_date' stores the date on which the cadence record should be
+ # updated using `CreateIterationsInAdvance` service that is idempotent
+ # and the column is only useful for optimizing when to run the service
+ # ('last_run_date' is also a misnomer as it can be better-named 'next_run_date'.)
+ end
+end
diff --git a/db/post_migrate/20220620151740_add_indexes_issues_on_project_id_and_closed_at.rb b/db/post_migrate/20220620151740_add_indexes_issues_on_project_id_and_closed_at.rb
new file mode 100644
index 00000000000..066e72dce45
--- /dev/null
+++ b/db/post_migrate/20220620151740_add_indexes_issues_on_project_id_and_closed_at.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class AddIndexesIssuesOnProjectIdAndClosedAt < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ OLD_INDEX_NAME = 'index_issues_on_project_id_and_closed_at'
+ NEW_INDEX_NAME_1 = 'index_issues_on_project_id_closed_at_desc_state_id_and_id'
+ NEW_INDEX_NAME_2 = 'index_issues_on_project_id_closed_at_state_id_and_id'
+
+ def up
+ # Index to improve performance when sorting issues by closed_at desc
+ unless index_exists_by_name?(:issues, NEW_INDEX_NAME_1)
+ add_concurrent_index :issues, 'project_id, closed_at DESC NULLS LAST, state_id, id', name: NEW_INDEX_NAME_1
+ end
+
+ # Index to improve performance when sorting issues by closed_at asc
+ # This replaces the old index which didn't account for state_id and id
+ unless index_exists_by_name?(:issues, NEW_INDEX_NAME_2)
+ add_concurrent_index :issues, [:project_id, :closed_at, :state_id, :id], name: NEW_INDEX_NAME_2
+ end
+
+ remove_concurrent_index_by_name :issues, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :issues, [:project_id, :closed_at], name: OLD_INDEX_NAME
+
+ remove_concurrent_index_by_name :issues, NEW_INDEX_NAME_1
+ remove_concurrent_index_by_name :issues, NEW_INDEX_NAME_2
+ end
+end
diff --git a/db/post_migrate/20220621040800_backfill_imported_issue_search_data.rb b/db/post_migrate/20220621040800_backfill_imported_issue_search_data.rb
new file mode 100644
index 00000000000..bc7d0eb3a13
--- /dev/null
+++ b/db/post_migrate/20220621040800_backfill_imported_issue_search_data.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class BackfillImportedIssueSearchData < Gitlab::Database::Migration[2.0]
+ def up
+ # replaced by 20220707075300_reschedule_backfill_imported_issue_search_data.rb
+ end
+
+ def down
+ # replaced by 20220707075300_reschedule_backfill_imported_issue_search_data.rb
+ end
+end
diff --git a/db/post_migrate/20220621082245_remove_tmp_index_on_routes_namespace_id_column.rb b/db/post_migrate/20220621082245_remove_tmp_index_on_routes_namespace_id_column.rb
new file mode 100644
index 00000000000..4aa125d3c14
--- /dev/null
+++ b/db/post_migrate/20220621082245_remove_tmp_index_on_routes_namespace_id_column.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveTmpIndexOnRoutesNamespaceIdColumn < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'tmp_index_for_namespace_id_migration_on_routes'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :routes, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :routes,
+ :id,
+ where: "routes.namespace_id is null and routes.source_type = 'Namespace'",
+ name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220621092245_validate_not_null_constraint_on_routes_namespace_id_column.rb b/db/post_migrate/20220621092245_validate_not_null_constraint_on_routes_namespace_id_column.rb
new file mode 100644
index 00000000000..73e2f6b2b38
--- /dev/null
+++ b/db/post_migrate/20220621092245_validate_not_null_constraint_on_routes_namespace_id_column.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class ValidateNotNullConstraintOnRoutesNamespaceIdColumn < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ validate_not_null_constraint :routes, :namespace_id
+ end
+
+ def down
+ remove_not_null_constraint :routes, :namespace_id
+ add_not_null_constraint :routes, :namespace_id, validate: false
+ 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
new file mode 100644
index 00000000000..64cdd75f5a7
--- /dev/null
+++ b/db/post_migrate/20220622070547_add_temp_index_for_container_registry_size_migration.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddTempIndexForContainerRegistrySizeMigration < Gitlab::Database::Migration[2.0]
+ INDEX_CONTAINER_REGISTRY_SIZE = 'tmp_index_migrated_container_registries'
+ INDEX_PROJECT_STATS_CONT_REG_SIZE = 'tmp_index_project_statistics_cont_registry_size'
+
+ disable_ddl_transaction!
+
+ 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"
+ end
+
+ def down
+ remove_concurrent_index_by_name :container_repositories, INDEX_CONTAINER_REGISTRY_SIZE
+ remove_concurrent_index_by_name :project_statistics, INDEX_PROJECT_STATS_CONT_REG_SIZE
+ end
+end
diff --git a/db/post_migrate/20220622080547_backfill_project_statistics_with_container_registry_size.rb b/db/post_migrate/20220622080547_backfill_project_statistics_with_container_registry_size.rb
new file mode 100644
index 00000000000..2cab7ae25f5
--- /dev/null
+++ b/db/post_migrate/20220622080547_backfill_project_statistics_with_container_registry_size.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class BackfillProjectStatisticsWithContainerRegistrySize < 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?
+
+ 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/20220624062300_delete_backfill_ci_runner_semver_migration.rb b/db/post_migrate/20220624062300_delete_backfill_ci_runner_semver_migration.rb
new file mode 100644
index 00000000000..4632d9104ea
--- /dev/null
+++ b/db/post_migrate/20220624062300_delete_backfill_ci_runner_semver_migration.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class DeleteBackfillCiRunnerSemverMigration < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_ci
+
+ MIGRATION = 'BackfillCiRunnerSemver'
+
+ disable_ddl_transaction!
+
+ def up
+ # Disabled background migration introduced in same milestone as it was decided to change approach
+ # and the semver column will no longer be needed
+ delete_batched_background_migration(MIGRATION, :ci_runners, :id, [])
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20220627090231_schedule_disable_legacy_open_source_license_for_inactive_public_projects.rb b/db/post_migrate/20220627090231_schedule_disable_legacy_open_source_license_for_inactive_public_projects.rb
new file mode 100644
index 00000000000..06bdb78698d
--- /dev/null
+++ b/db/post_migrate/20220627090231_schedule_disable_legacy_open_source_license_for_inactive_public_projects.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class ScheduleDisableLegacyOpenSourceLicenseForInactivePublicProjects < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'DisableLegacyOpenSourceLicenseForInactivePublicProjects'
+ INTERVAL = 2.minutes
+ BATCH_SIZE = 1_000
+ MAX_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,
+ 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/20220627152642_queue_update_delayed_project_removal_to_null_for_user_namespace.rb b/db/post_migrate/20220627152642_queue_update_delayed_project_removal_to_null_for_user_namespace.rb
new file mode 100644
index 00000000000..2f407b78b6d
--- /dev/null
+++ b/db/post_migrate/20220627152642_queue_update_delayed_project_removal_to_null_for_user_namespace.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class QueueUpdateDelayedProjectRemovalToNullForUserNamespace < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'UpdateDelayedProjectRemovalToNullForUserNamespaces'
+ INTERVAL = 2.minutes
+ BATCH_SIZE = 10_000
+
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :namespace_settings,
+ :namespace_id,
+ job_interval: INTERVAL,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :namespace_settings, :namespace_id, [])
+ end
+end
diff --git a/db/post_migrate/20220627223041_add_post_migrate_test_table.rb b/db/post_migrate/20220627223041_add_post_migrate_test_table.rb
new file mode 100644
index 00000000000..8d97444f8c1
--- /dev/null
+++ b/db/post_migrate/20220627223041_add_post_migrate_test_table.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddPostMigrateTestTable < Gitlab::Database::Migration[2.0]
+ # Fake table to be used for testing the post-deploy pipeline,
+ # details can be seen on https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/2352.
+ #
+ # It should be deleted after the testing is completed.
+ def change
+ create_table :post_migration_test_table do |t|
+ t.integer :status, null: false
+ end
+ end
+end
diff --git a/db/post_migrate/20220628012902_finalise_project_namespace_members.rb b/db/post_migrate/20220628012902_finalise_project_namespace_members.rb
new file mode 100644
index 00000000000..29b11fb4357
--- /dev/null
+++ b/db/post_migrate/20220628012902_finalise_project_namespace_members.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class FinaliseProjectNamespaceMembers < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'BackfillProjectMemberNamespaceId'
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: MIGRATION,
+ table_name: :members,
+ column_name: :id,
+ job_arguments: [],
+ finalize: true
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20220628110823_add_issues_namespace_id_fk_and_index.rb b/db/post_migrate/20220628110823_add_issues_namespace_id_fk_and_index.rb
new file mode 100644
index 00000000000..5a7ca428383
--- /dev/null
+++ b/db/post_migrate/20220628110823_add_issues_namespace_id_fk_and_index.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddIssuesNamespaceIdFkAndIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+ INDEX_NAME = 'index_issues_on_namespace_id'
+
+ def up
+ add_concurrent_index :issues, :namespace_id, name: INDEX_NAME
+ add_concurrent_foreign_key :issues, :namespaces,
+ column: :namespace_id,
+ on_delete: :nullify,
+ reverse_lock_order: true
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :issues, column: :namespace_id
+ end
+
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220628111752_drop_token_index_from_ci_builds.rb b/db/post_migrate/20220628111752_drop_token_index_from_ci_builds.rb
new file mode 100644
index 00000000000..d551eeebeb6
--- /dev/null
+++ b/db/post_migrate/20220628111752_drop_token_index_from_ci_builds.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropTokenIndexFromCiBuilds < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_builds_on_token_partial'
+
+ def up
+ remove_concurrent_index_by_name :ci_builds, INDEX_NAME
+ end
+
+ # rubocop:disable Migration/PreventIndexCreation
+ def down
+ add_concurrent_index :ci_builds, :token, unique: true, where: 'token IS NOT NULL', name: INDEX_NAME
+ end
+ # rubocop:enable Migration/PreventIndexCreation
+end
diff --git a/db/post_migrate/20220628122622_rename_builds_sidekiq_queues_to_namespaces.rb b/db/post_migrate/20220628122622_rename_builds_sidekiq_queues_to_namespaces.rb
new file mode 100644
index 00000000000..f692d1476ce
--- /dev/null
+++ b/db/post_migrate/20220628122622_rename_builds_sidekiq_queues_to_namespaces.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class RenameBuildsSidekiqQueuesToNamespaces < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ BUILD_OLD_QUEUE = 'pipeline_processing:build_finished'
+ BUILD_NEW_QUEUE = 'pipeline_processing:ci_build_finished'
+
+ TRACE_OLD_QUEUE = 'pipeline_background:archive_trace'
+ TRACE_NEW_QUEUE = 'pipeline_background:ci_archive_trace'
+
+ def up
+ sidekiq_queue_migrate BUILD_OLD_QUEUE, to: BUILD_NEW_QUEUE
+ sidekiq_queue_migrate TRACE_OLD_QUEUE, to: TRACE_NEW_QUEUE
+ end
+
+ def down
+ sidekiq_queue_migrate BUILD_NEW_QUEUE, to: BUILD_OLD_QUEUE
+ sidekiq_queue_migrate TRACE_NEW_QUEUE, to: TRACE_OLD_QUEUE
+ end
+end
diff --git a/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb b/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb
new file mode 100644
index 00000000000..89adc4b2703
--- /dev/null
+++ b/db/post_migrate/20220629184402_unset_escalation_policies_for_alert_incidents.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+class UnsetEscalationPoliciesForAlertIncidents < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class EscalationStatus < MigrationRecord
+ include EachBatch
+
+ self.table_name = 'incident_management_issuable_escalation_statuses'
+
+ scope :having_alert_policy, -> do
+ joins(
+ 'INNER JOIN alert_management_alerts ' \
+ 'ON alert_management_alerts.issue_id ' \
+ '= incident_management_issuable_escalation_statuses.issue_id'
+ )
+ end
+ end
+
+ def up
+ EscalationStatus.each_batch do |escalation_statuses|
+ escalation_statuses
+ .where.not(policy_id: nil)
+ .having_alert_policy
+ .update_all(policy_id: nil, escalations_started_at: nil)
+ end
+ end
+
+ def down
+ # no-op
+ #
+ # We cannot retrieve the exact nullified values. We could
+ # approximately guess what the values are via the alert's
+ # escalation policy. However, that may not be accurate
+ # in all cases, as an alert's escalation policy is implictly
+ # inferred from the project rather than explicit, like an incident.
+ # So we won't backfill potentially incorrect data.
+ #
+ # This data is functionally safe to delete, as the relevant
+ # fields are read-only, and exclusively informational.
+ #
+ # Re-running the migration will have no effect.
+ end
+end
diff --git a/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb b/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb
new file mode 100644
index 00000000000..58b6342e30f
--- /dev/null
+++ b/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class IndexVulnerabilityReadsOnCastedClusterAgentIdFull < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_vuln_reads_on_casted_cluster_agent_id_where_it_is_null'
+
+ def up
+ add_concurrent_index :vulnerability_reads,
+ :casted_cluster_agent_id,
+ name: INDEX_NAME,
+ where: 'casted_cluster_agent_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220630085003_drop_project_successfull_pages_deploy_index_from_ci_builds.rb b/db/post_migrate/20220630085003_drop_project_successfull_pages_deploy_index_from_ci_builds.rb
new file mode 100644
index 00000000000..0810419a4e8
--- /dev/null
+++ b/db/post_migrate/20220630085003_drop_project_successfull_pages_deploy_index_from_ci_builds.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class DropProjectSuccessfullPagesDeployIndexFromCiBuilds < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_builds_on_project_id_for_successfull_pages_deploy'
+
+ def up
+ remove_concurrent_index_by_name :ci_builds, INDEX_NAME
+ end
+
+ # rubocop:disable Migration/PreventIndexCreation
+ def down
+ add_concurrent_index :ci_builds,
+ :project_id,
+ where: "(((type)::text = 'GenericCommitStatus'::text) AND ((stage)::text = 'deploy'::text) AND " \
+ "((name)::text = 'pages:deploy'::text) AND ((status)::text = 'success'::text))",
+ name: INDEX_NAME
+ end
+ # rubocop:enable Migration/PreventIndexCreation
+end
diff --git a/db/post_migrate/20220630091409_add_index_on_events_for_contribution_analytics_optimization.rb b/db/post_migrate/20220630091409_add_index_on_events_for_contribution_analytics_optimization.rb
new file mode 100644
index 00000000000..de16b17f489
--- /dev/null
+++ b/db/post_migrate/20220630091409_add_index_on_events_for_contribution_analytics_optimization.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnEventsForContributionAnalyticsOptimization < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_on_events_to_improve_contribution_analytics_performance'
+
+ def up
+ add_concurrent_index :events, [:project_id, :target_type, :action, :created_at, :author_id, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :events, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220630151641_schedule_set_correct_vulnerability_state.rb b/db/post_migrate/20220630151641_schedule_set_correct_vulnerability_state.rb
new file mode 100644
index 00000000000..7c9211ff282
--- /dev/null
+++ b/db/post_migrate/20220630151641_schedule_set_correct_vulnerability_state.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class ScheduleSetCorrectVulnerabilityState < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ MAX_BATCH_SIZE = 5_000
+ JOB_INTERVAL = 2.minutes
+ MIGRATION_NAME = 'SetCorrectVulnerabilityState'
+ BATCH_CLASS_NAME = 'DismissedVulnerabilitiesStrategy'
+ SUB_BATCH_SIZE = 100
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION_NAME,
+ :vulnerabilities,
+ :id,
+ job_interval: JOB_INTERVAL,
+ batch_size: MAX_BATCH_SIZE,
+ max_batch_size: MAX_BATCH_SIZE,
+ batch_class_name: BATCH_CLASS_NAME,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION_NAME, :vulnerabilities, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220701085523_schedule_index_on_events_for_contribution_analytics_optimization.rb b/db/post_migrate/20220701085523_schedule_index_on_events_for_contribution_analytics_optimization.rb
new file mode 100644
index 00000000000..10be7a25965
--- /dev/null
+++ b/db/post_migrate/20220701085523_schedule_index_on_events_for_contribution_analytics_optimization.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ScheduleIndexOnEventsForContributionAnalyticsOptimization < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_on_events_to_improve_contribution_analytics_performance'
+
+ def up
+ prepare_async_index :events, [:project_id, :target_type, :action, :created_at, :author_id, :id], name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :events, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220703182314_add_check_constraint_for_security_findings_partition_number.rb b/db/post_migrate/20220703182314_add_check_constraint_for_security_findings_partition_number.rb
new file mode 100644
index 00000000000..82b5d0b165d
--- /dev/null
+++ b/db/post_migrate/20220703182314_add_check_constraint_for_security_findings_partition_number.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddCheckConstraintForSecurityFindingsPartitionNumber < Gitlab::Database::Migration[2.0]
+ CONSTRAINT_NAME = 'check_partition_number'
+
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint(:security_findings, 'partition_number = 1', CONSTRAINT_NAME)
+ end
+
+ def down
+ remove_check_constraint(:security_findings, CONSTRAINT_NAME)
+ end
+end
diff --git a/db/post_migrate/20220704044408_remove_foreign_key_in_project_tracing_settings.rb b/db/post_migrate/20220704044408_remove_foreign_key_in_project_tracing_settings.rb
new file mode 100644
index 00000000000..95eb461238f
--- /dev/null
+++ b/db/post_migrate/20220704044408_remove_foreign_key_in_project_tracing_settings.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class RemoveForeignKeyInProjectTracingSettings < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(:project_tracing_settings, column: :project_id)
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key :project_tracing_settings, :projects,
+ column: :project_id, on_delete: :cascade, name: 'fk_rails_fe56f57fc6'
+ end
+end
diff --git a/db/post_migrate/20220704045440_drop_project_tracing_settings_table.rb b/db/post_migrate/20220704045440_drop_project_tracing_settings_table.rb
new file mode 100644
index 00000000000..1ce8b05a08d
--- /dev/null
+++ b/db/post_migrate/20220704045440_drop_project_tracing_settings_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropProjectTracingSettingsTable < Gitlab::Database::Migration[2.0]
+ def up
+ drop_table :project_tracing_settings
+ end
+
+ def down
+ create_table :project_tracing_settings, id: :bigserial do |t|
+ t.timestamps_with_timezone null: false
+
+ t.references :project, type: :integer, null: false, index: { unique: true }
+
+ t.string :external_url, null: false
+ end
+ end
+end
diff --git a/db/post_migrate/20220705114635_drop_index_on_ci_runner_versions_on_version.rb b/db/post_migrate/20220705114635_drop_index_on_ci_runner_versions_on_version.rb
new file mode 100644
index 00000000000..22ff65f6fc3
--- /dev/null
+++ b/db/post_migrate/20220705114635_drop_index_on_ci_runner_versions_on_version.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DropIndexOnCiRunnerVersionsOnVersion < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_runner_versions_on_version'
+
+ def up
+ remove_concurrent_index_by_name :ci_runner_versions, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :ci_runner_versions, :version, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220705180843_validate_requirements_issue_id_not_null.rb b/db/post_migrate/20220705180843_validate_requirements_issue_id_not_null.rb
new file mode 100644
index 00000000000..a0c8954b481
--- /dev/null
+++ b/db/post_migrate/20220705180843_validate_requirements_issue_id_not_null.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ValidateRequirementsIssueIdNotNull < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ constraint_name = 'check_requirement_issue_not_null'
+
+ validate_not_null_constraint(:requirements, :issue_id, constraint_name: constraint_name)
+ end
+
+ def down
+ # No op
+ end
+end
diff --git a/db/post_migrate/20220706065245_remove_foreign_key_in_clusters_applications_elastic_stacks.rb b/db/post_migrate/20220706065245_remove_foreign_key_in_clusters_applications_elastic_stacks.rb
new file mode 100644
index 00000000000..bfe60099bfa
--- /dev/null
+++ b/db/post_migrate/20220706065245_remove_foreign_key_in_clusters_applications_elastic_stacks.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class RemoveForeignKeyInClustersApplicationsElasticStacks < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(:clusters_applications_elastic_stacks, column: :cluster_id)
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key :clusters_applications_elastic_stacks, :clusters,
+ column: :cluster_id, on_delete: :cascade, name: 'fk_rails_026f219f46'
+ end
+end
diff --git a/db/post_migrate/20220706065611_remove_foreign_key_in_clusters_integration_elasticstack.rb b/db/post_migrate/20220706065611_remove_foreign_key_in_clusters_integration_elasticstack.rb
new file mode 100644
index 00000000000..eeec465f6b9
--- /dev/null
+++ b/db/post_migrate/20220706065611_remove_foreign_key_in_clusters_integration_elasticstack.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class RemoveForeignKeyInClustersIntegrationElasticstack < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(:clusters_integration_elasticstack, column: :cluster_id)
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key :clusters_integration_elasticstack, :clusters,
+ column: :cluster_id, on_delete: :cascade, name: 'fk_rails_cc5ba8f658'
+ end
+end
diff --git a/db/post_migrate/20220706070804_drop_clusters_applications_elastic_stacks_table.rb b/db/post_migrate/20220706070804_drop_clusters_applications_elastic_stacks_table.rb
new file mode 100644
index 00000000000..cedf666e428
--- /dev/null
+++ b/db/post_migrate/20220706070804_drop_clusters_applications_elastic_stacks_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropClustersApplicationsElasticStacksTable < Gitlab::Database::Migration[2.0]
+ def up
+ drop_table :clusters_applications_elastic_stacks
+ end
+
+ def down
+ create_table :clusters_applications_elastic_stacks do |t|
+ t.timestamps_with_timezone null: false
+ t.references :cluster, type: :bigint, null: false, index: { unique: true }
+ t.integer :status, null: false
+ t.string :version, null: false, limit: 255
+ t.text :status_reason
+ end
+ end
+end
diff --git a/db/post_migrate/20220706071304_drop_clusters_integration_elasticstack_table.rb b/db/post_migrate/20220706071304_drop_clusters_integration_elasticstack_table.rb
new file mode 100644
index 00000000000..206652b5dcf
--- /dev/null
+++ b/db/post_migrate/20220706071304_drop_clusters_integration_elasticstack_table.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class DropClustersIntegrationElasticstackTable < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_clusters_integration_elasticstack_enabled'
+
+ def up
+ drop_table :clusters_integration_elasticstack
+ end
+
+ def down
+ create_table :clusters_integration_elasticstack, id: false do |t|
+ t.timestamps_with_timezone null: false
+ t.references :cluster, primary_key: true, type: :bigint, default: nil, index: false
+ t.boolean :enabled, null: false, default: false
+ t.text :chart_version, limit: 10
+ end
+
+ add_concurrent_index(:clusters_integration_elasticstack, [:enabled, :created_at, :cluster_id], name: INDEX_NAME)
+ end
+end
diff --git a/db/post_migrate/20220706115138_create_async_index_on_security_findings.rb b/db/post_migrate/20220706115138_create_async_index_on_security_findings.rb
new file mode 100644
index 00000000000..30baa1af91c
--- /dev/null
+++ b/db/post_migrate/20220706115138_create_async_index_on_security_findings.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateAsyncIndexOnSecurityFindings < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_on_security_findings_uuid_and_id_order_desc'
+
+ def up
+ prepare_async_index(
+ :security_findings,
+ %i[uuid id],
+ order: { id: :desc },
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ unprepare_async_index(
+ :security_findings,
+ %i[uuid id],
+ name: INDEX_NAME
+ )
+ end
+end
diff --git a/db/post_migrate/20220706122719_create_index_on_security_findings_uuid_id_desc.rb b/db/post_migrate/20220706122719_create_index_on_security_findings_uuid_id_desc.rb
new file mode 100644
index 00000000000..0c2e2cb4b70
--- /dev/null
+++ b/db/post_migrate/20220706122719_create_index_on_security_findings_uuid_id_desc.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class CreateIndexOnSecurityFindingsUuidIdDesc < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_on_security_findings_uuid_and_id_order_desc'
+
+ def up
+ add_concurrent_index(
+ :security_findings,
+ %i[uuid id],
+ order: { id: :desc },
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name(
+ :security_findings,
+ INDEX_NAME
+ )
+ end
+end
diff --git a/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb b/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb
new file mode 100644
index 00000000000..48dc5b5d84a
--- /dev/null
+++ b/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class AddIndicesOnSecurityScansInfoColumn < Gitlab::Database::Migration[2.0]
+ INDEX_NAME_ON_ERRORS = :index_security_scans_on_length_of_errors
+ INDEX_NAME_ON_WARNINGS = :index_security_scans_on_length_of_warnings
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(
+ :security_scans,
+ "pipeline_id, jsonb_array_length(COALESCE((security_scans.info -> 'errors'::text), '[]'::jsonb))",
+ name: INDEX_NAME_ON_ERRORS
+ )
+
+ add_concurrent_index(
+ :security_scans,
+ "pipeline_id, jsonb_array_length(COALESCE((security_scans.info -> 'warnings'::text), '[]'::jsonb))",
+ name: INDEX_NAME_ON_WARNINGS
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name :security_scans, INDEX_NAME_ON_ERRORS
+ remove_concurrent_index_by_name :security_scans, INDEX_NAME_ON_WARNINGS
+ end
+end
diff --git a/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb b/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb
new file mode 100644
index 00000000000..b5124ce667c
--- /dev/null
+++ b/db/post_migrate/20220707075300_reschedule_backfill_imported_issue_search_data.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class RescheduleBackfillImportedIssueSearchData < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ MIGRATION = 'BackfillImportedIssueSearchData'
+ DELAY_INTERVAL = 120.seconds
+ BATCH_SIZE = 50_000
+ SUB_BATCH_SIZE = 1_000
+
+ def up
+ # remove the original migration
+ delete_batched_background_migration(MIGRATION, :issues, :id, [])
+
+ # reschedule the migration
+ min_value = Gitlab::Database::BackgroundMigration::BatchedMigration.find_by(
+ job_class_name: "BackfillIssueSearchData"
+ )&.max_value || BATCH_MIN_VALUE
+
+ queue_batched_background_migration(
+ MIGRATION,
+ :issues,
+ :id,
+ job_interval: DELAY_INTERVAL,
+ batch_min_value: min_value,
+ batch_size: BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :issues, :id, [])
+ end
+end
diff --git a/db/post_migrate/20220708100508_drop_index_on_ci_runner_versions_on_status.rb b/db/post_migrate/20220708100508_drop_index_on_ci_runner_versions_on_status.rb
new file mode 100644
index 00000000000..71eb5a0867e
--- /dev/null
+++ b/db/post_migrate/20220708100508_drop_index_on_ci_runner_versions_on_status.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DropIndexOnCiRunnerVersionsOnStatus < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_runner_versions_on_status'
+
+ def up
+ remove_concurrent_index_by_name :ci_runner_versions, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :ci_runner_versions, :version, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb b/db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb
new file mode 100644
index 00000000000..eb612a98ae6
--- /dev/null
+++ b/db/post_migrate/20220713133515_cleanup_backfill_draft_statuses_on_merge_requests.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CleanupBackfillDraftStatusesOnMergeRequests < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ MIGRATION = 'BackfillDraftStatusOnMergeRequests'
+
+ def up
+ finalize_background_migration(MIGRATION)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20220714122311_add_async_index_on_security_findings_id_and_partition_number.rb b/db/post_migrate/20220714122311_add_async_index_on_security_findings_id_and_partition_number.rb
new file mode 100644
index 00000000000..02d18ba8b40
--- /dev/null
+++ b/db/post_migrate/20220714122311_add_async_index_on_security_findings_id_and_partition_number.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddAsyncIndexOnSecurityFindingsIdAndPartitionNumber < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'security_findings_partitioned_pkey'
+
+ disable_ddl_transaction!
+
+ def up
+ prepare_async_index :security_findings, [:id, :partition_number], unique: true, name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index_by_name :security_findings, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220714122418_add_async_index_on_security_findings_unique_columns.rb b/db/post_migrate/20220714122418_add_async_index_on_security_findings_unique_columns.rb
new file mode 100644
index 00000000000..e21d3db6798
--- /dev/null
+++ b/db/post_migrate/20220714122418_add_async_index_on_security_findings_unique_columns.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddAsyncIndexOnSecurityFindingsUniqueColumns < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_security_findings_on_unique_columns'
+
+ disable_ddl_transaction!
+
+ def up
+ prepare_async_index :security_findings, [:uuid, :scan_id, :partition_number], unique: true, name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index_by_name :security_findings, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb b/db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb
new file mode 100644
index 00000000000..ed5b85b711c
--- /dev/null
+++ b/db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddParentLinkUniqueWorkItemIndex < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_work_item_parent_links_on_work_item_id'
+ OLD_INDEX_NAME = 'index_parent_links_on_work_item_id_and_work_item_parent_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :work_item_parent_links, :work_item_id, unique: true, name: INDEX_NAME
+ remove_concurrent_index_by_name :work_item_parent_links, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :work_item_parent_links, [:work_item_id, :work_item_parent_id],
+ unique: true, name: OLD_INDEX_NAME
+ remove_concurrent_index_by_name :work_item_parent_links, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20220715160023_drop_post_migration_test_table.rb b/db/post_migrate/20220715160023_drop_post_migration_test_table.rb
new file mode 100644
index 00000000000..98b4cbcf972
--- /dev/null
+++ b/db/post_migrate/20220715160023_drop_post_migration_test_table.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class DropPostMigrationTestTable < Gitlab::Database::Migration[2.0]
+ def up
+ drop_table :post_migration_test_table
+ end
+
+ def down
+ create_table :post_migration_test_table do |t|
+ t.integer :status, null: false
+ end
+ end
+end
diff --git a/db/post_migrate/20220715163254_update_notes_in_past.rb b/db/post_migrate/20220715163254_update_notes_in_past.rb
new file mode 100644
index 00000000000..1c46a3bc9dc
--- /dev/null
+++ b/db/post_migrate/20220715163254_update_notes_in_past.rb
@@ -0,0 +1,22 @@
+# 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 UpdateNotesInPast < Gitlab::Database::Migration[2.0]
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ loop do
+ update_count = define_batchable_model('notes')
+ .where('created_at < ?', '1970-01-01').limit(100)
+ .update_all(created_at: '1970-01-01 00:00:00')
+
+ break if update_count == 0
+ end
+ end
+
+ def down
+ # no op
+ end
+end
diff --git a/db/schema_migrations/20220523162734 b/db/schema_migrations/20220523162734
new file mode 100644
index 00000000000..dd319042965
--- /dev/null
+++ b/db/schema_migrations/20220523162734
@@ -0,0 +1 @@
+af6f954426b714649a3b19e80a20cf99475cdc8496c23add8032cda27072d31d \ No newline at end of file
diff --git a/db/schema_migrations/20220523163734 b/db/schema_migrations/20220523163734
new file mode 100644
index 00000000000..622ea4abb95
--- /dev/null
+++ b/db/schema_migrations/20220523163734
@@ -0,0 +1 @@
+02821039feda457c1fb61dc6ff62756752c0c1c0ad01e12ecf28c265462529d4 \ No newline at end of file
diff --git a/db/schema_migrations/20220523164734 b/db/schema_migrations/20220523164734
new file mode 100644
index 00000000000..3538f55712d
--- /dev/null
+++ b/db/schema_migrations/20220523164734
@@ -0,0 +1 @@
+ef078bbcf8415a7bb49ed919739005d22c21199da1a0e5e5c0971d2a8e1b2a40 \ No newline at end of file
diff --git a/db/schema_migrations/20220523165734 b/db/schema_migrations/20220523165734
new file mode 100644
index 00000000000..b1d8fa16dd5
--- /dev/null
+++ b/db/schema_migrations/20220523165734
@@ -0,0 +1 @@
+89a03d69c44ed95133446275bb9b39dfe91ad3022cefdfa438ea3c96ab4f8e69 \ No newline at end of file
diff --git a/db/schema_migrations/20220524164122 b/db/schema_migrations/20220524164122
new file mode 100644
index 00000000000..26e3b596910
--- /dev/null
+++ b/db/schema_migrations/20220524164122
@@ -0,0 +1 @@
+dc449f4ea28da3662fce663dcd5cdc9e37417e14b39e26897cc35a2bebfa22f0 \ No newline at end of file
diff --git a/db/schema_migrations/20220531024905 b/db/schema_migrations/20220531024905
new file mode 100644
index 00000000000..3892c437701
--- /dev/null
+++ b/db/schema_migrations/20220531024905
@@ -0,0 +1 @@
+3470fa801f5d6c343c95d78a710aa1907a581575465718c8d971f4b8f305a39b \ No newline at end of file
diff --git a/db/schema_migrations/20220531035113 b/db/schema_migrations/20220531035113
new file mode 100644
index 00000000000..133741d8a36
--- /dev/null
+++ b/db/schema_migrations/20220531035113
@@ -0,0 +1 @@
+4e4e158655d40797c4f9152ad3e4f8b9b4894ce1ce92bf89c6219f9c69847c45 \ No newline at end of file
diff --git a/db/schema_migrations/20220531140515 b/db/schema_migrations/20220531140515
new file mode 100644
index 00000000000..1e89b902026
--- /dev/null
+++ b/db/schema_migrations/20220531140515
@@ -0,0 +1 @@
+2c0c801506c47adb74c4a91a5fcf37b02355b35570ffbdd18c8aa6a11a8397ac \ No newline at end of file
diff --git a/db/schema_migrations/20220601151900 b/db/schema_migrations/20220601151900
new file mode 100644
index 00000000000..d758b7aa67c
--- /dev/null
+++ b/db/schema_migrations/20220601151900
@@ -0,0 +1 @@
+c215c9ef738ab0d466d9244c0596164d6860728ac92fac90bef5a987c2cef6b7 \ No newline at end of file
diff --git a/db/schema_migrations/20220601152916 b/db/schema_migrations/20220601152916
new file mode 100644
index 00000000000..4858976aa3a
--- /dev/null
+++ b/db/schema_migrations/20220601152916
@@ -0,0 +1 @@
+f460407888e289580dec15ea27e19fa5cc2d2116a831105b71b980c617971743 \ No newline at end of file
diff --git a/db/schema_migrations/20220606082910 b/db/schema_migrations/20220606082910
new file mode 100644
index 00000000000..5917ba95971
--- /dev/null
+++ b/db/schema_migrations/20220606082910
@@ -0,0 +1 @@
+ecab80f469d2aea061b5c8371a243e4b6686d637c3df284f23e575606ef8c1a6 \ No newline at end of file
diff --git a/db/schema_migrations/20220608074738 b/db/schema_migrations/20220608074738
new file mode 100644
index 00000000000..035979d8f04
--- /dev/null
+++ b/db/schema_migrations/20220608074738
@@ -0,0 +1 @@
+0bf44279d1fd78a8df1ec2898b6170e587fb2dd5d692b9c31648aa19dffa5fe8 \ No newline at end of file
diff --git a/db/schema_migrations/20220610140605 b/db/schema_migrations/20220610140605
new file mode 100644
index 00000000000..c2ae3528d21
--- /dev/null
+++ b/db/schema_migrations/20220610140605
@@ -0,0 +1 @@
+9c64f9fb286992b6cdad8f7f22084c2d538bccf97e9c649f47284c5828a850e3 \ No newline at end of file
diff --git a/db/schema_migrations/20220613054349 b/db/schema_migrations/20220613054349
new file mode 100644
index 00000000000..1c3806a80c8
--- /dev/null
+++ b/db/schema_migrations/20220613054349
@@ -0,0 +1 @@
+4c3e4852614dd1a59d63809c40417887794bcbbcf8d3ea3a96f8846e2bd5f795 \ No newline at end of file
diff --git a/db/schema_migrations/20220614120415 b/db/schema_migrations/20220614120415
new file mode 100644
index 00000000000..2357871c8d8
--- /dev/null
+++ b/db/schema_migrations/20220614120415
@@ -0,0 +1 @@
+a18f38b1f25ab3344c3ce8dcefc4579370c79e70354dc1665dbb8026892e1e37 \ No newline at end of file
diff --git a/db/schema_migrations/20220616182001 b/db/schema_migrations/20220616182001
new file mode 100644
index 00000000000..8167bae8550
--- /dev/null
+++ b/db/schema_migrations/20220616182001
@@ -0,0 +1 @@
+7276612cf3f2fd968405c1bb31afe2eafeca3dc9e145f5f4c2e1609a93926e04 \ No newline at end of file
diff --git a/db/schema_migrations/20220616182015 b/db/schema_migrations/20220616182015
new file mode 100644
index 00000000000..00f4825677c
--- /dev/null
+++ b/db/schema_migrations/20220616182015
@@ -0,0 +1 @@
+4c2d89fc0aae46c08fc03018de7fafc9a040fa94284224a89ae626a1ddd2cfa9 \ No newline at end of file
diff --git a/db/schema_migrations/20220616182016 b/db/schema_migrations/20220616182016
new file mode 100644
index 00000000000..a2c9beba76b
--- /dev/null
+++ b/db/schema_migrations/20220616182016
@@ -0,0 +1 @@
+ebb53cf83d85c5b1b07e206e7190a3d17e37ec35f085e8e57e1245ba1a3acbf6 \ No newline at end of file
diff --git a/db/schema_migrations/20220616182038 b/db/schema_migrations/20220616182038
new file mode 100644
index 00000000000..1bf761987d8
--- /dev/null
+++ b/db/schema_migrations/20220616182038
@@ -0,0 +1 @@
+969b07e2aa0422f9eae171b7c345f2fdaf061bd0ea05bc76618d986364b9223c \ No newline at end of file
diff --git a/db/schema_migrations/20220616183240 b/db/schema_migrations/20220616183240
new file mode 100644
index 00000000000..39d0cab11ca
--- /dev/null
+++ b/db/schema_migrations/20220616183240
@@ -0,0 +1 @@
+7714fa874067ab65a0374617e83a53986105cafe0d92319b21a4f7d7ad2fc600 \ No newline at end of file
diff --git a/db/schema_migrations/20220616183309 b/db/schema_migrations/20220616183309
new file mode 100644
index 00000000000..cd44061963f
--- /dev/null
+++ b/db/schema_migrations/20220616183309
@@ -0,0 +1 @@
+717dd5d40fca276c49b42909e5e3ec9e0cef7f0e534c428d849528003af44fd8 \ No newline at end of file
diff --git a/db/schema_migrations/20220616183310 b/db/schema_migrations/20220616183310
new file mode 100644
index 00000000000..a854df90812
--- /dev/null
+++ b/db/schema_migrations/20220616183310
@@ -0,0 +1 @@
+c175c13b220873cea28ea3963cf461aaeb570051ef3834b8520b7ad9520a0f19 \ No newline at end of file
diff --git a/db/schema_migrations/20220617123022 b/db/schema_migrations/20220617123022
new file mode 100644
index 00000000000..043b16b6cb6
--- /dev/null
+++ b/db/schema_migrations/20220617123022
@@ -0,0 +1 @@
+247c6cba3cee4413a17193aeebd77eae79a7ced17a5a2b785f0ecd682e823c02 \ No newline at end of file
diff --git a/db/schema_migrations/20220617123034 b/db/schema_migrations/20220617123034
new file mode 100644
index 00000000000..f0ecdc68113
--- /dev/null
+++ b/db/schema_migrations/20220617123034
@@ -0,0 +1 @@
+d72ffd09437a576edb2d046963e8d004c5a2b13586f7318361fea6d673f5cece \ No newline at end of file
diff --git a/db/schema_migrations/20220617123105 b/db/schema_migrations/20220617123105
new file mode 100644
index 00000000000..a3ffe22bca4
--- /dev/null
+++ b/db/schema_migrations/20220617123105
@@ -0,0 +1 @@
+d382bfcfcf79ba38a388ac5496a194adc0c392ba6685c024d7bd55a14d57c1b8 \ No newline at end of file
diff --git a/db/schema_migrations/20220617123113 b/db/schema_migrations/20220617123113
new file mode 100644
index 00000000000..deb71083ab0
--- /dev/null
+++ b/db/schema_migrations/20220617123113
@@ -0,0 +1 @@
+ebe1b2db48b987720e7c561b30ce41e7542d8cd190e4b454bd28d6fdfa8bff0d \ No newline at end of file
diff --git a/db/schema_migrations/20220617123135 b/db/schema_migrations/20220617123135
new file mode 100644
index 00000000000..3cafd00560c
--- /dev/null
+++ b/db/schema_migrations/20220617123135
@@ -0,0 +1 @@
+2fcb9e7ecdc387d5dd4dfe78544289026bb2626eca2650da590f6181deeaadef \ No newline at end of file
diff --git a/db/schema_migrations/20220617123144 b/db/schema_migrations/20220617123144
new file mode 100644
index 00000000000..6f9c5e33092
--- /dev/null
+++ b/db/schema_migrations/20220617123144
@@ -0,0 +1 @@
+5a03ed4bc5791d0feb72203553f77ed37f37127309eda6c7dc75c7ac950e28e3 \ No newline at end of file
diff --git a/db/schema_migrations/20220617141347 b/db/schema_migrations/20220617141347
new file mode 100644
index 00000000000..d8c8ff580cf
--- /dev/null
+++ b/db/schema_migrations/20220617141347
@@ -0,0 +1 @@
+64473c05cc67d6d87d921921ea09e0962f51092d5bb565cc387def8d91676728 \ No newline at end of file
diff --git a/db/schema_migrations/20220617142124 b/db/schema_migrations/20220617142124
new file mode 100644
index 00000000000..c8fd06f2c10
--- /dev/null
+++ b/db/schema_migrations/20220617142124
@@ -0,0 +1 @@
+668404076e9cfc91817b8ae3ec995a69ec0db283153bbe497a81eb83c2188ceb \ No newline at end of file
diff --git a/db/schema_migrations/20220617143228 b/db/schema_migrations/20220617143228
new file mode 100644
index 00000000000..cb4ac555bc3
--- /dev/null
+++ b/db/schema_migrations/20220617143228
@@ -0,0 +1 @@
+547fc0071177395133497cbcec9a9d9ed058fe74f632f5e84d9a6416047503f2 \ No newline at end of file
diff --git a/db/schema_migrations/20220619182308 b/db/schema_migrations/20220619182308
new file mode 100644
index 00000000000..7d85fb1c487
--- /dev/null
+++ b/db/schema_migrations/20220619182308
@@ -0,0 +1 @@
+f8830ecd0c49aea19857fec9b07d238f4bc269a758b6a3495d57222ab1604c74 \ No newline at end of file
diff --git a/db/schema_migrations/20220619184931 b/db/schema_migrations/20220619184931
new file mode 100644
index 00000000000..a98c1f3e847
--- /dev/null
+++ b/db/schema_migrations/20220619184931
@@ -0,0 +1 @@
+2cdbc5b29e11a2ce0679f218adc57c95d483139ca0bcd1801ea97fbd4ba68ddf \ No newline at end of file
diff --git a/db/schema_migrations/20220620060633 b/db/schema_migrations/20220620060633
new file mode 100644
index 00000000000..d6a627ff611
--- /dev/null
+++ b/db/schema_migrations/20220620060633
@@ -0,0 +1 @@
+29b2e0496736ae09f7d2b6a971a7a9a946379469de0f5488a3ff16efd896e306 \ No newline at end of file
diff --git a/db/schema_migrations/20220620132300 b/db/schema_migrations/20220620132300
new file mode 100644
index 00000000000..8355b33c868
--- /dev/null
+++ b/db/schema_migrations/20220620132300
@@ -0,0 +1 @@
+cc7a1d81c9de121380b7b1a4bbbb1947313635c6ae16ce15184b586765333a8e \ No newline at end of file
diff --git a/db/schema_migrations/20220620151740 b/db/schema_migrations/20220620151740
new file mode 100644
index 00000000000..fae240f63f9
--- /dev/null
+++ b/db/schema_migrations/20220620151740
@@ -0,0 +1 @@
+b54da707978fc5e90183331250ab66b5438c6c9f9ecd50a50db5b63a5993bd6b \ No newline at end of file
diff --git a/db/schema_migrations/20220621040800 b/db/schema_migrations/20220621040800
new file mode 100644
index 00000000000..dbdc38367be
--- /dev/null
+++ b/db/schema_migrations/20220621040800
@@ -0,0 +1 @@
+effd82de862e39edcba7793010bdd377b8141c49edebdd380276a8b558886835 \ No newline at end of file
diff --git a/db/schema_migrations/20220621082245 b/db/schema_migrations/20220621082245
new file mode 100644
index 00000000000..42e34952c30
--- /dev/null
+++ b/db/schema_migrations/20220621082245
@@ -0,0 +1 @@
+290ff026a11ac5eadd71fb9fb3ba21bed535d148c56b3176f115e973cdb41369 \ No newline at end of file
diff --git a/db/schema_migrations/20220621092245 b/db/schema_migrations/20220621092245
new file mode 100644
index 00000000000..86274a80e6d
--- /dev/null
+++ b/db/schema_migrations/20220621092245
@@ -0,0 +1 @@
+c414443040bb168009bcbe00f874b1f474c1d1dcf563e621cfdf641f21846d59 \ No newline at end of file
diff --git a/db/schema_migrations/20220621202616 b/db/schema_migrations/20220621202616
new file mode 100644
index 00000000000..187ff41b3c1
--- /dev/null
+++ b/db/schema_migrations/20220621202616
@@ -0,0 +1 @@
+6567c86c14f741b7ea8f49b04c3ad82f226f04c0ab2e68212b5f6e7bf4ef615f \ No newline at end of file
diff --git a/db/schema_migrations/20220622070547 b/db/schema_migrations/20220622070547
new file mode 100644
index 00000000000..da1b4231b0d
--- /dev/null
+++ b/db/schema_migrations/20220622070547
@@ -0,0 +1 @@
+e259a91d467b3ec3e09c4514de0e798cffa697a8bc492edd6ad0dcab7f9a9623 \ No newline at end of file
diff --git a/db/schema_migrations/20220622080547 b/db/schema_migrations/20220622080547
new file mode 100644
index 00000000000..c7b3e676a30
--- /dev/null
+++ b/db/schema_migrations/20220622080547
@@ -0,0 +1 @@
+366f0819ce42bc84fc88871872d4b5870e63894fa2e32fbd7808cce2afe4815b \ No newline at end of file
diff --git a/db/schema_migrations/20220624062300 b/db/schema_migrations/20220624062300
new file mode 100644
index 00000000000..a13fda7e34b
--- /dev/null
+++ b/db/schema_migrations/20220624062300
@@ -0,0 +1 @@
+d09b9359b871c96511c255abdc1ff82640420f469a16c5e76461ca47dca58770 \ No newline at end of file
diff --git a/db/schema_migrations/20220624081524 b/db/schema_migrations/20220624081524
new file mode 100644
index 00000000000..f643b1223a8
--- /dev/null
+++ b/db/schema_migrations/20220624081524
@@ -0,0 +1 @@
+3245905956e4781629bbf6398c9534cf35eab469e8a703f755ed26de90dee0e1 \ No newline at end of file
diff --git a/db/schema_migrations/20220624090458 b/db/schema_migrations/20220624090458
new file mode 100644
index 00000000000..62473bf8bd3
--- /dev/null
+++ b/db/schema_migrations/20220624090458
@@ -0,0 +1 @@
+cf3c6e8d720ce48272b8b9658d3c240e8fe3c9a26284a9e169f7bb6a40c862bc \ No newline at end of file
diff --git a/db/schema_migrations/20220627061008 b/db/schema_migrations/20220627061008
new file mode 100644
index 00000000000..8a576f791ad
--- /dev/null
+++ b/db/schema_migrations/20220627061008
@@ -0,0 +1 @@
+80c35cd4dbc2e00e721ccb9313ff0f2f4f85e781c7961680e14769c308f067ed \ No newline at end of file
diff --git a/db/schema_migrations/20220627090231 b/db/schema_migrations/20220627090231
new file mode 100644
index 00000000000..ca24023b011
--- /dev/null
+++ b/db/schema_migrations/20220627090231
@@ -0,0 +1 @@
+e0038cb5687098e93a250e6fb0449d0ae2eb7c534219b3f24a9258f2a3c0fedb \ No newline at end of file
diff --git a/db/schema_migrations/20220627122229 b/db/schema_migrations/20220627122229
new file mode 100644
index 00000000000..040376e1aa0
--- /dev/null
+++ b/db/schema_migrations/20220627122229
@@ -0,0 +1 @@
+29ab69647b53c331aefdd62e8fbcc1567df4424a8e7ae6f8eb7b1e9afa7a6911 \ No newline at end of file
diff --git a/db/schema_migrations/20220627122230 b/db/schema_migrations/20220627122230
new file mode 100644
index 00000000000..82ba0d503ee
--- /dev/null
+++ b/db/schema_migrations/20220627122230
@@ -0,0 +1 @@
+6d65af0d20cd80cf3367f48c5447ff33046e982ac1cfd55aaf52a7cc2330e428 \ No newline at end of file
diff --git a/db/schema_migrations/20220627140315 b/db/schema_migrations/20220627140315
new file mode 100644
index 00000000000..1ff8388f109
--- /dev/null
+++ b/db/schema_migrations/20220627140315
@@ -0,0 +1 @@
+0511a510621fec3b4b22ac55f151ec3fd83206cc39e97ac3b93a61a80e7a43f8 \ No newline at end of file
diff --git a/db/schema_migrations/20220627152642 b/db/schema_migrations/20220627152642
new file mode 100644
index 00000000000..b92fde2e5ca
--- /dev/null
+++ b/db/schema_migrations/20220627152642
@@ -0,0 +1 @@
+24b07a6966c6fd7ab680cf5a9052b7c2f6d20944eaae5d06ef42934364dce222 \ No newline at end of file
diff --git a/db/schema_migrations/20220627171538 b/db/schema_migrations/20220627171538
new file mode 100644
index 00000000000..a2c269b4348
--- /dev/null
+++ b/db/schema_migrations/20220627171538
@@ -0,0 +1 @@
+1f44130f3f8af92bfaa7de488da2f5f0804045afa6e2ac233d2660a7937a9e32 \ No newline at end of file
diff --git a/db/schema_migrations/20220627223041 b/db/schema_migrations/20220627223041
new file mode 100644
index 00000000000..3292e76e1de
--- /dev/null
+++ b/db/schema_migrations/20220627223041
@@ -0,0 +1 @@
+225606ccdf0979aaf70ff8b9a44269e69b1598718e3d7c1944ed41c07b5e33f6 \ No newline at end of file
diff --git a/db/schema_migrations/20220628012902 b/db/schema_migrations/20220628012902
new file mode 100644
index 00000000000..ef7325629ca
--- /dev/null
+++ b/db/schema_migrations/20220628012902
@@ -0,0 +1 @@
+5881441f8a6c0f25cff00aa9e164a1c19bcc34d4db678fc50712824fff82b24e \ No newline at end of file
diff --git a/db/schema_migrations/20220628110214 b/db/schema_migrations/20220628110214
new file mode 100644
index 00000000000..97bab836225
--- /dev/null
+++ b/db/schema_migrations/20220628110214
@@ -0,0 +1 @@
+f95de3ed746d6f661358a3826587da37009f20ba3cd0e8a332e57f9276fb856c \ No newline at end of file
diff --git a/db/schema_migrations/20220628110823 b/db/schema_migrations/20220628110823
new file mode 100644
index 00000000000..1c5bb0f3320
--- /dev/null
+++ b/db/schema_migrations/20220628110823
@@ -0,0 +1 @@
+50d788ced675b3773bbb84122040c775c24c0993c95542f5130a6456fcd4ee69 \ No newline at end of file
diff --git a/db/schema_migrations/20220628111752 b/db/schema_migrations/20220628111752
new file mode 100644
index 00000000000..747546f1ba4
--- /dev/null
+++ b/db/schema_migrations/20220628111752
@@ -0,0 +1 @@
+5a4a6355d1954735a05831e17c97e2879320f2cb313be56fb72e1cd2c20d9090 \ No newline at end of file
diff --git a/db/schema_migrations/20220628120708 b/db/schema_migrations/20220628120708
new file mode 100644
index 00000000000..b6961491c93
--- /dev/null
+++ b/db/schema_migrations/20220628120708
@@ -0,0 +1 @@
+75027a5b09491b156837707af20406b2672d5ee3ce2272ecf1496e98da2861bf \ No newline at end of file
diff --git a/db/schema_migrations/20220628121644 b/db/schema_migrations/20220628121644
new file mode 100644
index 00000000000..cac9b9d9a0b
--- /dev/null
+++ b/db/schema_migrations/20220628121644
@@ -0,0 +1 @@
+90b9b47ef3671b73117205264589f895a083b0d00db00e684b25e60673d2e840 \ No newline at end of file
diff --git a/db/schema_migrations/20220628121712 b/db/schema_migrations/20220628121712
new file mode 100644
index 00000000000..e1c0ed37cff
--- /dev/null
+++ b/db/schema_migrations/20220628121712
@@ -0,0 +1 @@
+d64a9c41376bbb3bc2c9df846668b1a67b0bed1b1410d97dba17c19a2f322b38 \ No newline at end of file
diff --git a/db/schema_migrations/20220628122622 b/db/schema_migrations/20220628122622
new file mode 100644
index 00000000000..ce29140a862
--- /dev/null
+++ b/db/schema_migrations/20220628122622
@@ -0,0 +1 @@
+aeaa386b52a2a5e30b59fbe57e9c701298fea45219b3ec419866d40c6d2a5e5d \ No newline at end of file
diff --git a/db/schema_migrations/20220629184402 b/db/schema_migrations/20220629184402
new file mode 100644
index 00000000000..7e8b0c47bd1
--- /dev/null
+++ b/db/schema_migrations/20220629184402
@@ -0,0 +1 @@
+9414b08c3eacadffd8759739da163eb378776d3ecdb06dab7c66e259ff1bed29 \ No newline at end of file
diff --git a/db/schema_migrations/20220629220129 b/db/schema_migrations/20220629220129
new file mode 100644
index 00000000000..580da9df82a
--- /dev/null
+++ b/db/schema_migrations/20220629220129
@@ -0,0 +1 @@
+2f5e08212b2f733ce5812d7154879768532e31e642b647648d1c03fd4ddf8b13 \ No newline at end of file
diff --git a/db/schema_migrations/20220630050050 b/db/schema_migrations/20220630050050
new file mode 100644
index 00000000000..2ec998847eb
--- /dev/null
+++ b/db/schema_migrations/20220630050050
@@ -0,0 +1 @@
+dfb314ef76efc54a2464e6b84e71753caf58bc8508f9e64b403066ea4847fe56 \ No newline at end of file
diff --git a/db/schema_migrations/20220630085003 b/db/schema_migrations/20220630085003
new file mode 100644
index 00000000000..9e020afbe84
--- /dev/null
+++ b/db/schema_migrations/20220630085003
@@ -0,0 +1 @@
+c1fb356eb437f9511c0af324f9f4a173245a427d20e2bbda0557dfaff28911c3 \ No newline at end of file
diff --git a/db/schema_migrations/20220630091409 b/db/schema_migrations/20220630091409
new file mode 100644
index 00000000000..e36a91febe6
--- /dev/null
+++ b/db/schema_migrations/20220630091409
@@ -0,0 +1 @@
+f8c8489ecded214bbc4ab615a23eceaef3b6f650e98514f8e2b4b2fa6d328f4e \ No newline at end of file
diff --git a/db/schema_migrations/20220630151641 b/db/schema_migrations/20220630151641
new file mode 100644
index 00000000000..f32c607c840
--- /dev/null
+++ b/db/schema_migrations/20220630151641
@@ -0,0 +1 @@
+55794a6bb6380adc662fb90f60596477ff81d83b05b4cca83d72332d869d08fb \ No newline at end of file
diff --git a/db/schema_migrations/20220630202329 b/db/schema_migrations/20220630202329
new file mode 100644
index 00000000000..c45ba56ad4b
--- /dev/null
+++ b/db/schema_migrations/20220630202329
@@ -0,0 +1 @@
+5b12e0fbebef2979cfc31aab16ce78988a2f94662dbe1048791413347edb3c99 \ No newline at end of file
diff --git a/db/schema_migrations/20220701085523 b/db/schema_migrations/20220701085523
new file mode 100644
index 00000000000..c835395cd6d
--- /dev/null
+++ b/db/schema_migrations/20220701085523
@@ -0,0 +1 @@
+eb28e690d810a6b23454b0b5a2ebc1ff802cdf52f7c41faae7519ea8f018b96a \ No newline at end of file
diff --git a/db/schema_migrations/20220701173859 b/db/schema_migrations/20220701173859
new file mode 100644
index 00000000000..c5f72bfb817
--- /dev/null
+++ b/db/schema_migrations/20220701173859
@@ -0,0 +1 @@
+7c9b8b433553e83bb05208e62541e3d51bcc1083ff33d1146e93b92d954f9cb0 \ No newline at end of file
diff --git a/db/schema_migrations/20220703182234 b/db/schema_migrations/20220703182234
new file mode 100644
index 00000000000..7d977a4ea9f
--- /dev/null
+++ b/db/schema_migrations/20220703182234
@@ -0,0 +1 @@
+cb1457d19b058add7a966690f8d83e4f7e1612f2de3d6d8a87873bb7fb19960b \ No newline at end of file
diff --git a/db/schema_migrations/20220703182254 b/db/schema_migrations/20220703182254
new file mode 100644
index 00000000000..9d454d07600
--- /dev/null
+++ b/db/schema_migrations/20220703182254
@@ -0,0 +1 @@
+aa4e72f0f6596a609a7620c32e2a5def1ce3ee7200cf7513dd3c6569f68db342 \ No newline at end of file
diff --git a/db/schema_migrations/20220703182314 b/db/schema_migrations/20220703182314
new file mode 100644
index 00000000000..94d06e2075e
--- /dev/null
+++ b/db/schema_migrations/20220703182314
@@ -0,0 +1 @@
+e52d274075c18c3b80ed8306138eabd6dd3d1157dd1093f7f769b0a6cfb56791 \ No newline at end of file
diff --git a/db/schema_migrations/20220704034050 b/db/schema_migrations/20220704034050
new file mode 100644
index 00000000000..4ddb8267bf5
--- /dev/null
+++ b/db/schema_migrations/20220704034050
@@ -0,0 +1 @@
+3c2e9dfb0bbd31f01a9f1b3bc7d5e1865b0ae0c94dcfd6e900890677ca276e6c \ No newline at end of file
diff --git a/db/schema_migrations/20220704034105 b/db/schema_migrations/20220704034105
new file mode 100644
index 00000000000..5d08da1b417
--- /dev/null
+++ b/db/schema_migrations/20220704034105
@@ -0,0 +1 @@
+45347ab01c723358a736268c40f04efd7f4ce4be0570072f3740acdc73b6a203 \ No newline at end of file
diff --git a/db/schema_migrations/20220704044408 b/db/schema_migrations/20220704044408
new file mode 100644
index 00000000000..083554d2ffd
--- /dev/null
+++ b/db/schema_migrations/20220704044408
@@ -0,0 +1 @@
+4fd3bd4f3f3fd521b5491c38636c4c6e73470367b7510ebe517e7557c6b341ff \ No newline at end of file
diff --git a/db/schema_migrations/20220704045440 b/db/schema_migrations/20220704045440
new file mode 100644
index 00000000000..3d8be03c87f
--- /dev/null
+++ b/db/schema_migrations/20220704045440
@@ -0,0 +1 @@
+0494aa671826be96811e2985560c70b0ba4bce4272ca7d94222eff6761d305ed \ No newline at end of file
diff --git a/db/schema_migrations/20220705114635 b/db/schema_migrations/20220705114635
new file mode 100644
index 00000000000..1ab54b47282
--- /dev/null
+++ b/db/schema_migrations/20220705114635
@@ -0,0 +1 @@
+b9d37f6b3f59c4d2a08533fd1e2dc91403081fdf5691c86a1874079cb7937588 \ No newline at end of file
diff --git a/db/schema_migrations/20220705145349 b/db/schema_migrations/20220705145349
new file mode 100644
index 00000000000..6c309d401db
--- /dev/null
+++ b/db/schema_migrations/20220705145349
@@ -0,0 +1 @@
+7f5288a47ce5d548bf47fbcd107e31f5448ec1d730ce5b13a760c155c50b44fb \ No newline at end of file
diff --git a/db/schema_migrations/20220705180843 b/db/schema_migrations/20220705180843
new file mode 100644
index 00000000000..4e39726e61e
--- /dev/null
+++ b/db/schema_migrations/20220705180843
@@ -0,0 +1 @@
+755e06f8bd3a0a28820f6ec2ee52a39a7920eb9d8ae0315a8a179139c78645d9 \ No newline at end of file
diff --git a/db/schema_migrations/20220706065245 b/db/schema_migrations/20220706065245
new file mode 100644
index 00000000000..46abcb3e7c8
--- /dev/null
+++ b/db/schema_migrations/20220706065245
@@ -0,0 +1 @@
+3583de8dc55a1e9835b64542bb11a94084d34c2409f63cd7e402bd3c5c0009ef \ No newline at end of file
diff --git a/db/schema_migrations/20220706065611 b/db/schema_migrations/20220706065611
new file mode 100644
index 00000000000..24b6523f24f
--- /dev/null
+++ b/db/schema_migrations/20220706065611
@@ -0,0 +1 @@
+eab26142f1314caa9ff6a6f07b6c787d276653d9bf6702bce9355c0e9605a909 \ No newline at end of file
diff --git a/db/schema_migrations/20220706070804 b/db/schema_migrations/20220706070804
new file mode 100644
index 00000000000..08943e8fe00
--- /dev/null
+++ b/db/schema_migrations/20220706070804
@@ -0,0 +1 @@
+7bf55a7614afcb210b22df1ea38cf16fde9510bbe66d9b19f0fb63d668ac4e72 \ No newline at end of file
diff --git a/db/schema_migrations/20220706071304 b/db/schema_migrations/20220706071304
new file mode 100644
index 00000000000..e2e0ba301e5
--- /dev/null
+++ b/db/schema_migrations/20220706071304
@@ -0,0 +1 @@
+ed72bfafe1c04826ce57b9068c537df563bc193f231f4f223348b084c68a8bde \ No newline at end of file
diff --git a/db/schema_migrations/20220706115138 b/db/schema_migrations/20220706115138
new file mode 100644
index 00000000000..0c139470b47
--- /dev/null
+++ b/db/schema_migrations/20220706115138
@@ -0,0 +1 @@
+c0c4a18cb711e0288bf1d385e06151e0e329dc40d4e9cd51e6437fe73d6bfc21 \ No newline at end of file
diff --git a/db/schema_migrations/20220706122719 b/db/schema_migrations/20220706122719
new file mode 100644
index 00000000000..6341be22a00
--- /dev/null
+++ b/db/schema_migrations/20220706122719
@@ -0,0 +1 @@
+b80d15b0176f0372a1553920ba72c43a2f9831f786358397f820a83b1b840cdc \ No newline at end of file
diff --git a/db/schema_migrations/20220706132238 b/db/schema_migrations/20220706132238
new file mode 100644
index 00000000000..32ae901bfb9
--- /dev/null
+++ b/db/schema_migrations/20220706132238
@@ -0,0 +1 @@
+ea387b35bfb7f15a036aca9413b8fd15ede6b16048fa9e9be5a62b9e21ca362d \ No newline at end of file
diff --git a/db/schema_migrations/20220706191627 b/db/schema_migrations/20220706191627
new file mode 100644
index 00000000000..3b66876ff9a
--- /dev/null
+++ b/db/schema_migrations/20220706191627
@@ -0,0 +1 @@
+28aecb58b63bdc910c3a37b5ff0f99d2feb42dcb49ba894bb017115f2b33f531 \ No newline at end of file
diff --git a/db/schema_migrations/20220707075300 b/db/schema_migrations/20220707075300
new file mode 100644
index 00000000000..1374cbd2036
--- /dev/null
+++ b/db/schema_migrations/20220707075300
@@ -0,0 +1 @@
+f796c973e95ad95fb95e72214ba664382757c5127bdd19b00934bf99b394fde3 \ No newline at end of file
diff --git a/db/schema_migrations/20220708100508 b/db/schema_migrations/20220708100508
new file mode 100644
index 00000000000..73de59b95ab
--- /dev/null
+++ b/db/schema_migrations/20220708100508
@@ -0,0 +1 @@
+041c729542e7bf418ee805d6c1878aa62fd274a97583cc11dfebae9e7bdac896 \ No newline at end of file
diff --git a/db/schema_migrations/20220708100532 b/db/schema_migrations/20220708100532
new file mode 100644
index 00000000000..8f4f3876515
--- /dev/null
+++ b/db/schema_migrations/20220708100532
@@ -0,0 +1 @@
+28cf54895ada6e5d501bd5dcb9e7e161fd44ce51494b984dde7beadd0895c952 \ No newline at end of file
diff --git a/db/schema_migrations/20220708132701 b/db/schema_migrations/20220708132701
new file mode 100644
index 00000000000..01fdd550b06
--- /dev/null
+++ b/db/schema_migrations/20220708132701
@@ -0,0 +1 @@
+a91b2e3c9f89c6b7a0e4330fe617b22ee3b22100fc868ef13b5c656580175816 \ No newline at end of file
diff --git a/db/schema_migrations/20220708142744 b/db/schema_migrations/20220708142744
new file mode 100644
index 00000000000..980c0b43c52
--- /dev/null
+++ b/db/schema_migrations/20220708142744
@@ -0,0 +1 @@
+b93ab540270a4b743c12fe5d1d6963cfeb29ee3b0a1e4e012cd4b3d1b3a08cde \ No newline at end of file
diff --git a/db/schema_migrations/20220708142803 b/db/schema_migrations/20220708142803
new file mode 100644
index 00000000000..4eb59905dd0
--- /dev/null
+++ b/db/schema_migrations/20220708142803
@@ -0,0 +1 @@
+7929540cf382f282f75f2f9c9dd6196d426ed1edb1f6744da1f0a627e7fb0cfc \ No newline at end of file
diff --git a/db/schema_migrations/20220708150315 b/db/schema_migrations/20220708150315
new file mode 100644
index 00000000000..10b3f069ffa
--- /dev/null
+++ b/db/schema_migrations/20220708150315
@@ -0,0 +1 @@
+925069c0dd5058e38da16496b140ea4139318a40c8207fcd7116d76562b0e959 \ No newline at end of file
diff --git a/db/schema_migrations/20220708150335 b/db/schema_migrations/20220708150335
new file mode 100644
index 00000000000..ee0bc1a666e
--- /dev/null
+++ b/db/schema_migrations/20220708150335
@@ -0,0 +1 @@
+9a41920cb988c3c5459e33c143f4bb97d8d6cf4fc691aa87f3fd7ef9f2a726f8 \ No newline at end of file
diff --git a/db/schema_migrations/20220708184822 b/db/schema_migrations/20220708184822
new file mode 100644
index 00000000000..095ed891609
--- /dev/null
+++ b/db/schema_migrations/20220708184822
@@ -0,0 +1 @@
+80ac782e6e3ee1daec9e18f88a823d7cd43152a36f53c9d50758ba88a5711642 \ No newline at end of file
diff --git a/db/schema_migrations/20220712025712 b/db/schema_migrations/20220712025712
new file mode 100644
index 00000000000..68e8a510feb
--- /dev/null
+++ b/db/schema_migrations/20220712025712
@@ -0,0 +1 @@
+f0bba8e67c97d6dea461d8626a07820c52e20ab6578ad40e8873ad0031a2ce62 \ No newline at end of file
diff --git a/db/schema_migrations/20220712031923 b/db/schema_migrations/20220712031923
new file mode 100644
index 00000000000..1cb2b63faa8
--- /dev/null
+++ b/db/schema_migrations/20220712031923
@@ -0,0 +1 @@
+db2c19f15a03a6222627875d8bd27368de43fb6485961f866de61b3017796e28 \ No newline at end of file
diff --git a/db/schema_migrations/20220712094945 b/db/schema_migrations/20220712094945
new file mode 100644
index 00000000000..1c03490d054
--- /dev/null
+++ b/db/schema_migrations/20220712094945
@@ -0,0 +1 @@
+ef638a5168e2d98621e1c80216bc75500b4de39c40121a7044f039c28448fe82 \ No newline at end of file
diff --git a/db/schema_migrations/20220713133515 b/db/schema_migrations/20220713133515
new file mode 100644
index 00000000000..8c3b76a5d63
--- /dev/null
+++ b/db/schema_migrations/20220713133515
@@ -0,0 +1 @@
+4c0f48149987c821c8666df7a1d9e9780146d356ffb9539572d5a3c77038e237 \ No newline at end of file
diff --git a/db/schema_migrations/20220713175658 b/db/schema_migrations/20220713175658
new file mode 100644
index 00000000000..9b086972336
--- /dev/null
+++ b/db/schema_migrations/20220713175658
@@ -0,0 +1 @@
+6bbaa8006a848a65e866c7836d0b0e28e3c303d28b329f5e12f978dd895e868f \ No newline at end of file
diff --git a/db/schema_migrations/20220713175737 b/db/schema_migrations/20220713175737
new file mode 100644
index 00000000000..88f4550ced0
--- /dev/null
+++ b/db/schema_migrations/20220713175737
@@ -0,0 +1 @@
+95a535d8f97ec96df918547aff7947acacbdf37fd0d3656878c9c60d80f3fd02 \ No newline at end of file
diff --git a/db/schema_migrations/20220713175812 b/db/schema_migrations/20220713175812
new file mode 100644
index 00000000000..13e0279a11e
--- /dev/null
+++ b/db/schema_migrations/20220713175812
@@ -0,0 +1 @@
+41e42a51a0c5b3af8d94edc25e9421a754d6fc517f343bd718b16fd6bfc383f3 \ No newline at end of file
diff --git a/db/schema_migrations/20220714105122 b/db/schema_migrations/20220714105122
new file mode 100644
index 00000000000..f3ec5c17af7
--- /dev/null
+++ b/db/schema_migrations/20220714105122
@@ -0,0 +1 @@
+c452f7dc9a76b6daa7ced88f2ed93332a84bfcb94a7e94f31149e43b888e210f \ No newline at end of file
diff --git a/db/schema_migrations/20220714122311 b/db/schema_migrations/20220714122311
new file mode 100644
index 00000000000..bb7bb022791
--- /dev/null
+++ b/db/schema_migrations/20220714122311
@@ -0,0 +1 @@
+6e59a39a5d843b5df3b33edb54c51f08062bff7ab1676b9326bb5aa8da159027 \ No newline at end of file
diff --git a/db/schema_migrations/20220714122418 b/db/schema_migrations/20220714122418
new file mode 100644
index 00000000000..a7eeeba0255
--- /dev/null
+++ b/db/schema_migrations/20220714122418
@@ -0,0 +1 @@
+efdfa1c6ffb1b5e4de42bbfd87820eb5d1b87883c8b93cb4cb4101ba928f56dd \ No newline at end of file
diff --git a/db/schema_migrations/20220714142424 b/db/schema_migrations/20220714142424
new file mode 100644
index 00000000000..1a7f5e7dcaf
--- /dev/null
+++ b/db/schema_migrations/20220714142424
@@ -0,0 +1 @@
+42387b8524845aeb76d8b6584ffa480819f682538ca9578492eed53baa49bc09 \ No newline at end of file
diff --git a/db/schema_migrations/20220715054506 b/db/schema_migrations/20220715054506
new file mode 100644
index 00000000000..ad01657f92a
--- /dev/null
+++ b/db/schema_migrations/20220715054506
@@ -0,0 +1 @@
+ecd71a6f9c90bd19a28edcd054ce2ef826859e051dd44c9fea875a5c32040a12 \ No newline at end of file
diff --git a/db/schema_migrations/20220715160023 b/db/schema_migrations/20220715160023
new file mode 100644
index 00000000000..39a141fb743
--- /dev/null
+++ b/db/schema_migrations/20220715160023
@@ -0,0 +1 @@
+3696ff7ea12600702911895c085a85b49e613bc133a580d895fc53cf1f6912a8 \ No newline at end of file
diff --git a/db/schema_migrations/20220715163254 b/db/schema_migrations/20220715163254
new file mode 100644
index 00000000000..71461af7b68
--- /dev/null
+++ b/db/schema_migrations/20220715163254
@@ -0,0 +1 @@
+ea8182741ce0b30f2de23041d1f6bafaf6e04a7a7d0f50abcd04462683637596 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index e92e77f0f60..cb0d4696931 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -53,6 +53,7 @@ DECLARE
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;
@@ -63,16 +64,20 @@ BEGIN
END IF;
SELECT
- vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch
+ 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
+ severity, state, report_type, resolved_on_default_branch, present_on_default_branch
FROM
vulnerabilities
WHERE
vulnerabilities.id = NEW.vulnerability_id;
- INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, 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')
+ 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
@@ -89,6 +94,33 @@ RETURN NULL;
END
$$;
+CREATE 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
+$$;
+
CREATE FUNCTION next_traversal_ids_sibling(traversal_ids integer[]) RETURNS integer[]
LANGUAGE plpgsql IMMUTABLE STRICT
AS $$
@@ -206,6 +238,7 @@ UPDATE
vulnerability_reads
SET
location_image = NEW.location->>'image',
+ casted_cluster_agent_id = CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint),
cluster_agent_id = NEW.location->'kubernetes_resource'->>'agent_id'
WHERE
vulnerability_id = NEW.vulnerability_id;
@@ -11321,11 +11354,25 @@ CREATE TABLE application_settings (
container_registry_pre_import_tags_rate numeric(6,2) DEFAULT 0.5 NOT NULL,
license_usage_data_exported boolean DEFAULT false NOT NULL,
phone_verification_code_enabled boolean DEFAULT false NOT NULL,
+ max_number_of_repository_downloads smallint DEFAULT 0 NOT NULL,
+ max_number_of_repository_downloads_within_time_period integer DEFAULT 0 NOT NULL,
+ feishu_integration_enabled boolean DEFAULT false NOT NULL,
+ encrypted_feishu_app_key bytea,
+ encrypted_feishu_app_key_iv bytea,
+ encrypted_feishu_app_secret bytea,
+ encrypted_feishu_app_secret_iv bytea,
+ error_tracking_enabled boolean DEFAULT false NOT NULL,
+ error_tracking_api_url text,
+ 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,
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)),
CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)),
+ CONSTRAINT app_settings_git_rate_limit_users_allowlist_max_usernames CHECK ((cardinality(git_rate_limit_users_allowlist) <= 100)),
CONSTRAINT app_settings_p_cleanup_package_file_worker_capacity_positive CHECK ((packages_cleanup_package_file_worker_capacity >= 0)),
+ CONSTRAINT app_settings_pkg_registry_cleanup_pol_worker_capacity_gte_zero CHECK ((package_registry_cleanup_policies_worker_capacity >= 0)),
CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)),
CONSTRAINT app_settings_yaml_max_depth_positive CHECK ((max_yaml_depth > 0)),
CONSTRAINT app_settings_yaml_max_size_positive CHECK ((max_yaml_size_bytes > 0)),
@@ -11336,8 +11383,10 @@ CREATE TABLE application_settings (
CONSTRAINT check_3455368420 CHECK ((char_length(database_grafana_api_url) <= 255)),
CONSTRAINT check_3559645ae5 CHECK ((char_length(container_registry_import_target_plan) <= 255)),
CONSTRAINT check_3def0f1829 CHECK ((char_length(sentry_clientside_dsn) <= 255)),
+ CONSTRAINT check_492cc1354d CHECK ((char_length(error_tracking_api_url) <= 255)),
CONSTRAINT check_4f8b811780 CHECK ((char_length(sentry_dsn) <= 255)),
CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)),
+ CONSTRAINT check_5688c70478 CHECK ((char_length(error_tracking_access_token_encrypted) <= 255)),
CONSTRAINT check_57123c9593 CHECK ((char_length(help_page_documentation_base_url) <= 255)),
CONSTRAINT check_5a84c3ffdc CHECK ((char_length(content_validation_endpoint_url) <= 255)),
CONSTRAINT check_5bcba483c4 CHECK ((char_length(sentry_environment) <= 255)),
@@ -11383,6 +11432,16 @@ COMMENT ON COLUMN application_settings.encrypted_dingtalk_app_secret_iv IS 'JiHu
COMMENT ON COLUMN application_settings.phone_verification_code_enabled IS 'JiHu-specific column';
+COMMENT ON COLUMN application_settings.feishu_integration_enabled IS 'JiHu-specific column';
+
+COMMENT ON COLUMN application_settings.encrypted_feishu_app_key IS 'JiHu-specific column';
+
+COMMENT ON COLUMN application_settings.encrypted_feishu_app_key_iv IS 'JiHu-specific column';
+
+COMMENT ON COLUMN application_settings.encrypted_feishu_app_secret IS 'JiHu-specific column';
+
+COMMENT ON COLUMN application_settings.encrypted_feishu_app_secret_iv IS 'JiHu-specific column';
+
CREATE SEQUENCE application_settings_id_seq
START WITH 1
INCREMENT BY 1
@@ -11493,7 +11552,8 @@ CREATE TABLE approval_project_rules (
severity_levels text[] DEFAULT '{}'::text[] NOT NULL,
report_type smallint,
vulnerability_states text[] DEFAULT '{newly_detected}'::text[] NOT NULL,
- orchestration_policy_idx smallint
+ orchestration_policy_idx smallint,
+ applies_to_all_protected_branches boolean DEFAULT false NOT NULL
);
CREATE TABLE approval_project_rules_groups (
@@ -13061,6 +13121,12 @@ CREATE SEQUENCE ci_runner_projects_id_seq
ALTER SEQUENCE ci_runner_projects_id_seq OWNED BY ci_runner_projects.id;
+CREATE TABLE ci_runner_versions (
+ version text NOT NULL,
+ status smallint,
+ CONSTRAINT check_b5a3714594 CHECK ((char_length(version) <= 2048))
+);
+
CREATE TABLE ci_runners (
id integer NOT NULL,
token character varying,
@@ -13120,6 +13186,27 @@ CREATE SEQUENCE ci_running_builds_id_seq
ALTER SEQUENCE ci_running_builds_id_seq OWNED BY ci_running_builds.id;
+CREATE TABLE ci_secure_file_states (
+ verification_started_at timestamp with time zone,
+ verification_retry_at timestamp with time zone,
+ verified_at timestamp with time zone,
+ ci_secure_file_id bigint NOT NULL,
+ verification_state smallint DEFAULT 0 NOT NULL,
+ verification_retry_count smallint,
+ verification_checksum bytea,
+ verification_failure text,
+ CONSTRAINT check_a79e5a9261 CHECK ((char_length(verification_failure) <= 255))
+);
+
+CREATE SEQUENCE ci_secure_file_states_ci_secure_file_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ci_secure_file_states_ci_secure_file_id_seq OWNED BY ci_secure_file_states.ci_secure_file_id;
+
CREATE TABLE ci_secure_files (
id bigint NOT NULL,
project_id bigint NOT NULL,
@@ -13568,25 +13655,6 @@ CREATE SEQUENCE clusters_applications_crossplane_id_seq
ALTER SEQUENCE clusters_applications_crossplane_id_seq OWNED BY clusters_applications_crossplane.id;
-CREATE TABLE clusters_applications_elastic_stacks (
- id bigint NOT NULL,
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL,
- cluster_id bigint NOT NULL,
- status integer NOT NULL,
- version character varying(255) NOT NULL,
- status_reason text
-);
-
-CREATE SEQUENCE clusters_applications_elastic_stacks_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE clusters_applications_elastic_stacks_id_seq OWNED BY clusters_applications_elastic_stacks.id;
-
CREATE TABLE clusters_applications_helm (
id integer NOT NULL,
cluster_id integer NOT NULL,
@@ -13728,15 +13796,6 @@ CREATE SEQUENCE clusters_id_seq
ALTER SEQUENCE clusters_id_seq OWNED BY clusters.id;
-CREATE TABLE clusters_integration_elasticstack (
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL,
- cluster_id bigint NOT NULL,
- enabled boolean DEFAULT false NOT NULL,
- chart_version text,
- CONSTRAINT check_f8d671ce04 CHECK ((char_length(chart_version) <= 10))
-);
-
CREATE TABLE clusters_integration_prometheus (
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
@@ -16524,6 +16583,7 @@ CREATE TABLE issues (
blocking_issues_count integer DEFAULT 0 NOT NULL,
upvotes_count integer DEFAULT 0 NOT NULL,
work_item_type_id bigint,
+ namespace_id bigint,
CONSTRAINT check_fba63f706d CHECK ((lock_version IS NOT NULL))
);
@@ -17445,6 +17505,23 @@ CREATE TABLE namespace_aggregation_schedules (
namespace_id integer NOT NULL
);
+CREATE TABLE namespace_bans (
+ id bigint NOT NULL,
+ namespace_id bigint NOT NULL,
+ user_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL
+);
+
+CREATE SEQUENCE namespace_bans_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE namespace_bans_id_seq OWNED BY namespace_bans.id;
+
CREATE TABLE namespace_ci_cd_settings (
namespace_id bigint NOT NULL,
allow_stale_runner_pruning boolean DEFAULT false NOT NULL
@@ -17504,6 +17581,10 @@ CREATE TABLE namespace_settings (
project_runner_token_expiration_interval integer,
exclude_from_free_user_cap boolean DEFAULT false NOT NULL,
enabled_git_access_protocol smallint DEFAULT 0 NOT NULL,
+ unique_project_download_limit smallint DEFAULT 0 NOT NULL,
+ 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))
);
@@ -17861,7 +17942,8 @@ CREATE TABLE operations_feature_flags (
CREATE TABLE operations_feature_flags_clients (
id bigint NOT NULL,
project_id integer NOT NULL,
- token_encrypted character varying
+ token_encrypted character varying,
+ last_feature_flag_updated_at timestamp with time zone
);
CREATE SEQUENCE operations_feature_flags_clients_id_seq
@@ -18789,7 +18871,9 @@ CREATE TABLE plan_limits (
repository_size bigint DEFAULT 0 NOT NULL,
security_policy_scan_execution_schedules integer DEFAULT 0 NOT NULL,
web_hook_calls_mid integer DEFAULT 0 NOT NULL,
- web_hook_calls_low 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
);
CREATE SEQUENCE plan_limits_id_seq
@@ -19200,7 +19284,8 @@ CREATE TABLE project_ci_cd_settings (
restrict_user_defined_variables boolean DEFAULT false NOT NULL,
job_token_scope_enabled boolean DEFAULT false NOT NULL,
runner_token_expiration_interval integer,
- separated_caches boolean DEFAULT true NOT NULL
+ separated_caches boolean DEFAULT true NOT NULL,
+ opt_in_jwt boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE project_ci_cd_settings_id_seq
@@ -19348,7 +19433,12 @@ CREATE TABLE project_features (
analytics_access_level integer DEFAULT 20 NOT NULL,
security_and_compliance_access_level integer DEFAULT 10 NOT NULL,
container_registry_access_level integer DEFAULT 0 NOT NULL,
- package_registry_access_level integer DEFAULT 0 NOT NULL
+ package_registry_access_level integer DEFAULT 0 NOT NULL,
+ monitor_access_level integer DEFAULT 20 NOT NULL,
+ infrastructure_access_level integer DEFAULT 20 NOT NULL,
+ feature_flags_access_level integer DEFAULT 20 NOT NULL,
+ environments_access_level integer DEFAULT 20 NOT NULL,
+ releases_access_level integer DEFAULT 20 NOT NULL
);
CREATE SEQUENCE project_features_id_seq
@@ -19458,6 +19548,47 @@ CREATE TABLE project_pages_metadata (
onboarding_complete boolean DEFAULT false NOT NULL
);
+CREATE TABLE project_relation_export_uploads (
+ id bigint NOT NULL,
+ project_relation_export_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ export_file text NOT NULL,
+ CONSTRAINT check_d8ee243e9e CHECK ((char_length(export_file) <= 255))
+);
+
+CREATE SEQUENCE project_relation_export_uploads_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE project_relation_export_uploads_id_seq OWNED BY project_relation_export_uploads.id;
+
+CREATE TABLE project_relation_exports (
+ id bigint NOT NULL,
+ project_export_job_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ status smallint DEFAULT 0 NOT NULL,
+ relation text NOT NULL,
+ jid text,
+ export_error text,
+ CONSTRAINT check_15e644d856 CHECK ((char_length(jid) <= 255)),
+ CONSTRAINT check_4b5880b795 CHECK ((char_length(relation) <= 255)),
+ CONSTRAINT check_dbd1cf73d0 CHECK ((char_length(export_error) <= 300))
+);
+
+CREATE SEQUENCE project_relation_exports_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE project_relation_exports_id_seq OWNED BY project_relation_exports.id;
+
CREATE TABLE project_repositories (
id bigint NOT NULL,
shard_id integer NOT NULL,
@@ -19612,23 +19743,6 @@ CREATE SEQUENCE project_topics_id_seq
ALTER SEQUENCE project_topics_id_seq OWNED BY project_topics.id;
-CREATE TABLE project_tracing_settings (
- id bigint NOT NULL,
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL,
- project_id integer NOT NULL,
- external_url character varying NOT NULL
-);
-
-CREATE SEQUENCE project_tracing_settings_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE project_tracing_settings_id_seq OWNED BY project_tracing_settings.id;
-
CREATE TABLE projects (
id integer NOT NULL,
name character varying,
@@ -20176,19 +20290,20 @@ ALTER SEQUENCE required_code_owners_sections_id_seq OWNED BY required_code_owner
CREATE TABLE requirements (
id bigint NOT NULL,
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL,
+ created_at timestamp with time zone,
+ updated_at timestamp with time zone,
project_id integer NOT NULL,
author_id integer,
iid integer NOT NULL,
cached_markdown_version integer,
- state smallint DEFAULT 1 NOT NULL,
- title character varying(255) NOT NULL,
+ state smallint DEFAULT 1,
+ title character varying(255),
title_html text,
description text,
description_html text,
issue_id bigint,
- CONSTRAINT check_785ae25b9d CHECK ((char_length(description) <= 10000))
+ CONSTRAINT check_785ae25b9d CHECK ((char_length(description) <= 10000)),
+ CONSTRAINT check_requirement_issue_not_null CHECK ((issue_id IS NOT NULL))
);
CREATE SEQUENCE requirements_id_seq
@@ -20347,7 +20462,8 @@ CREATE TABLE routes (
created_at timestamp without time zone,
updated_at timestamp without time zone,
name character varying,
- namespace_id bigint
+ namespace_id bigint,
+ CONSTRAINT check_af84c6c93f CHECK ((namespace_id IS NOT NULL))
);
CREATE SEQUENCE routes_id_seq
@@ -20420,6 +20536,80 @@ CREATE SEQUENCE saved_replies_id_seq
ALTER SEQUENCE saved_replies_id_seq OWNED BY saved_replies.id;
+CREATE TABLE sbom_component_versions (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ component_id bigint NOT NULL,
+ version text NOT NULL,
+ CONSTRAINT check_e71cad08d3 CHECK ((char_length(version) <= 255))
+);
+
+CREATE SEQUENCE sbom_component_versions_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE sbom_component_versions_id_seq OWNED BY sbom_component_versions.id;
+
+CREATE TABLE sbom_components (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ component_type smallint NOT NULL,
+ name text NOT NULL,
+ CONSTRAINT check_91a8f6ad53 CHECK ((char_length(name) <= 255))
+);
+
+CREATE SEQUENCE sbom_components_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE sbom_components_id_seq OWNED BY sbom_components.id;
+
+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,
+ project_id bigint NOT NULL,
+ pipeline_id bigint,
+ source_id bigint,
+ commit_sha bytea NOT NULL
+);
+
+CREATE SEQUENCE sbom_occurrences_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE sbom_occurrences_id_seq OWNED BY sbom_occurrences.id;
+
+CREATE TABLE sbom_sources (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ source_type smallint NOT NULL,
+ source jsonb DEFAULT '{}'::jsonb NOT NULL,
+ fingerprint bytea NOT NULL
+);
+
+CREATE SEQUENCE sbom_sources_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE sbom_sources_id_seq OWNED BY sbom_sources.id;
+
CREATE TABLE schema_migrations (
version character varying NOT NULL,
finished_at timestamp with time zone DEFAULT now()
@@ -20471,8 +20661,10 @@ CREATE TABLE security_findings (
deduplicated boolean DEFAULT false NOT NULL,
uuid uuid,
overridden_uuid uuid,
+ partition_number integer DEFAULT 1 NOT NULL,
CONSTRAINT check_6c2851a8c9 CHECK ((uuid IS NOT NULL)),
- CONSTRAINT check_b9508c6df8 CHECK ((char_length(project_fingerprint) <= 40))
+ CONSTRAINT check_b9508c6df8 CHECK ((char_length(project_fingerprint) <= 40)),
+ CONSTRAINT check_partition_number CHECK ((partition_number = 1))
);
CREATE SEQUENCE security_findings_id_seq
@@ -20540,7 +20732,8 @@ CREATE TABLE security_scans (
project_id bigint,
pipeline_id bigint,
latest boolean DEFAULT true NOT NULL,
- status smallint DEFAULT 0 NOT NULL
+ status smallint DEFAULT 0 NOT NULL,
+ findings_partition_number integer DEFAULT 1 NOT NULL
);
CREATE SEQUENCE security_scans_id_seq
@@ -21508,6 +21701,23 @@ CREATE TABLE user_interacted_projects (
project_id integer NOT NULL
);
+CREATE TABLE user_namespace_callouts (
+ id bigint NOT NULL,
+ user_id bigint NOT NULL,
+ namespace_id bigint NOT NULL,
+ dismissed_at timestamp with time zone,
+ feature_name smallint NOT NULL
+);
+
+CREATE SEQUENCE user_namespace_callouts_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE user_namespace_callouts_id_seq OWNED BY user_namespace_callouts.id;
+
CREATE TABLE user_permission_export_uploads (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -22045,6 +22255,23 @@ CREATE SEQUENCE vulnerability_issue_links_id_seq
ALTER SEQUENCE vulnerability_issue_links_id_seq OWNED BY vulnerability_issue_links.id;
+CREATE TABLE vulnerability_merge_request_links (
+ id bigint NOT NULL,
+ vulnerability_id bigint NOT NULL,
+ merge_request_id integer NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL
+);
+
+CREATE SEQUENCE vulnerability_merge_request_links_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE vulnerability_merge_request_links_id_seq OWNED BY vulnerability_merge_request_links.id;
+
CREATE TABLE vulnerability_occurrence_identifiers (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -22132,6 +22359,7 @@ CREATE TABLE vulnerability_reads (
uuid uuid NOT NULL,
location_image text,
cluster_agent_id text,
+ casted_cluster_agent_id bigint,
CONSTRAINT check_380451bdbe CHECK ((char_length(location_image) <= 2048)),
CONSTRAINT check_a105eb825a CHECK ((char_length(cluster_agent_id) <= 10))
);
@@ -22315,7 +22543,7 @@ CREATE TABLE webauthn_registrations (
public_key text NOT NULL,
u2f_registration_id integer,
CONSTRAINT check_2f02e74321 CHECK ((char_length(name) <= 255)),
- CONSTRAINT check_e54008d9ce CHECK ((char_length(credential_xid) <= 340))
+ CONSTRAINT check_f5ab2b551a CHECK ((char_length(credential_xid) <= 1364))
);
CREATE SEQUENCE webauthn_registrations_id_seq
@@ -22707,6 +22935,8 @@ ALTER TABLE ONLY ci_runners ALTER COLUMN id SET DEFAULT nextval('ci_runners_id_s
ALTER TABLE ONLY ci_running_builds ALTER COLUMN id SET DEFAULT nextval('ci_running_builds_id_seq'::regclass);
+ALTER TABLE ONLY ci_secure_file_states ALTER COLUMN ci_secure_file_id SET DEFAULT nextval('ci_secure_file_states_ci_secure_file_id_seq'::regclass);
+
ALTER TABLE ONLY ci_secure_files ALTER COLUMN id SET DEFAULT nextval('ci_secure_files_id_seq'::regclass);
ALTER TABLE ONLY ci_sources_pipelines ALTER COLUMN id SET DEFAULT nextval('ci_sources_pipelines_id_seq'::regclass);
@@ -22751,8 +22981,6 @@ ALTER TABLE ONLY clusters_applications_cilium ALTER COLUMN id SET DEFAULT nextva
ALTER TABLE ONLY clusters_applications_crossplane ALTER COLUMN id SET DEFAULT nextval('clusters_applications_crossplane_id_seq'::regclass);
-ALTER TABLE ONLY clusters_applications_elastic_stacks ALTER COLUMN id SET DEFAULT nextval('clusters_applications_elastic_stacks_id_seq'::regclass);
-
ALTER TABLE ONLY clusters_applications_helm ALTER COLUMN id SET DEFAULT nextval('clusters_applications_helm_id_seq'::regclass);
ALTER TABLE ONLY clusters_applications_ingress ALTER COLUMN id SET DEFAULT nextval('clusters_applications_ingress_id_seq'::regclass);
@@ -23089,6 +23317,8 @@ ALTER TABLE ONLY milestones ALTER COLUMN id SET DEFAULT nextval('milestones_id_s
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);
+
ALTER TABLE ONLY namespace_statistics ALTER COLUMN id SET DEFAULT nextval('namespace_statistics_id_seq'::regclass);
ALTER TABLE ONLY namespaces ALTER COLUMN id SET DEFAULT nextval('namespaces_id_seq'::regclass);
@@ -23231,6 +23461,10 @@ ALTER TABLE ONLY project_incident_management_settings ALTER COLUMN project_id SE
ALTER TABLE ONLY project_mirror_data ALTER COLUMN id SET DEFAULT nextval('project_mirror_data_id_seq'::regclass);
+ALTER TABLE ONLY project_relation_export_uploads ALTER COLUMN id SET DEFAULT nextval('project_relation_export_uploads_id_seq'::regclass);
+
+ALTER TABLE ONLY project_relation_exports ALTER COLUMN id SET DEFAULT nextval('project_relation_exports_id_seq'::regclass);
+
ALTER TABLE ONLY project_repositories ALTER COLUMN id SET DEFAULT nextval('project_repositories_id_seq'::regclass);
ALTER TABLE ONLY project_repository_states ALTER COLUMN id SET DEFAULT nextval('project_repository_states_id_seq'::regclass);
@@ -23243,8 +23477,6 @@ ALTER TABLE ONLY project_statistics ALTER COLUMN id SET DEFAULT nextval('project
ALTER TABLE ONLY project_topics ALTER COLUMN id SET DEFAULT nextval('project_topics_id_seq'::regclass);
-ALTER TABLE ONLY project_tracing_settings ALTER COLUMN id SET DEFAULT nextval('project_tracing_settings_id_seq'::regclass);
-
ALTER TABLE ONLY projects ALTER COLUMN id SET DEFAULT nextval('projects_id_seq'::regclass);
ALTER TABLE ONLY projects_sync_events ALTER COLUMN id SET DEFAULT nextval('projects_sync_events_id_seq'::regclass);
@@ -23313,6 +23545,14 @@ ALTER TABLE ONLY saml_providers ALTER COLUMN id SET DEFAULT nextval('saml_provid
ALTER TABLE ONLY saved_replies ALTER COLUMN id SET DEFAULT nextval('saved_replies_id_seq'::regclass);
+ALTER TABLE ONLY sbom_component_versions ALTER COLUMN id SET DEFAULT nextval('sbom_component_versions_id_seq'::regclass);
+
+ALTER TABLE ONLY sbom_components ALTER COLUMN id SET DEFAULT nextval('sbom_components_id_seq'::regclass);
+
+ALTER TABLE ONLY sbom_occurrences ALTER COLUMN id SET DEFAULT nextval('sbom_occurrences_id_seq'::regclass);
+
+ALTER TABLE ONLY sbom_sources ALTER COLUMN id SET DEFAULT nextval('sbom_sources_id_seq'::regclass);
+
ALTER TABLE ONLY scim_identities ALTER COLUMN id SET DEFAULT nextval('scim_identities_id_seq'::regclass);
ALTER TABLE ONLY scim_oauth_access_tokens ALTER COLUMN id SET DEFAULT nextval('scim_oauth_access_tokens_id_seq'::regclass);
@@ -23411,6 +23651,8 @@ ALTER TABLE ONLY user_details ALTER COLUMN user_id SET DEFAULT nextval('user_det
ALTER TABLE ONLY user_group_callouts ALTER COLUMN id SET DEFAULT nextval('user_group_callouts_id_seq'::regclass);
+ALTER TABLE ONLY user_namespace_callouts ALTER COLUMN id SET DEFAULT nextval('user_namespace_callouts_id_seq'::regclass);
+
ALTER TABLE ONLY user_permission_export_uploads ALTER COLUMN id SET DEFAULT nextval('user_permission_export_uploads_id_seq'::regclass);
ALTER TABLE ONLY user_preferences ALTER COLUMN id SET DEFAULT nextval('user_preferences_id_seq'::regclass);
@@ -23451,6 +23693,8 @@ ALTER TABLE ONLY vulnerability_identifiers ALTER COLUMN id SET DEFAULT nextval('
ALTER TABLE ONLY vulnerability_issue_links ALTER COLUMN id SET DEFAULT nextval('vulnerability_issue_links_id_seq'::regclass);
+ALTER TABLE ONLY vulnerability_merge_request_links ALTER COLUMN id SET DEFAULT nextval('vulnerability_merge_request_links_id_seq'::regclass);
+
ALTER TABLE ONLY vulnerability_occurrence_identifiers ALTER COLUMN id SET DEFAULT nextval('vulnerability_occurrence_identifiers_id_seq'::regclass);
ALTER TABLE ONLY vulnerability_occurrence_pipelines ALTER COLUMN id SET DEFAULT nextval('vulnerability_occurrence_pipelines_id_seq'::regclass);
@@ -24300,9 +24544,6 @@ ALTER TABLE ONLY chat_teams
ALTER TABLE vulnerability_scanners
ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) NOT VALID;
-ALTER TABLE routes
- ADD CONSTRAINT check_af84c6c93f CHECK ((namespace_id IS NOT NULL)) NOT VALID;
-
ALTER TABLE sprints
ADD CONSTRAINT check_ccd8a1eae0 CHECK ((start_date IS NOT NULL)) NOT VALID;
@@ -24315,9 +24556,6 @@ ALTER TABLE sprints
ALTER TABLE projects
ADD CONSTRAINT check_fa75869cb1 CHECK ((project_namespace_id IS NOT NULL)) NOT VALID;
-ALTER TABLE requirements
- ADD CONSTRAINT check_requirement_issue_not_null CHECK ((issue_id IS NOT NULL)) NOT VALID;
-
ALTER TABLE ONLY ci_build_needs
ADD CONSTRAINT ci_build_needs_pkey PRIMARY KEY (id);
@@ -24429,12 +24667,18 @@ ALTER TABLE ONLY ci_runner_namespaces
ALTER TABLE ONLY ci_runner_projects
ADD CONSTRAINT ci_runner_projects_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ci_runner_versions
+ ADD CONSTRAINT ci_runner_versions_pkey PRIMARY KEY (version);
+
ALTER TABLE ONLY ci_runners
ADD CONSTRAINT ci_runners_pkey PRIMARY KEY (id);
ALTER TABLE ONLY ci_running_builds
ADD CONSTRAINT ci_running_builds_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ci_secure_file_states
+ ADD CONSTRAINT ci_secure_file_states_pkey PRIMARY KEY (ci_secure_file_id);
+
ALTER TABLE ONLY ci_secure_files
ADD CONSTRAINT ci_secure_files_pkey PRIMARY KEY (id);
@@ -24498,9 +24742,6 @@ ALTER TABLE ONLY clusters_applications_cilium
ALTER TABLE ONLY clusters_applications_crossplane
ADD CONSTRAINT clusters_applications_crossplane_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY clusters_applications_elastic_stacks
- ADD CONSTRAINT clusters_applications_elastic_stacks_pkey PRIMARY KEY (id);
-
ALTER TABLE ONLY clusters_applications_helm
ADD CONSTRAINT clusters_applications_helm_pkey PRIMARY KEY (id);
@@ -24519,9 +24760,6 @@ ALTER TABLE ONLY clusters_applications_prometheus
ALTER TABLE ONLY clusters_applications_runners
ADD CONSTRAINT clusters_applications_runners_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY clusters_integration_elasticstack
- ADD CONSTRAINT clusters_integration_elasticstack_pkey PRIMARY KEY (cluster_id);
-
ALTER TABLE ONLY clusters_integration_prometheus
ADD CONSTRAINT clusters_integration_prometheus_pkey PRIMARY KEY (cluster_id);
@@ -25089,6 +25327,9 @@ ALTER TABLE ONLY namespace_admin_notes
ALTER TABLE ONLY namespace_aggregation_schedules
ADD CONSTRAINT namespace_aggregation_schedules_pkey PRIMARY KEY (namespace_id);
+ALTER TABLE ONLY namespace_bans
+ ADD CONSTRAINT namespace_bans_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY namespace_ci_cd_settings
ADD CONSTRAINT namespace_ci_cd_settings_pkey PRIMARY KEY (namespace_id);
@@ -25362,6 +25603,12 @@ ALTER TABLE ONLY project_mirror_data
ALTER TABLE ONLY project_pages_metadata
ADD CONSTRAINT project_pages_metadata_pkey PRIMARY KEY (project_id);
+ALTER TABLE ONLY project_relation_export_uploads
+ ADD CONSTRAINT project_relation_export_uploads_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY project_relation_exports
+ ADD CONSTRAINT project_relation_exports_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY project_repositories
ADD CONSTRAINT project_repositories_pkey PRIMARY KEY (id);
@@ -25383,9 +25630,6 @@ ALTER TABLE ONLY project_statistics
ALTER TABLE ONLY project_topics
ADD CONSTRAINT project_topics_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY project_tracing_settings
- ADD CONSTRAINT project_tracing_settings_pkey PRIMARY KEY (id);
-
ALTER TABLE ONLY projects
ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
@@ -25497,6 +25741,18 @@ ALTER TABLE ONLY saml_providers
ALTER TABLE ONLY saved_replies
ADD CONSTRAINT saved_replies_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY sbom_component_versions
+ ADD CONSTRAINT sbom_component_versions_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY sbom_components
+ ADD CONSTRAINT sbom_components_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY sbom_occurrences
+ ADD CONSTRAINT sbom_occurrences_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY sbom_sources
+ ADD CONSTRAINT sbom_sources_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
@@ -25674,6 +25930,9 @@ ALTER TABLE ONLY user_highest_roles
ALTER TABLE ONLY user_interacted_projects
ADD CONSTRAINT user_interacted_projects_pkey PRIMARY KEY (project_id, user_id);
+ALTER TABLE ONLY user_namespace_callouts
+ ADD CONSTRAINT user_namespace_callouts_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY user_permission_export_uploads
ADD CONSTRAINT user_permission_export_uploads_pkey PRIMARY KEY (id);
@@ -25740,6 +25999,9 @@ ALTER TABLE ONLY vulnerability_identifiers
ALTER TABLE ONLY vulnerability_issue_links
ADD CONSTRAINT vulnerability_issue_links_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY vulnerability_merge_request_links
+ ADD CONSTRAINT vulnerability_merge_request_links_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY vulnerability_occurrence_identifiers
ADD CONSTRAINT vulnerability_occurrence_identifiers_pkey PRIMARY KEY (id);
@@ -26817,6 +27079,8 @@ CREATE INDEX idx_eaprpb_external_approval_rule_id ON external_approval_rules_pro
CREATE INDEX idx_elastic_reindexing_slices_on_elastic_reindexing_subtask_id ON elastic_reindexing_slices USING btree (elastic_reindexing_subtask_id);
+CREATE INDEX idx_enabled_pkgs_cleanup_policies_on_next_run_at_project_id ON packages_cleanup_policies USING btree (next_run_at, project_id) WHERE (keep_n_duplicated_package_files <> 'all'::text);
+
CREATE UNIQUE INDEX idx_environment_merge_requests_unique_index ON deployment_merge_requests USING btree (environment_id, merge_request_id);
CREATE UNIQUE INDEX idx_external_audit_event_destination_id_key_uniq ON audit_events_streaming_headers USING btree (key, external_audit_event_destination_id);
@@ -26897,6 +27161,8 @@ CREATE INDEX idx_pkgs_debian_project_distribution_keys_on_distribution_id ON pac
CREATE UNIQUE INDEX idx_pkgs_dep_links_on_pkg_id_dependency_id_dependency_type ON packages_dependency_links USING btree (package_id, dependency_id, dependency_type);
+CREATE INDEX idx_pkgs_installable_package_files_on_package_id_id_file_name ON packages_package_files USING btree (package_id, id, file_name) WHERE (status = 0);
+
CREATE INDEX idx_proj_feat_usg_on_jira_dvcs_cloud_last_sync_at_and_proj_id ON project_feature_usages USING btree (jira_dvcs_cloud_last_sync_at, project_id) WHERE (jira_dvcs_cloud_last_sync_at IS NOT NULL);
CREATE INDEX idx_proj_feat_usg_on_jira_dvcs_server_last_sync_at_and_proj_id ON project_feature_usages USING btree (jira_dvcs_server_last_sync_at, project_id) WHERE (jira_dvcs_server_last_sync_at IS NOT NULL);
@@ -27107,7 +27373,7 @@ CREATE INDEX index_authentication_events_on_provider ON authentication_events US
CREATE INDEX index_authentication_events_on_provider_user_id_created_at ON authentication_events USING btree (provider, user_id, created_at) WHERE (result = 1);
-CREATE INDEX index_authentication_events_on_user_id ON authentication_events USING btree (user_id);
+CREATE INDEX index_authentication_events_on_user_and_ip_address_and_result ON authentication_events USING btree (user_id, ip_address, result);
CREATE INDEX index_award_emoji_on_awardable_type_and_awardable_id ON award_emoji USING btree (awardable_type, awardable_id);
@@ -27271,8 +27537,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_project_id_for_successfull_pages_deploy ON ci_builds USING btree (project_id) WHERE (((type)::text = 'GenericCommitStatus'::text) AND ((stage)::text = 'deploy'::text) AND ((name)::text = 'pages:deploy'::text) AND ((status)::text = 'success'::text));
-
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);
@@ -27285,8 +27549,6 @@ CREATE INDEX index_ci_builds_on_status_and_type_and_runner_id ON ci_builds USING
CREATE UNIQUE INDEX index_ci_builds_on_token_encrypted ON ci_builds USING btree (token_encrypted) WHERE (token_encrypted IS NOT NULL);
-CREATE UNIQUE INDEX index_ci_builds_on_token_partial ON ci_builds USING btree (token) WHERE (token IS NOT NULL);
-
CREATE INDEX index_ci_builds_on_updated_at ON ci_builds USING btree (updated_at);
CREATE INDEX index_ci_builds_on_upstream_pipeline_id ON ci_builds USING btree (upstream_pipeline_id) WHERE (upstream_pipeline_id IS NOT NULL);
@@ -27467,6 +27729,8 @@ CREATE UNIQUE INDEX index_ci_runner_namespaces_on_runner_id_and_namespace_id ON
CREATE INDEX index_ci_runner_projects_on_project_id ON ci_runner_projects USING btree (project_id);
+CREATE UNIQUE INDEX index_ci_runner_versions_on_unique_status_and_version ON ci_runner_versions USING btree (status, version);
+
CREATE INDEX index_ci_runners_on_active ON ci_runners USING btree (active, id);
CREATE INDEX index_ci_runners_on_contacted_at_and_id_desc ON ci_runners USING btree (contacted_at, id DESC);
@@ -27497,12 +27761,24 @@ CREATE INDEX index_ci_runners_on_token_expires_at_and_id_desc ON ci_runners USIN
CREATE INDEX index_ci_runners_on_token_expires_at_desc_and_id_desc ON ci_runners USING btree (token_expires_at DESC, id DESC);
+CREATE INDEX index_ci_runners_on_version ON ci_runners USING btree (version);
+
CREATE UNIQUE INDEX index_ci_running_builds_on_build_id ON ci_running_builds USING btree (build_id);
CREATE INDEX index_ci_running_builds_on_project_id ON ci_running_builds USING btree (project_id);
CREATE INDEX index_ci_running_builds_on_runner_id ON ci_running_builds USING btree (runner_id);
+CREATE INDEX index_ci_secure_file_states_failed_verification ON ci_secure_file_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
+
+CREATE INDEX index_ci_secure_file_states_needs_verification ON ci_secure_file_states USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3));
+
+CREATE INDEX index_ci_secure_file_states_on_ci_secure_file_id ON ci_secure_file_states USING btree (ci_secure_file_id);
+
+CREATE INDEX index_ci_secure_file_states_on_verification_state ON ci_secure_file_states USING btree (verification_state);
+
+CREATE INDEX index_ci_secure_file_states_pending_verification ON ci_secure_file_states USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0);
+
CREATE INDEX index_ci_secure_files_on_project_id ON ci_secure_files USING btree (project_id);
CREATE INDEX index_ci_sources_pipelines_on_pipeline_id ON ci_sources_pipelines USING btree (pipeline_id);
@@ -27551,6 +27827,8 @@ CREATE UNIQUE INDEX index_ci_variables_on_project_id_and_key_and_environment_sco
CREATE INDEX index_cicd_settings_on_namespace_id_where_stale_pruning_enabled ON namespace_ci_cd_settings USING btree (namespace_id) WHERE (allow_stale_runner_pruning = true);
+CREATE INDEX index_cis_vulnerability_reads_on_cluster_agent_id ON vulnerability_reads USING btree (casted_cluster_agent_id) WHERE (report_type = 7);
+
CREATE INDEX index_cluster_agent_tokens_on_agent_id_status_last_used_at ON cluster_agent_tokens USING btree (agent_id, status, last_used_at DESC NULLS LAST);
CREATE INDEX index_cluster_agent_tokens_on_created_by_user_id ON cluster_agent_tokens USING btree (created_by_user_id);
@@ -27589,8 +27867,6 @@ CREATE UNIQUE INDEX index_clusters_applications_cilium_on_cluster_id ON clusters
CREATE UNIQUE INDEX index_clusters_applications_crossplane_on_cluster_id ON clusters_applications_crossplane USING btree (cluster_id);
-CREATE UNIQUE INDEX index_clusters_applications_elastic_stacks_on_cluster_id ON clusters_applications_elastic_stacks USING btree (cluster_id);
-
CREATE UNIQUE INDEX index_clusters_applications_helm_on_cluster_id ON clusters_applications_helm USING btree (cluster_id);
CREATE UNIQUE INDEX index_clusters_applications_ingress_on_cluster_id ON clusters_applications_ingress USING btree (cluster_id);
@@ -27607,8 +27883,6 @@ CREATE UNIQUE INDEX index_clusters_applications_runners_on_cluster_id ON cluster
CREATE INDEX index_clusters_applications_runners_on_runner_id ON clusters_applications_runners USING btree (runner_id);
-CREATE INDEX index_clusters_integration_elasticstack_enabled ON clusters_integration_elasticstack USING btree (enabled, created_at, cluster_id);
-
CREATE INDEX index_clusters_integration_prometheus_enabled ON clusters_integration_prometheus USING btree (enabled, created_at, cluster_id);
CREATE INDEX index_clusters_kubernetes_namespaces_on_cluster_project_id ON clusters_kubernetes_namespaces USING btree (cluster_project_id);
@@ -28289,7 +28563,7 @@ CREATE INDEX index_issues_on_milestone_id ON issues USING btree (milestone_id);
CREATE INDEX index_issues_on_moved_to_id ON issues USING btree (moved_to_id) WHERE (moved_to_id IS NOT NULL);
-CREATE INDEX index_issues_on_project_id_and_closed_at ON issues USING btree (project_id, closed_at);
+CREATE INDEX index_issues_on_namespace_id ON issues USING btree (namespace_id);
CREATE INDEX index_issues_on_project_id_and_created_at_issue_type_incident ON issues USING btree (project_id, created_at) WHERE (issue_type = 1);
@@ -28301,6 +28575,10 @@ CREATE INDEX index_issues_on_project_id_and_state_id_and_created_at_and_id ON is
CREATE INDEX index_issues_on_project_id_and_upvotes_count ON issues USING btree (project_id, upvotes_count);
+CREATE INDEX index_issues_on_project_id_closed_at_desc_state_id_and_id ON issues USING btree (project_id, closed_at DESC NULLS LAST, state_id, id);
+
+CREATE INDEX index_issues_on_project_id_closed_at_state_id_and_id ON issues USING btree (project_id, closed_at, state_id, id);
+
CREATE INDEX index_issues_on_promoted_to_epic_id ON issues USING btree (promoted_to_epic_id) WHERE (promoted_to_epic_id IS NOT NULL);
CREATE INDEX index_issues_on_sprint_id ON issues USING btree (sprint_id);
@@ -28603,6 +28881,10 @@ CREATE INDEX index_namespace_admin_notes_on_namespace_id ON namespace_admin_note
CREATE UNIQUE INDEX index_namespace_aggregation_schedules_on_namespace_id ON namespace_aggregation_schedules USING btree (namespace_id);
+CREATE UNIQUE INDEX index_namespace_bans_on_namespace_id_and_user_id ON namespace_bans USING btree (namespace_id, user_id);
+
+CREATE INDEX index_namespace_bans_on_user_id ON namespace_bans USING btree (user_id);
+
CREATE UNIQUE INDEX index_namespace_root_storage_statistics_on_namespace_id ON namespace_root_storage_statistics USING btree (namespace_id);
CREATE UNIQUE INDEX index_namespace_statistics_on_namespace_id ON namespace_statistics USING btree (namespace_id);
@@ -28681,6 +28963,8 @@ CREATE INDEX index_notification_settings_on_source_and_level_and_user ON notific
CREATE UNIQUE INDEX index_notifications_on_user_id_and_source_id_and_source_type ON notification_settings USING btree (user_id, source_id, source_type);
+CREATE UNIQUE INDEX index_ns_user_callouts_feature ON user_namespace_callouts USING btree (user_id, feature_name, namespace_id);
+
CREATE INDEX index_oauth_access_grants_on_resource_owner_id ON oauth_access_grants USING btree (resource_owner_id, application_id, created_at);
CREATE UNIQUE INDEX index_oauth_access_grants_on_token ON oauth_access_grants USING btree (token);
@@ -28689,8 +28973,6 @@ CREATE INDEX index_oauth_access_tokens_on_application_id ON oauth_access_tokens
CREATE UNIQUE INDEX index_oauth_access_tokens_on_refresh_token ON oauth_access_tokens USING btree (refresh_token);
-CREATE INDEX index_oauth_access_tokens_on_resource_owner_id ON oauth_access_tokens USING btree (resource_owner_id);
-
CREATE UNIQUE INDEX index_oauth_access_tokens_on_token ON oauth_access_tokens USING btree (token);
CREATE INDEX index_oauth_applications_on_owner_id_and_owner_type ON oauth_applications USING btree (owner_id, owner_type);
@@ -28705,6 +28987,8 @@ CREATE INDEX index_on_dingtalk_tracker_data_corpid ON dingtalk_tracker_data USIN
COMMENT ON INDEX index_on_dingtalk_tracker_data_corpid IS 'JiHu-specific index';
+CREATE INDEX index_on_events_to_improve_contribution_analytics_performance ON events USING btree (project_id, target_type, action, created_at, author_id, id);
+
CREATE INDEX index_on_group_id_on_webhooks ON web_hooks USING btree (group_id);
CREATE INDEX index_on_identities_lower_extern_uid_and_provider ON identities USING btree (lower((extern_uid)::text), provider);
@@ -28743,6 +29027,8 @@ CREATE INDEX index_on_projects_path ON projects USING btree (path);
CREATE INDEX index_on_routes_lower_path ON routes USING btree (lower((path)::text));
+CREATE INDEX index_on_security_findings_uuid_and_id_order_desc ON security_findings USING btree (uuid, id DESC);
+
CREATE INDEX index_on_users_lower_email ON users USING btree (lower((email)::text));
CREATE INDEX index_on_users_lower_username ON users USING btree (lower((username)::text));
@@ -28857,7 +29143,7 @@ CREATE INDEX index_packages_packages_on_project_id_and_created_at ON packages_pa
CREATE INDEX index_packages_packages_on_project_id_and_package_type ON packages_packages USING btree (project_id, package_type);
-CREATE INDEX index_packages_packages_on_project_id_and_status ON packages_packages USING btree (project_id, status);
+CREATE INDEX index_packages_packages_on_project_id_and_status_and_id ON packages_packages USING btree (project_id, status, id);
CREATE INDEX index_packages_packages_on_project_id_and_version ON packages_packages USING btree (project_id, version);
@@ -28911,8 +29197,6 @@ CREATE INDEX index_pages_domains_on_verified_at_and_enabled_until ON pages_domai
CREATE INDEX index_pages_domains_on_wildcard ON pages_domains USING btree (wildcard);
-CREATE UNIQUE INDEX index_parent_links_on_work_item_id_and_work_item_parent_id ON work_item_parent_links USING btree (work_item_id, work_item_parent_id);
-
CREATE INDEX index_partial_ci_builds_on_user_id_name_parser_features ON ci_builds USING btree (user_id, name) WHERE (((type)::text = 'Ci::Build'::text) AND ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('license_scanning'::character varying)::text, ('sast'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('secret_detection'::character varying)::text])));
CREATE INDEX index_pat_on_user_id_and_expires_at ON personal_access_tokens USING btree (user_id, expires_at);
@@ -28923,6 +29207,8 @@ CREATE INDEX index_path_locks_on_project_id ON path_locks USING btree (project_i
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 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);
@@ -28973,6 +29259,8 @@ CREATE INDEX index_project_deploy_tokens_on_deploy_token_id ON project_deploy_to
CREATE UNIQUE INDEX index_project_deploy_tokens_on_project_id_and_deploy_token_id ON project_deploy_tokens USING btree (project_id, deploy_token_id);
+CREATE UNIQUE INDEX index_project_export_job_relation ON project_relation_exports USING btree (project_export_job_id, relation);
+
CREATE UNIQUE INDEX index_project_export_jobs_on_jid ON project_export_jobs USING btree (jid);
CREATE INDEX index_project_export_jobs_on_project_id_and_jid ON project_export_jobs USING btree (project_id, jid);
@@ -29011,6 +29299,10 @@ CREATE INDEX index_project_pages_metadata_on_pages_deployment_id ON project_page
CREATE INDEX index_project_pages_metadata_on_project_id_and_deployed_is_true ON project_pages_metadata USING btree (project_id) WHERE (deployed = true);
+CREATE INDEX index_project_relation_export_upload_id ON project_relation_export_uploads USING btree (project_relation_export_id);
+
+CREATE INDEX index_project_relation_exports_on_project_export_job_id ON project_relation_exports USING btree (project_export_job_id);
+
CREATE UNIQUE INDEX index_project_repositories_on_disk_path ON project_repositories USING btree (disk_path);
CREATE UNIQUE INDEX index_project_repositories_on_project_id ON project_repositories USING btree (project_id);
@@ -29047,8 +29339,6 @@ 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_tracing_settings_on_project_id ON project_tracing_settings USING btree (project_id);
-
CREATE INDEX index_projects_aimed_for_deletion ON projects USING btree (marked_for_deletion_at) WHERE ((marked_for_deletion_at IS NOT NULL) AND (pending_delete = false));
CREATE INDEX index_projects_api_created_at_id_desc ON projects USING btree (created_at, id DESC);
@@ -29127,10 +29417,6 @@ CREATE UNIQUE INDEX index_projects_on_project_namespace_id ON projects USING btr
CREATE INDEX index_projects_on_repository_storage ON projects USING btree (repository_storage);
-CREATE INDEX index_projects_on_runners_token ON projects USING btree (runners_token);
-
-CREATE INDEX index_projects_on_runners_token_encrypted ON projects USING btree (runners_token_encrypted);
-
CREATE INDEX index_projects_on_star_count ON projects USING btree (star_count);
CREATE INDEX index_projects_on_updated_at_and_id ON projects USING btree (updated_at, id);
@@ -29187,6 +29473,8 @@ CREATE INDEX index_protected_environment_deploy_access_levels_on_group_id ON pro
CREATE INDEX index_protected_environment_deploy_access_levels_on_user_id ON protected_environment_deploy_access_levels USING btree (user_id);
+CREATE INDEX index_protected_environments_on_approval_count_and_created_at ON protected_environments USING btree (required_approval_count, created_at);
+
CREATE UNIQUE INDEX index_protected_environments_on_group_id_and_name ON protected_environments USING btree (group_id, name) WHERE (group_id IS NOT NULL);
CREATE INDEX index_protected_environments_on_project_id ON protected_environments USING btree (project_id);
@@ -29333,6 +29621,16 @@ CREATE INDEX index_saml_providers_on_group_id ON saml_providers USING btree (gro
CREATE UNIQUE INDEX index_saved_replies_on_name_text_pattern_ops ON saved_replies USING btree (user_id, name text_pattern_ops);
+CREATE INDEX index_sbom_component_versions_on_component_id ON sbom_component_versions 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);
+
+CREATE INDEX index_sbom_occurrences_on_project_id ON sbom_occurrences USING btree (project_id);
+
+CREATE INDEX index_sbom_occurrences_on_source_id ON sbom_occurrences USING btree (source_id);
+
CREATE INDEX index_scim_identities_on_group_id ON scim_identities USING btree (group_id);
CREATE UNIQUE INDEX index_scim_identities_on_lower_extern_uid_and_group_id ON scim_identities USING btree (lower((extern_uid)::text), group_id);
@@ -29363,6 +29661,10 @@ CREATE INDEX index_security_scans_on_created_at ON security_scans USING btree (c
CREATE INDEX index_security_scans_on_date_created_at_and_id ON security_scans USING btree (date(timezone('UTC'::text, created_at)), id);
+CREATE INDEX index_security_scans_on_length_of_errors ON security_scans USING btree (pipeline_id, jsonb_array_length(COALESCE((info -> 'errors'::text), '[]'::jsonb)));
+
+CREATE INDEX index_security_scans_on_length_of_warnings ON security_scans USING btree (pipeline_id, jsonb_array_length(COALESCE((info -> 'warnings'::text), '[]'::jsonb)));
+
CREATE INDEX index_security_scans_on_pipeline_id ON security_scans USING btree (pipeline_id);
CREATE INDEX index_security_scans_on_project_id ON security_scans USING btree (project_id);
@@ -29597,6 +29899,10 @@ CREATE INDEX index_u2f_registrations_on_user_id ON u2f_registrations USING btree
CREATE UNIQUE INDEX index_uniq_im_issuable_escalation_statuses_on_issue_id ON incident_management_issuable_escalation_statuses USING btree (issue_id);
+CREATE UNIQUE INDEX index_uniq_projects_on_runners_token ON projects USING btree (runners_token);
+
+CREATE UNIQUE INDEX index_uniq_projects_on_runners_token_encrypted ON projects USING btree (runners_token_encrypted);
+
CREATE UNIQUE INDEX index_unique_ci_runner_projects_on_runner_id_and_project_id ON ci_runner_projects USING btree (runner_id, project_id);
CREATE UNIQUE INDEX index_unique_issue_metrics_issue_id ON issue_metrics USING btree (issue_id);
@@ -29661,6 +29967,8 @@ CREATE INDEX index_user_highest_roles_on_user_id_and_highest_access_level ON use
CREATE INDEX index_user_interacted_projects_on_user_id ON user_interacted_projects USING btree (user_id);
+CREATE INDEX index_user_namespace_callouts_on_namespace_id ON user_namespace_callouts USING btree (namespace_id);
+
CREATE INDEX index_user_permission_export_uploads_on_user_id_and_status ON user_permission_export_uploads USING btree (user_id, status);
CREATE INDEX index_user_preferences_on_gitpod_enabled ON user_preferences USING btree (gitpod_enabled);
@@ -29741,6 +30049,8 @@ COMMENT ON INDEX index_verification_codes_on_phone_and_visitor_id_code IS 'JiHu-
CREATE UNIQUE INDEX index_vuln_historical_statistics_on_project_id_and_date ON vulnerability_historical_statistics USING btree (project_id, date);
+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_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);
@@ -29817,6 +30127,8 @@ CREATE UNIQUE INDEX index_vulnerability_identifiers_on_project_id_and_fingerprin
CREATE INDEX index_vulnerability_issue_links_on_issue_id ON vulnerability_issue_links USING btree (issue_id);
+CREATE INDEX index_vulnerability_merge_request_links_on_merge_request_id ON vulnerability_merge_request_links USING btree (merge_request_id);
+
CREATE INDEX index_vulnerability_occurrence_identifiers_on_identifier_id ON vulnerability_occurrence_identifiers USING btree (identifier_id);
CREATE UNIQUE INDEX index_vulnerability_occurrence_identifiers_on_unique_keys ON vulnerability_occurrence_identifiers USING btree (occurrence_id, identifier_id);
@@ -29905,6 +30217,8 @@ CREATE UNIQUE INDEX index_wiki_page_slugs_on_slug_and_wiki_page_meta_id ON wiki_
CREATE INDEX index_wiki_page_slugs_on_wiki_page_meta_id ON wiki_page_slugs USING btree (wiki_page_meta_id);
+CREATE UNIQUE INDEX index_work_item_parent_links_on_work_item_id ON work_item_parent_links USING btree (work_item_id);
+
CREATE INDEX index_work_item_parent_links_on_work_item_parent_id ON work_item_parent_links USING btree (work_item_parent_id);
CREATE INDEX index_x509_certificates_on_subject_key_identifier ON x509_certificates USING btree (subject_key_identifier);
@@ -29975,6 +30289,8 @@ CREATE UNIQUE INDEX partial_index_sop_configs_on_namespace_id ON security_orches
CREATE UNIQUE INDEX partial_index_sop_configs_on_project_id ON security_orchestration_policy_configurations USING btree (project_id) WHERE (project_id IS NOT NULL);
+CREATE INDEX partial_index_user_id_app_id_created_at_token_not_revoked ON oauth_access_tokens USING btree (resource_owner_id, application_id, created_at) WHERE (revoked_at IS NULL);
+
CREATE UNIQUE INDEX snippet_user_mentions_on_snippet_id_and_note_id_index ON snippet_user_mentions USING btree (snippet_id, note_id);
CREATE UNIQUE INDEX snippet_user_mentions_on_snippet_id_index ON snippet_user_mentions USING btree (snippet_id) WHERE (note_id IS NULL);
@@ -29995,8 +30311,6 @@ CREATE INDEX tmp_index_for_namespace_id_migration_on_group_members ON members US
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_namespace_id_migration_on_routes ON routes USING btree (id) WHERE ((namespace_id IS NULL) AND ((source_type)::text = 'Namespace'::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));
@@ -30007,13 +30321,13 @@ CREATE INDEX tmp_index_members_on_state ON members USING btree (state) WHERE (st
CREATE INDEX tmp_index_merge_requests_draft_and_status ON merge_requests USING btree (id) WHERE ((draft = false) AND (state_id = 1) AND ((title)::text ~* '^(\[draft\]|\(draft\)|draft:|draft|\[WIP\]|WIP:|WIP)'::text));
+CREATE INDEX tmp_index_migrated_container_registries ON container_repositories USING btree (project_id) WHERE ((migration_state = 'import_done'::text) OR (created_at >= '2022-01-23 00:00:00'::timestamp without time zone));
+
CREATE UNIQUE INDEX tmp_index_on_tmp_project_id_on_namespaces ON namespaces USING btree (tmp_project_id);
CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING btree (id) WHERE (state <> 2);
-CREATE INDEX tmp_index_projects_on_id_and_runners_token ON projects USING btree (id, runners_token) WHERE (runners_token IS NOT NULL);
-
-CREATE INDEX tmp_index_projects_on_id_and_runners_token_encrypted ON projects USING btree (id, runners_token_encrypted) WHERE (runners_token_encrypted IS NOT NULL);
+CREATE INDEX tmp_index_project_statistics_cont_registry_size ON project_statistics USING btree (project_id) WHERE (container_registry_size = 0);
CREATE UNIQUE INDEX uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name ON packages_debian_group_architectures USING btree (distribution_id, name);
@@ -30035,6 +30349,8 @@ CREATE UNIQUE INDEX unique_merge_request_metrics_by_merge_request_id ON merge_re
CREATE UNIQUE INDEX unique_projects_on_name_namespace_id ON projects USING btree (name, namespace_id);
+CREATE UNIQUE INDEX unique_vuln_merge_request_link_vuln_id_and_mr_id ON vulnerability_merge_request_links USING btree (vulnerability_id, merge_request_id);
+
CREATE INDEX user_follow_users_followee_id_idx ON user_follow_users USING btree (followee_id);
CREATE INDEX users_forbidden_state_idx ON users USING btree (id) WHERE ((confirmed_at IS NOT NULL) AND ((state)::text <> ALL (ARRAY['blocked'::text, 'banned'::text, 'ldap_blocked'::text])));
@@ -31361,6 +31677,8 @@ CREATE TRIGGER trigger_has_external_wiki_on_update AFTER UPDATE ON integrations
CREATE TRIGGER trigger_insert_or_update_vulnerability_reads_from_occurrences AFTER INSERT OR UPDATE ON vulnerability_occurrences FOR EACH ROW EXECUTE FUNCTION insert_or_update_vulnerability_reads();
+CREATE TRIGGER trigger_insert_vulnerability_reads_from_vulnerability AFTER UPDATE ON vulnerabilities FOR EACH ROW WHEN (((old.present_on_default_branch IS NOT TRUE) AND (new.present_on_default_branch IS TRUE))) EXECUTE FUNCTION insert_vulnerability_reads_from_vulnerability();
+
CREATE TRIGGER trigger_namespaces_parent_id_on_insert AFTER INSERT ON namespaces FOR EACH ROW EXECUTE FUNCTION insert_namespaces_sync_event();
CREATE TRIGGER trigger_namespaces_parent_id_on_update AFTER UPDATE ON namespaces FOR EACH ROW WHEN ((old.parent_id IS DISTINCT FROM new.parent_id)) EXECUTE FUNCTION insert_namespaces_sync_event();
@@ -31375,7 +31693,7 @@ CREATE TRIGGER trigger_update_has_issues_on_vulnerability_issue_links_update AFT
CREATE TRIGGER trigger_update_location_on_vulnerability_occurrences_update AFTER UPDATE ON vulnerability_occurrences FOR EACH ROW WHEN (((new.report_type = ANY (ARRAY[2, 7])) AND (((old.location ->> 'image'::text) IS DISTINCT FROM (new.location ->> 'image'::text)) OR (((old.location -> 'kubernetes_resource'::text) ->> 'agent_id'::text) IS DISTINCT FROM ((new.location -> 'kubernetes_resource'::text) ->> 'agent_id'::text))))) EXECUTE FUNCTION update_location_from_vulnerability_occurrences();
-CREATE TRIGGER trigger_update_vulnerability_reads_on_vulnerability_update AFTER UPDATE ON vulnerabilities FOR EACH ROW WHEN (((old.severity IS DISTINCT FROM new.severity) OR (old.state IS DISTINCT FROM new.state) OR (old.resolved_on_default_branch IS DISTINCT FROM new.resolved_on_default_branch))) EXECUTE FUNCTION update_vulnerability_reads_from_vulnerability();
+CREATE TRIGGER trigger_update_vulnerability_reads_on_vulnerability_update AFTER UPDATE ON vulnerabilities FOR EACH ROW WHEN (((old.present_on_default_branch IS TRUE) AND ((old.severity IS DISTINCT FROM new.severity) OR (old.state IS DISTINCT FROM new.state) OR (old.resolved_on_default_branch IS DISTINCT FROM new.resolved_on_default_branch)))) EXECUTE FUNCTION update_vulnerability_reads_from_vulnerability();
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();
@@ -31445,6 +31763,9 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY webauthn_registrations
ADD CONSTRAINT fk_13e04d719a FOREIGN KEY (u2f_registration_id) REFERENCES u2f_registrations(id) ON DELETE CASCADE;
+ALTER TABLE ONLY sbom_occurrences
+ ADD CONSTRAINT fk_157506c0e2 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY protected_branch_push_access_levels
ADD CONSTRAINT fk_15d2a7a4ae FOREIGN KEY (deploy_key_id) REFERENCES keys(id) ON DELETE CASCADE;
@@ -31517,6 +31838,9 @@ ALTER TABLE ONLY ci_pipelines
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_27548c6db3 FOREIGN KEY (hashed_storage_migrated_event_id) REFERENCES geo_hashed_storage_migrated_events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY user_namespace_callouts
+ ADD CONSTRAINT fk_27a69fd1bd FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY merge_requests_compliance_violations
ADD CONSTRAINT fk_290ec1ab02 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
@@ -31538,6 +31862,9 @@ ALTER TABLE ONLY members
ALTER TABLE ONLY lfs_objects_projects
ADD CONSTRAINT fk_2eb33f7a78 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE NOT VALID;
+ALTER TABLE ONLY vulnerability_merge_request_links
+ ADD CONSTRAINT fk_2ef3954596 FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY analytics_cycle_analytics_group_stages
ADD CONSTRAINT fk_3078345d6d FOREIGN KEY (stage_event_hash_id) REFERENCES analytics_cycle_analytics_stage_event_hashes(id) ON DELETE CASCADE;
@@ -31598,6 +31925,9 @@ ALTER TABLE ONLY protected_environment_approval_rules
ALTER TABLE ONLY ci_pipeline_schedule_variables
ADD CONSTRAINT fk_41c35fda51 FOREIGN KEY (pipeline_schedule_id) REFERENCES ci_pipeline_schedules(id) ON DELETE CASCADE;
+ALTER TABLE ONLY namespace_bans
+ ADD CONSTRAINT fk_4275fbb1d7 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_42c3b54bed FOREIGN KEY (cache_invalidation_event_id) REFERENCES geo_cache_invalidation_events(id) ON DELETE CASCADE;
@@ -31616,6 +31946,12 @@ ALTER TABLE ONLY releases
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_4a99ebfd60 FOREIGN KEY (repositories_changed_event_id) REFERENCES geo_repositories_changed_events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY user_namespace_callouts
+ ADD CONSTRAINT fk_4b1257f385 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
+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_5001652292 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -31694,6 +32030,12 @@ ALTER TABLE ONLY projects
ALTER TABLE ONLY dast_profile_schedules
ADD CONSTRAINT fk_6cca0d8800 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY vulnerability_merge_request_links
+ ADD CONSTRAINT fk_6d7aa8796e FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY issues
+ ADD CONSTRAINT fk_6e10d4d38a FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY projects
ADD CONSTRAINT fk_6e5c14658a FOREIGN KEY (pool_repository_id) REFERENCES pool_repositories(id) ON DELETE SET NULL;
@@ -31928,6 +32270,9 @@ ALTER TABLE ONLY merge_requests
ALTER TABLE ONLY merge_request_metrics
ADD CONSTRAINT fk_ae440388cc FOREIGN KEY (latest_closed_by_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY vulnerability_reads
+ ADD CONSTRAINT fk_aee839e611 FOREIGN KEY (casted_cluster_agent_id) REFERENCES cluster_agents(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY dast_profile_schedules
ADD CONSTRAINT fk_aef03d62e5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -31982,6 +32327,9 @@ ALTER TABLE ONLY deployments
ALTER TABLE ONLY routes
ADD CONSTRAINT fk_bb2e5b8968 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY namespace_bans
+ ADD CONSTRAINT fk_bcc024eef2 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY gitlab_subscriptions
ADD CONSTRAINT fk_bd0c4019c3 FOREIGN KEY (hosted_plan_id) REFERENCES plans(id) ON DELETE CASCADE;
@@ -32006,6 +32354,9 @@ ALTER TABLE ONLY design_management_versions
ALTER TABLE ONLY packages_packages
ADD CONSTRAINT fk_c188f0dba4 FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY sbom_occurrences
+ ADD CONSTRAINT fk_c2a5562923 FOREIGN KEY (source_id) REFERENCES sbom_sources(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY analytics_cycle_analytics_project_stages
ADD CONSTRAINT fk_c3339bdfc9 FOREIGN KEY (stage_event_hash_id) REFERENCES analytics_cycle_analytics_stage_event_hashes(id) ON DELETE CASCADE;
@@ -32261,9 +32612,6 @@ ALTER TABLE ONLY approval_merge_request_rules
ALTER TABLE ONLY namespace_statistics
ADD CONSTRAINT fk_rails_0062050394 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
-ALTER TABLE ONLY clusters_applications_elastic_stacks
- ADD CONSTRAINT fk_rails_026f219f46 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY incident_management_oncall_participants
ADD CONSTRAINT fk_rails_032b12996a FOREIGN KEY (oncall_rotation_id) REFERENCES incident_management_oncall_rotations(id) ON DELETE CASCADE;
@@ -32804,6 +33152,9 @@ ALTER TABLE ONLY badges
ALTER TABLE ONLY resource_label_events
ADD CONSTRAINT fk_rails_5ac1d2fc24 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ci_secure_file_states
+ ADD CONSTRAINT fk_rails_5adba40c5f FOREIGN KEY (ci_secure_file_id) REFERENCES ci_secure_files(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY approval_merge_request_rules_groups
ADD CONSTRAINT fk_rails_5b2ecf6139 FOREIGN KEY (approval_merge_request_rule_id) REFERENCES approval_merge_request_rules(id) ON DELETE CASCADE;
@@ -32858,6 +33209,9 @@ ALTER TABLE ONLY dependency_proxy_group_settings
ALTER TABLE ONLY group_deploy_tokens
ADD CONSTRAINT fk_rails_61a572b41a FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY sbom_component_versions
+ ADD CONSTRAINT fk_rails_61a83aa892 FOREIGN KEY (component_id) REFERENCES sbom_components(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY status_page_published_incidents
ADD CONSTRAINT fk_rails_61e5493940 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -32900,6 +33254,9 @@ ALTER TABLE ONLY design_management_versions
ALTER TABLE ONLY approval_merge_request_rules_approved_approvers
ADD CONSTRAINT fk_rails_6577725edb FOREIGN KEY (approval_merge_request_rule_id) REFERENCES approval_merge_request_rules(id) ON DELETE CASCADE;
+ALTER TABLE ONLY project_relation_export_uploads
+ ADD CONSTRAINT fk_rails_660ada90c9 FOREIGN KEY (project_relation_export_id) REFERENCES project_relation_exports(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY operations_feature_flags_clients
ADD CONSTRAINT fk_rails_6650ed902c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -33515,9 +33872,6 @@ 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 clusters_integration_elasticstack
- ADD CONSTRAINT fk_rails_cc5ba8f658 FOREIGN KEY (cluster_id) REFERENCES clusters(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;
@@ -33710,6 +34064,9 @@ ALTER TABLE ONLY ci_daily_build_group_report_results
ALTER TABLE ONLY packages_debian_group_architectures
ADD CONSTRAINT fk_rails_ef667d1b03 FOREIGN KEY (distribution_id) REFERENCES packages_debian_group_distributions(id) ON DELETE CASCADE;
+ALTER TABLE ONLY project_relation_exports
+ ADD CONSTRAINT fk_rails_ef89b354fc FOREIGN KEY (project_export_job_id) REFERENCES project_export_jobs(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY label_priorities
ADD CONSTRAINT fk_rails_ef916d14fa FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -33806,9 +34163,6 @@ ALTER TABLE ONLY experiment_users
ALTER TABLE ONLY cluster_groups
ADD CONSTRAINT fk_rails_fdb8648a96 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
-ALTER TABLE ONLY project_tracing_settings
- ADD CONSTRAINT fk_rails_fe56f57fc6 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY resource_label_events
ADD CONSTRAINT fk_rails_fe91ece594 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;