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>2021-12-20 16:37:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 16:37:47 +0300
commitaee0a117a889461ce8ced6fcf73207fe017f1d99 (patch)
tree891d9ef189227a8445d83f35c1b0fc99573f4380 /db
parent8d46af3258650d305f53b819eabf7ab18d22f59e (diff)
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/02_users.rb5
-rw-r--r--db/fixtures/development/32_crm.rb47
-rw-r--r--db/migrate/20211008043855_remove_notes_trigram_index.rb15
-rw-r--r--db/migrate/20211011140930_create_ci_namespace_mirrors.rb15
-rw-r--r--db/migrate/20211011140931_create_ci_project_mirrors.rb12
-rw-r--r--db/migrate/20211011140932_create_namespaces_sync_events.rb9
-rw-r--r--db/migrate/20211011141239_create_projects_sync_events.rb9
-rw-r--r--db/migrate/20211011141242_create_namespaces_sync_trigger.rb37
-rw-r--r--db/migrate/20211011141243_create_projects_sync_trigger.rb37
-rw-r--r--db/migrate/20211101165656_create_upload_states.rb32
-rw-r--r--db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb9
-rw-r--r--db/migrate/20211110014701_create_agent_activity_events.rb22
-rw-r--r--db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb35
-rw-r--r--db/migrate/20211110092710_create_issue_emails.rb21
-rw-r--r--db/migrate/20211111112425_create_merge_requests_compliance_violations.rb13
-rw-r--r--db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb18
-rw-r--r--db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb18
-rw-r--r--db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb9
-rw-r--r--db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb13
-rw-r--r--db/migrate/20211112073413_change_package_index_on_corpus.rb19
-rw-r--r--db/migrate/20211115132613_create_incident_management_timeline_events.rb30
-rw-r--r--db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb15
-rw-r--r--db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb15
-rw-r--r--db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb15
-rw-r--r--db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb17
-rw-r--r--db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb17
-rw-r--r--db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb15
-rw-r--r--db/migrate/20211117174209_create_vulnerability_reads.rb24
-rw-r--r--db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb9
-rw-r--r--db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb40
-rw-r--r--db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb7
-rw-r--r--db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb15
-rw-r--r--db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb15
-rw-r--r--db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb15
-rw-r--r--db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb16
-rw-r--r--db/migrate/20211119154221_create_pages_deployment_states.rb38
-rw-r--r--db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb16
-rw-r--r--db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb7
-rw-r--r--db/migrate/20211119195201_create_deployment_approvals.rb13
-rw-r--r--db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb9
-rw-r--r--db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb15
-rw-r--r--db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb7
-rw-r--r--db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb14
-rw-r--r--db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb14
-rw-r--r--db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb12
-rw-r--r--db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb29
-rw-r--r--db/migrate/20211126142200_add_encrypted_static_object_token.rb16
-rw-r--r--db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb13
-rw-r--r--db/migrate/20211126204445_add_task_to_work_item_types.rb31
-rw-r--r--db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb7
-rw-r--r--db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb15
-rw-r--r--db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb15
-rw-r--r--db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb18
-rw-r--r--db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb7
-rw-r--r--db/migrate/20211201143042_create_lfs_object_states.rb32
-rw-r--r--db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb15
-rw-r--r--db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb17
-rw-r--r--db/migrate/20211202135508_add_index_on_packages_build_infos_package_id_pipeline_id.rb18
-rw-r--r--db/migrate/20211204010826_add_index_snippets_on_project_id_and_title.rb15
-rw-r--r--db/migrate/20211207154413_add_ci_runners_index_on_created_at_where_active_is_false.rb15
-rw-r--r--db/migrate/20211207154414_add_ci_runners_index_on_contacted_at_where_active_is_false.rb15
-rw-r--r--db/migrate/20211207165508_add_protected_environments_required_approval_count_check_constraint.rb15
-rw-r--r--db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb7
-rw-r--r--db/migrate/20211213130324_update_timelogs_spent_at_default.rb7
-rw-r--r--db/migrate/20211214110307_remove_temp_index_from_vulnerability_occurrences.rb15
-rw-r--r--db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb59
-rw-r--r--db/post_migrate/20211022214523_schedule_recalculate_vulnerability_finding_signatures_for_findings.rb25
-rw-r--r--db/post_migrate/20211023102243_schedule_delete_invalid_epic_issues.rb14
-rw-r--r--db/post_migrate/20211027043206_track_ci_pipeline_deletions.rb15
-rw-r--r--db/post_migrate/20211027043229_track_ci_build_deletions.rb15
-rw-r--r--db/post_migrate/20211101222614_consume_remaining_user_namespace_jobs.rb26
-rw-r--r--db/post_migrate/20211103141403_remove_propagate_service_template_worker.rb11
-rw-r--r--db/post_migrate/20211104165220_remove_vulnerability_finding_links.rb21
-rw-r--r--db/post_migrate/20211110143306_add_not_null_constraint_to_security_findings_uuid.rb20
-rw-r--r--db/post_migrate/20211110151320_add_temporary_index_on_security_findings_uuid.rb23
-rw-r--r--db/post_migrate/20211110151350_schedule_drop_invalid_security_findings.rb25
-rw-r--r--db/post_migrate/20211116091751_change_namespace_type_default_to_user.rb17
-rw-r--r--db/post_migrate/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings.rb23
-rw-r--r--db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb26
-rw-r--r--db/post_migrate/20211118130836_drop_pages_deployments_builds_fk.rb22
-rw-r--r--db/post_migrate/20211118194239_drop_invalid_remediations.rb25
-rw-r--r--db/post_migrate/20211119085036_add_text_limit_to_job_artifact_original_filename.rb13
-rw-r--r--db/post_migrate/20211122033501_improve_index_on_events_for_calendar.rb13
-rw-r--r--db/post_migrate/20211122193948_cleanup_background_migration_of_requirements_to_work_items.rb17
-rw-r--r--db/post_migrate/20211124132705_change_index_users_on_public_email.rb22
-rw-r--r--db/post_migrate/20211125120444_add_index_todos_project_id_user_id.rb15
-rw-r--r--db/post_migrate/20211130165043_backfill_sequence_column_for_sprints_table.rb24
-rw-r--r--db/post_migrate/20211130201100_track_deletions_in_namespaces.rb15
-rw-r--r--db/post_migrate/20211130201101_track_deletions_in_projects.rb15
-rw-r--r--db/post_migrate/20211201101541_drop_clusters_applications_runners_ci_runners_fk.rb15
-rw-r--r--db/post_migrate/20211202145237_add_todos_project_and_id_index.rb32
-rw-r--r--db/post_migrate/20211203091642_add_index_to_projects_on_marked_for_deletion_at.rb15
-rw-r--r--db/post_migrate/20211206073851_create_calendar_events_index_synchronously.rb15
-rw-r--r--db/post_migrate/20211206074547_remove_old_calendar_events_index.rb18
-rw-r--r--db/post_migrate/20211207090503_cleanup_first_mentioned_in_commit_jobs.rb22
-rw-r--r--db/post_migrate/20211208171402_reschedule_recalculate_vulnerability_finding_signatures_for_findings.rb27
-rw-r--r--db/post_migrate/20211209093636_track_ci_job_artifacts_deletes.rb15
-rw-r--r--db/post_migrate/20211209093828_track_users_deletes.rb15
-rw-r--r--db/post_migrate/20211209093923_track_external_pull_requests_deletes.rb15
-rw-r--r--db/post_migrate/20211209094222_track_merge_requests_deletes.rb15
-rw-r--r--db/post_migrate/20211210173137_remove_vulnerability_finding_links_again.rb21
-rw-r--r--db/post_migrate/20211213064821_add_agent_id_location_index_to_vulnerability_occurrences.rb18
-rw-r--r--db/post_migrate/20211213102111_drop_ci_pipelines_mr_metrics_fk.rb15
-rw-r--r--db/post_migrate/20211215090620_schedule_update_timelogs_null_spent_at.rb23
-rw-r--r--db/schema_migrations/202107130420001
-rw-r--r--db/schema_migrations/202110080438551
-rw-r--r--db/schema_migrations/202110111409301
-rw-r--r--db/schema_migrations/202110111409311
-rw-r--r--db/schema_migrations/202110111409321
-rw-r--r--db/schema_migrations/202110111412391
-rw-r--r--db/schema_migrations/202110111412421
-rw-r--r--db/schema_migrations/202110111412431
-rw-r--r--db/schema_migrations/202110222145231
-rw-r--r--db/schema_migrations/202110231022431
-rw-r--r--db/schema_migrations/202110270432061
-rw-r--r--db/schema_migrations/202110270432291
-rw-r--r--db/schema_migrations/202111011656561
-rw-r--r--db/schema_migrations/202111012226141
-rw-r--r--db/schema_migrations/202111031414031
-rw-r--r--db/schema_migrations/202111041652201
-rw-r--r--db/schema_migrations/202111082047361
-rw-r--r--db/schema_migrations/202111100147011
-rw-r--r--db/schema_migrations/202111100152521
-rw-r--r--db/schema_migrations/202111100927101
-rw-r--r--db/schema_migrations/202111101433061
-rw-r--r--db/schema_migrations/202111101513201
-rw-r--r--db/schema_migrations/202111101513501
-rw-r--r--db/schema_migrations/202111111124251
-rw-r--r--db/schema_migrations/202111111126391
-rw-r--r--db/schema_migrations/202111111127131
-rw-r--r--db/schema_migrations/202111111640251
-rw-r--r--db/schema_migrations/202111111640471
-rw-r--r--db/schema_migrations/202111120734131
-rw-r--r--db/schema_migrations/202111151326131
-rw-r--r--db/schema_migrations/202111151428031
-rw-r--r--db/schema_migrations/202111151428471
-rw-r--r--db/schema_migrations/202111151429111
-rw-r--r--db/schema_migrations/202111151451071
-rw-r--r--db/schema_migrations/202111151541031
-rw-r--r--db/schema_migrations/202111160917511
-rw-r--r--db/schema_migrations/202111160937391
-rw-r--r--db/schema_migrations/202111161116441
-rw-r--r--db/schema_migrations/202111170848141
-rw-r--r--db/schema_migrations/202111171742091
-rw-r--r--db/schema_migrations/202111181009591
-rw-r--r--db/schema_migrations/202111181034391
-rw-r--r--db/schema_migrations/202111181142281
-rw-r--r--db/schema_migrations/202111181245371
-rw-r--r--db/schema_migrations/202111181246281
-rw-r--r--db/schema_migrations/202111181246501
-rw-r--r--db/schema_migrations/202111181308361
-rw-r--r--db/schema_migrations/202111181942391
-rw-r--r--db/schema_migrations/202111190850151
-rw-r--r--db/schema_migrations/202111190850361
-rw-r--r--db/schema_migrations/202111191542211
-rw-r--r--db/schema_migrations/202111191708051
-rw-r--r--db/schema_migrations/202111191940241
-rw-r--r--db/schema_migrations/202111191952011
-rw-r--r--db/schema_migrations/202111220335011
-rw-r--r--db/schema_migrations/202111221939481
-rw-r--r--db/schema_migrations/202111222150011
-rw-r--r--db/schema_migrations/202111231812361
-rw-r--r--db/schema_migrations/202111231826141
-rw-r--r--db/schema_migrations/202111241323191
-rw-r--r--db/schema_migrations/202111241327051
-rw-r--r--db/schema_migrations/202111251204441
-rw-r--r--db/schema_migrations/202111260422351
-rw-r--r--db/schema_migrations/202111261130291
-rw-r--r--db/schema_migrations/202111261154491
-rw-r--r--db/schema_migrations/202111261422001
-rw-r--r--db/schema_migrations/202111261423541
-rw-r--r--db/schema_migrations/202111262044451
-rw-r--r--db/schema_migrations/202111291511551
-rw-r--r--db/schema_migrations/202111291518321
-rw-r--r--db/schema_migrations/202111301517241
-rw-r--r--db/schema_migrations/202111301650431
-rw-r--r--db/schema_migrations/202111302011001
-rw-r--r--db/schema_migrations/202111302011011
-rw-r--r--db/schema_migrations/202111302057191
-rw-r--r--db/schema_migrations/202112010617331
-rw-r--r--db/schema_migrations/202112011015411
-rw-r--r--db/schema_migrations/202112011430421
-rw-r--r--db/schema_migrations/202112020412331
-rw-r--r--db/schema_migrations/202112020949441
-rw-r--r--db/schema_migrations/202112021355081
-rw-r--r--db/schema_migrations/202112021452371
-rw-r--r--db/schema_migrations/202112030916421
-rw-r--r--db/schema_migrations/202112040108261
-rw-r--r--db/schema_migrations/202112060738511
-rw-r--r--db/schema_migrations/202112060745471
-rw-r--r--db/schema_migrations/202112070905031
-rw-r--r--db/schema_migrations/202112071544131
-rw-r--r--db/schema_migrations/202112071544141
-rw-r--r--db/schema_migrations/202112071655081
-rw-r--r--db/schema_migrations/202112081114251
-rw-r--r--db/schema_migrations/202112081714021
-rw-r--r--db/schema_migrations/202112090936361
-rw-r--r--db/schema_migrations/202112090938281
-rw-r--r--db/schema_migrations/202112090939231
-rw-r--r--db/schema_migrations/202112090942221
-rw-r--r--db/schema_migrations/202112101731371
-rw-r--r--db/schema_migrations/202112130648211
-rw-r--r--db/schema_migrations/202112131021111
-rw-r--r--db/schema_migrations/202112131303241
-rw-r--r--db/schema_migrations/202112141103071
-rw-r--r--db/schema_migrations/202112150906201
-rw-r--r--db/structure.sql681
207 files changed, 2607 insertions, 85 deletions
diff --git a/db/fixtures/development/02_users.rb b/db/fixtures/development/02_users.rb
index 7916cdd5fb1..76a00c18649 100644
--- a/db/fixtures/development/02_users.rb
+++ b/db/fixtures/development/02_users.rb
@@ -41,11 +41,12 @@ class Gitlab::Seeder::Users
relation = User.where(admin: false)
Gitlab::Seeder.with_mass_insert(relation.count, Namespace) do
ActiveRecord::Base.connection.execute <<~SQL
- INSERT INTO namespaces (name, path, owner_id)
+ INSERT INTO namespaces (name, path, owner_id, type)
SELECT
username,
username,
- id
+ id,
+ 'User'
FROM users WHERE NOT admin
SQL
end
diff --git a/db/fixtures/development/32_crm.rb b/db/fixtures/development/32_crm.rb
new file mode 100644
index 00000000000..bad2fc56ed3
--- /dev/null
+++ b/db/fixtures/development/32_crm.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+class Gitlab::Seeder::Crm
+ attr_reader :group, :organizations_per_group, :contacts_per_group
+
+ def initialize(group, organizations_per_group: 10, contacts_per_group: 40)
+ @group = group
+ @organizations_per_group = organizations_per_group
+ @contacts_per_group = contacts_per_group
+ end
+
+ def seed!
+ organization_ids = []
+
+ organizations_per_group.times do |index|
+ organization_ids << ::CustomerRelations::Organization.create!(
+ group_id: group.id,
+ name: "#{FFaker::Company.name}-#{index}"
+ ).id
+
+ print '.'
+ end
+
+ contacts_per_group.times do |index|
+ first_name = FFaker::Name.first_name
+ last_name = FFaker::Name.last_name
+ organization_id = index % 3 == 0 ? organization_ids.sample : nil
+ ::CustomerRelations::Contact.create!(
+ group_id: group.id,
+ first_name: first_name,
+ last_name: last_name,
+ email: "#{first_name}.#{last_name}@example.org",
+ organization_id: organization_id
+ )
+
+ print '.'
+ end
+ end
+end
+
+Gitlab::Seeder.quiet do
+ puts "\nGenerating group crm organizations and contacts"
+
+ Group.all.find_each do |group|
+ Gitlab::Seeder::Crm.new(group).seed!
+ end
+end
diff --git a/db/migrate/20211008043855_remove_notes_trigram_index.rb b/db/migrate/20211008043855_remove_notes_trigram_index.rb
new file mode 100644
index 00000000000..a20ef1852e2
--- /dev/null
+++ b/db/migrate/20211008043855_remove_notes_trigram_index.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveNotesTrigramIndex < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ NOTES_TRIGRAM_INDEX_NAME = 'index_notes_on_note_trigram'
+
+ def up
+ remove_concurrent_index_by_name(:notes, NOTES_TRIGRAM_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :notes, :note, name: NOTES_TRIGRAM_INDEX_NAME, using: :gin, opclass: { content: :gin_trgm_ops }
+ end
+end
diff --git a/db/migrate/20211011140930_create_ci_namespace_mirrors.rb b/db/migrate/20211011140930_create_ci_namespace_mirrors.rb
new file mode 100644
index 00000000000..b9a708c5d7b
--- /dev/null
+++ b/db/migrate/20211011140930_create_ci_namespace_mirrors.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateCiNamespaceMirrors < Gitlab::Database::Migration[1.0]
+ TABLE_NAME = :ci_namespace_mirrors
+ INDEX_NAME = "index_gin_#{TABLE_NAME}_on_traversal_ids"
+
+ def change
+ create_table TABLE_NAME do |t|
+ t.integer :namespace_id, null: false, index: { unique: true }
+ t.integer :traversal_ids, array: true, default: [], null: false
+
+ t.index :traversal_ids, name: INDEX_NAME, using: :gin
+ end
+ end
+end
diff --git a/db/migrate/20211011140931_create_ci_project_mirrors.rb b/db/migrate/20211011140931_create_ci_project_mirrors.rb
new file mode 100644
index 00000000000..2407b7e0b84
--- /dev/null
+++ b/db/migrate/20211011140931_create_ci_project_mirrors.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateCiProjectMirrors < Gitlab::Database::Migration[1.0]
+ TABLE_NAME = :ci_project_mirrors
+
+ def change
+ create_table TABLE_NAME do |t|
+ t.integer :project_id, null: false, index: { unique: true }
+ t.integer :namespace_id, null: false, index: true
+ end
+ end
+end
diff --git a/db/migrate/20211011140932_create_namespaces_sync_events.rb b/db/migrate/20211011140932_create_namespaces_sync_events.rb
new file mode 100644
index 00000000000..06831423343
--- /dev/null
+++ b/db/migrate/20211011140932_create_namespaces_sync_events.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class CreateNamespacesSyncEvents < Gitlab::Database::Migration[1.0]
+ def change
+ create_table :namespaces_sync_events do |t|
+ t.references :namespace, null: false, index: true, foreign_key: { on_delete: :cascade }
+ end
+ end
+end
diff --git a/db/migrate/20211011141239_create_projects_sync_events.rb b/db/migrate/20211011141239_create_projects_sync_events.rb
new file mode 100644
index 00000000000..50fe988ac1b
--- /dev/null
+++ b/db/migrate/20211011141239_create_projects_sync_events.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class CreateProjectsSyncEvents < Gitlab::Database::Migration[1.0]
+ def change
+ create_table :projects_sync_events do |t|
+ t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }
+ end
+ end
+end
diff --git a/db/migrate/20211011141242_create_namespaces_sync_trigger.rb b/db/migrate/20211011141242_create_namespaces_sync_trigger.rb
new file mode 100644
index 00000000000..91f64709f28
--- /dev/null
+++ b/db/migrate/20211011141242_create_namespaces_sync_trigger.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class CreateNamespacesSyncTrigger < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::SchemaHelpers
+
+ enable_lock_retries!
+
+ TABLE_NAME = 'namespaces'
+ EVENT_TABLE_NAME = 'namespaces_sync_events'
+ FUNCTION_NAME = 'insert_namespaces_sync_event'
+ TRIGGER_ON_INSERT = 'trigger_namespaces_parent_id_on_insert'
+ TRIGGER_ON_UPDATE = 'trigger_namespaces_parent_id_on_update'
+
+ def up
+ create_trigger_function(FUNCTION_NAME) do
+ <<~SQL
+ INSERT INTO #{EVENT_TABLE_NAME} (namespace_id)
+ VALUES(COALESCE(NEW.id, OLD.id));
+ RETURN NULL;
+ SQL
+ end
+
+ create_trigger(TABLE_NAME, TRIGGER_ON_INSERT, FUNCTION_NAME, fires: 'AFTER INSERT')
+
+ create_trigger(TABLE_NAME, TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do
+ <<~SQL
+ WHEN (OLD.parent_id IS DISTINCT FROM NEW.parent_id)
+ SQL
+ end
+ end
+
+ def down
+ drop_trigger(TABLE_NAME, TRIGGER_ON_INSERT)
+ drop_trigger(TABLE_NAME, TRIGGER_ON_UPDATE)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/migrate/20211011141243_create_projects_sync_trigger.rb b/db/migrate/20211011141243_create_projects_sync_trigger.rb
new file mode 100644
index 00000000000..03b31c35a3a
--- /dev/null
+++ b/db/migrate/20211011141243_create_projects_sync_trigger.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class CreateProjectsSyncTrigger < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::SchemaHelpers
+
+ enable_lock_retries!
+
+ TABLE_NAME = 'projects'
+ EVENT_TABLE_NAME = 'projects_sync_events'
+ FUNCTION_NAME = 'insert_projects_sync_event'
+ TRIGGER_ON_INSERT = 'trigger_projects_parent_id_on_insert'
+ TRIGGER_ON_UPDATE = 'trigger_projects_parent_id_on_update'
+
+ def up
+ create_trigger_function(FUNCTION_NAME) do
+ <<~SQL
+ INSERT INTO #{EVENT_TABLE_NAME} (project_id)
+ VALUES(COALESCE(NEW.id, OLD.id));
+ RETURN NULL;
+ SQL
+ end
+
+ create_trigger(TABLE_NAME, TRIGGER_ON_INSERT, FUNCTION_NAME, fires: 'AFTER INSERT')
+
+ create_trigger(TABLE_NAME, TRIGGER_ON_UPDATE, FUNCTION_NAME, fires: 'AFTER UPDATE') do
+ <<~SQL
+ WHEN (OLD.namespace_id IS DISTINCT FROM NEW.namespace_id)
+ SQL
+ end
+ end
+
+ def down
+ drop_trigger(TABLE_NAME, TRIGGER_ON_INSERT)
+ drop_trigger(TABLE_NAME, TRIGGER_ON_UPDATE)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/migrate/20211101165656_create_upload_states.rb b/db/migrate/20211101165656_create_upload_states.rb
new file mode 100644
index 00000000000..64873f4c9a2
--- /dev/null
+++ b/db/migrate/20211101165656_create_upload_states.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class CreateUploadStates < Gitlab::Database::Migration[1.0]
+ VERIFICATION_STATE_INDEX_NAME = "index_upload_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_upload_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_upload_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_upload_states_needs_verification"
+
+ disable_ddl_transaction!
+
+ def up
+ create_table :upload_states, id: false do |t|
+ t.datetime_with_timezone :verification_started_at
+ t.datetime_with_timezone :verification_retry_at
+ t.datetime_with_timezone :verified_at
+ t.references :upload, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :verification_state, default: 0, limit: 2, null: false
+ t.integer :verification_retry_count, limit: 2
+ t.binary :verification_checksum, using: 'verification_checksum::bytea'
+ t.text :verification_failure, limit: 255
+
+ t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
+ t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
+ t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
+ t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
+ end
+ end
+
+ def down
+ drop_table :upload_states
+ end
+end
diff --git a/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb b/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb
new file mode 100644
index 00000000000..90e5fa34817
--- /dev/null
+++ b/db/migrate/20211108204736_add_policy_idx_to_approval_project_rule.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPolicyIdxToApprovalProjectRule < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def change
+ add_column :approval_project_rules, :orchestration_policy_idx, :integer, limit: 2
+ end
+end
diff --git a/db/migrate/20211110014701_create_agent_activity_events.rb b/db/migrate/20211110014701_create_agent_activity_events.rb
new file mode 100644
index 00000000000..11b9c6d03b3
--- /dev/null
+++ b/db/migrate/20211110014701_create_agent_activity_events.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateAgentActivityEvents < Gitlab::Database::Migration[1.0]
+ def change
+ create_table :agent_activity_events do |t|
+ t.bigint :agent_id, null: false
+ t.bigint :user_id, index: { where: 'user_id IS NOT NULL' }
+ t.bigint :project_id, index: { where: 'project_id IS NOT NULL' }
+ t.bigint :merge_request_id, index: { where: 'merge_request_id IS NOT NULL' }
+ t.bigint :agent_token_id, index: { where: 'agent_token_id IS NOT NULL' }
+
+ t.datetime_with_timezone :recorded_at, null: false
+ t.integer :kind, limit: 2, null: false
+ t.integer :level, limit: 2, null: false
+
+ t.binary :sha
+ t.text :detail, limit: 255
+
+ t.index [:agent_id, :recorded_at, :id]
+ end
+ end
+end
diff --git a/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb b/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb
new file mode 100644
index 00000000000..fcbafcccb06
--- /dev/null
+++ b/db/migrate/20211110015252_add_agent_activity_events_foreign_keys.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class AddAgentActivityEventsForeignKeys < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :agent_activity_events, :cluster_agents, column: :agent_id, on_delete: :cascade
+ add_concurrent_foreign_key :agent_activity_events, :users, column: :user_id, on_delete: :nullify
+ add_concurrent_foreign_key :agent_activity_events, :projects, column: :project_id, on_delete: :nullify
+ add_concurrent_foreign_key :agent_activity_events, :merge_requests, column: :merge_request_id, on_delete: :nullify
+ add_concurrent_foreign_key :agent_activity_events, :cluster_agent_tokens, column: :agent_token_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_activity_events, column: :agent_id
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_activity_events, column: :user_id
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_activity_events, column: :project_id
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_activity_events, column: :merge_request_id
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists :agent_activity_events, column: :agent_token_id
+ end
+ end
+end
diff --git a/db/migrate/20211110092710_create_issue_emails.rb b/db/migrate/20211110092710_create_issue_emails.rb
new file mode 100644
index 00000000000..5f6104fa2c3
--- /dev/null
+++ b/db/migrate/20211110092710_create_issue_emails.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 CreateIssueEmails < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def up
+ create_table :issue_emails do |t|
+ t.references :issue, index: true, null: false, unique: true, foreign_key: { on_delete: :cascade }
+ t.text :email_message_id, null: false, limit: 1000
+
+ t.index :email_message_id
+ end
+ end
+
+ def down
+ drop_table :issue_emails
+ end
+end
diff --git a/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb b/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb
new file mode 100644
index 00000000000..064dc38f5b3
--- /dev/null
+++ b/db/migrate/20211111112425_create_merge_requests_compliance_violations.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CreateMergeRequestsComplianceViolations < Gitlab::Database::Migration[1.0]
+ def change
+ create_table :merge_requests_compliance_violations do |t|
+ t.bigint :violating_user_id, null: false
+ t.bigint :merge_request_id, null: false
+ t.integer :reason, limit: 2, null: false
+ t.index :violating_user_id
+ t.index [:merge_request_id, :violating_user_id, :reason], unique: true, name: 'index_merge_requests_compliance_violations_unique_columns'
+ end
+ end
+end
diff --git a/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb b/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb
new file mode 100644
index 00000000000..b280c35433b
--- /dev/null
+++ b/db/migrate/20211111112639_add_fk_compliance_violations_merge_request.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddFkComplianceViolationsMergeRequest < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_requests_compliance_violations,
+ :merge_requests,
+ column: :merge_request_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :merge_requests_compliance_violations, column: :merge_request_id
+ end
+ end
+end
diff --git a/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb b/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb
new file mode 100644
index 00000000000..af1cd6f07ed
--- /dev/null
+++ b/db/migrate/20211111112713_add_fk_compliance_violations_violating_user.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddFkComplianceViolationsViolatingUser < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :merge_requests_compliance_violations,
+ :users,
+ column: :violating_user_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :merge_requests_compliance_violations, column: :violating_user_id
+ end
+ end
+end
diff --git a/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb b/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb
new file mode 100644
index 00000000000..6120a6ed0b4
--- /dev/null
+++ b/db/migrate/20211111164025_add_squash_commit_template_to_project_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSquashCommitTemplateToProjectSettings < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def change
+ add_column :project_settings, :squash_commit_template, :text # rubocop:disable Migration/AddLimitToTextColumns
+ end
+end
diff --git a/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb b/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb
new file mode 100644
index 00000000000..578d2271d60
--- /dev/null
+++ b/db/migrate/20211111164047_add_squash_commit_template_limit_to_project_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddSquashCommitTemplateLimitToProjectSettings < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :project_settings, :squash_commit_template, 500
+ end
+
+ def down
+ remove_text_limit :project_settings, :squash_commit_template
+ end
+end
diff --git a/db/migrate/20211112073413_change_package_index_on_corpus.rb b/db/migrate/20211112073413_change_package_index_on_corpus.rb
new file mode 100644
index 00000000000..6e8222f853c
--- /dev/null
+++ b/db/migrate/20211112073413_change_package_index_on_corpus.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class ChangePackageIndexOnCorpus < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'index_coverage_fuzzing_corpuses_on_package_id'
+
+ disable_ddl_transaction!
+
+ # Changing this index is safe.
+ # The table does not have any data in it as it's behind a feature flag.
+ def up
+ remove_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME
+ add_concurrent_index :coverage_fuzzing_corpuses, :package_id, unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME
+ add_concurrent_index :coverage_fuzzing_corpuses, :package_id, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20211115132613_create_incident_management_timeline_events.rb b/db/migrate/20211115132613_create_incident_management_timeline_events.rb
new file mode 100644
index 00000000000..217dcd27b4c
--- /dev/null
+++ b/db/migrate/20211115132613_create_incident_management_timeline_events.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class CreateIncidentManagementTimelineEvents < Gitlab::Database::Migration[1.0]
+ def up
+ create_table :incident_management_timeline_events do |t|
+ t.timestamps_with_timezone null: false
+ t.datetime_with_timezone :occurred_at, null: false
+ t.bigint :project_id, null: false
+ t.bigint :author_id
+ t.bigint :issue_id, null: false
+ t.bigint :updated_by_user_id
+ t.bigint :promoted_from_note_id
+ t.integer :cached_markdown_version
+ t.boolean :editable, null: false, default: false
+ t.text :note, limit: 10_000, null: false
+ t.text :note_html, limit: 10_000, null: false
+ t.text :action, limit: 128, null: false
+
+ t.index :project_id, name: 'index_im_timeline_events_project_id'
+ t.index :author_id, name: 'index_im_timeline_events_author_id'
+ t.index :issue_id, name: 'index_im_timeline_events_issue_id'
+ t.index :updated_by_user_id, name: 'index_im_timeline_events_updated_by_user_id'
+ t.index :promoted_from_note_id, name: 'index_im_timeline_events_promoted_from_note_id'
+ end
+ end
+
+ def down
+ drop_table :incident_management_timeline_events
+ end
+end
diff --git a/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb b/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb
new file mode 100644
index 00000000000..893043cc1ab
--- /dev/null
+++ b/db/migrate/20211115142803_add_foreign_key_to_incident_management_timeline_events_on_project.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToIncidentManagementTimelineEventsOnProject < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :incident_management_timeline_events, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :incident_management_timeline_events, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb b/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb
new file mode 100644
index 00000000000..0f5886eb5ed
--- /dev/null
+++ b/db/migrate/20211115142847_add_foreign_key_to_incident_management_timeline_events_on_user.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToIncidentManagementTimelineEventsOnUser < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :author_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :incident_management_timeline_events, column: :author_id
+ end
+ end
+end
diff --git a/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb b/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb
new file mode 100644
index 00000000000..bdcf7f389d1
--- /dev/null
+++ b/db/migrate/20211115142911_add_foreign_key_to_incident_management_timeline_events_on_issue.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToIncidentManagementTimelineEventsOnIssue < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :incident_management_timeline_events, :issues, column: :issue_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :incident_management_timeline_events, column: :issue_id
+ end
+ end
+end
diff --git a/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb b/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb
new file mode 100644
index 00000000000..e0e2bec72ad
--- /dev/null
+++ b/db/migrate/20211115145107_add_created_at_to_namespace_monthly_usages.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddCreatedAtToNamespaceMonthlyUsages < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :ci_namespace_monthly_usages, :created_at, :datetime_with_timezone
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :ci_namespace_monthly_usages, :created_at
+ end
+ end
+end
diff --git a/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb b/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb
new file mode 100644
index 00000000000..eb0cd448da3
--- /dev/null
+++ b/db/migrate/20211115154103_add_created_at_to_project_monthly_usage.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddCreatedAtToProjectMonthlyUsage < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :ci_project_monthly_usages, :created_at, :datetime_with_timezone
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :ci_project_monthly_usages, :created_at
+ end
+ end
+end
diff --git a/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb b/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb
new file mode 100644
index 00000000000..a35020699fc
--- /dev/null
+++ b/db/migrate/20211116093739_add_foreign_key_to_incident_management_timeline_events_on_updated_by_user.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToIncidentManagementTimelineEventsOnUpdatedByUser < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :updated_by_user_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :incident_management_timeline_events, column: :updated_by_user_id
+ end
+ end
+end
diff --git a/db/migrate/20211117174209_create_vulnerability_reads.rb b/db/migrate/20211117174209_create_vulnerability_reads.rb
new file mode 100644
index 00000000000..b9e32bfd0fa
--- /dev/null
+++ b/db/migrate/20211117174209_create_vulnerability_reads.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityReads < Gitlab::Database::Migration[1.0]
+ def change
+ create_table :vulnerability_reads do |t|
+ t.bigint :vulnerability_id, null: false
+ t.bigint :project_id, null: false
+ t.bigint :scanner_id, null: false
+ t.integer :report_type, limit: 2, null: false
+ t.integer :severity, limit: 2, null: false
+ t.integer :state, limit: 2, null: false
+ t.boolean :has_issues, default: false, null: false
+ t.boolean :resolved_on_default_branch, default: false, null: false
+ t.uuid :uuid, null: false
+ t.text :location_image, limit: 2048
+
+ t.index :vulnerability_id, unique: true
+ t.index :scanner_id
+ t.index :uuid, unique: true
+ t.index [:project_id, :state, :severity, :vulnerability_id], name: :index_vuln_reads_on_project_id_state_severity_and_vuln_id, order: { vulnerability_id: :desc }
+ t.index :location_image, where: "report_type IN (2, 7)", name: :index_vulnerability_reads_on_location_image
+ end
+ end
+end
diff --git a/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb b/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb
new file mode 100644
index 00000000000..185178d8025
--- /dev/null
+++ b/db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class ChangeDefaultValueOfLooseFkDeletedRecordsPartition < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def change
+ change_column_default(:loose_foreign_keys_deleted_records, :partition, from: nil, to: 1)
+ end
+end
diff --git a/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb b/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb
new file mode 100644
index 00000000000..33159167b19
--- /dev/null
+++ b/db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+class RemoveHardcodedPartitionFromLooseFkTriggerFunction < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}()
+ RETURNS TRIGGER AS
+ $$
+ BEGIN
+ INSERT INTO loose_foreign_keys_deleted_records
+ (fully_qualified_table_name, primary_key_value)
+ SELECT TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table;
+
+ RETURN NULL;
+ END
+ $$ LANGUAGE PLPGSQL
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ CREATE OR REPLACE FUNCTION #{DELETED_RECORDS_INSERT_FUNCTION_NAME}()
+ RETURNS TRIGGER AS
+ $$
+ BEGIN
+ INSERT INTO loose_foreign_keys_deleted_records
+ (partition, fully_qualified_table_name, primary_key_value)
+ SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table
+ ON CONFLICT DO NOTHING;
+
+ RETURN NULL;
+ END
+ $$ LANGUAGE PLPGSQL
+ SQL
+ end
+end
diff --git a/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb b/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb
new file mode 100644
index 00000000000..1b0d2104c91
--- /dev/null
+++ b/db/migrate/20211118114228_add_max_ssh_key_lifetime_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddMaxSshKeyLifetimeToApplicationSettings < Gitlab::Database::Migration[1.0]
+ def change
+ add_column :application_settings, :max_ssh_key_lifetime, :integer
+ end
+end
diff --git a/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb b/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb
new file mode 100644
index 00000000000..dd5b0bdc028
--- /dev/null
+++ b/db/migrate/20211118124537_add_foreign_key_to_vulnerability_reads_on_vulnerability.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToVulnerabilityReadsOnVulnerability < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerability_reads, :vulnerabilities, column: :vulnerability_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :vulnerability_reads, column: :vulnerability_id
+ end
+ end
+end
diff --git a/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb b/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb
new file mode 100644
index 00000000000..14dde371e3d
--- /dev/null
+++ b/db/migrate/20211118124628_add_foreign_key_to_vulnerability_reads_on_project.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToVulnerabilityReadsOnProject < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerability_reads, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :vulnerability_reads, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb b/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb
new file mode 100644
index 00000000000..923e62a4beb
--- /dev/null
+++ b/db/migrate/20211118124650_add_foreign_key_to_vulnerability_reads_on_scanner.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToVulnerabilityReadsOnScanner < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :vulnerability_reads, :vulnerability_scanners, column: :scanner_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :vulnerability_reads, column: :scanner_id
+ end
+ end
+end
diff --git a/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb b/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb
new file mode 100644
index 00000000000..f52bc346d16
--- /dev/null
+++ b/db/migrate/20211119085015_add_orignal_filename_to_ci_job_artifact.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddOrignalFilenameToCiJobArtifact < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20211119085036_add_text_limit_to_job_artifact_original_filename.rb
+ def up
+ add_column :ci_job_artifacts, :original_filename, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+
+ def down
+ remove_column :ci_job_artifacts, :original_filename, :text
+ end
+end
diff --git a/db/migrate/20211119154221_create_pages_deployment_states.rb b/db/migrate/20211119154221_create_pages_deployment_states.rb
new file mode 100644
index 00000000000..283f6c7d0d7
--- /dev/null
+++ b/db/migrate/20211119154221_create_pages_deployment_states.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+class CreatePagesDeploymentStates < Gitlab::Database::Migration[1.0]
+ VERIFICATION_STATE_INDEX_NAME = "index_pages_deployment_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_pages_deployment_states_needs_verification"
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:pages_deployment_states)
+ with_lock_retries do
+ create_table :pages_deployment_states, id: false do |t|
+ t.references :pages_deployment, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :verification_state, default: 0, limit: 2, null: false
+ t.column :verification_started_at, :datetime_with_timezone
+ t.datetime_with_timezone :verification_retry_at
+ t.datetime_with_timezone :verified_at
+ t.integer :verification_retry_count, limit: 2
+ t.binary :verification_checksum, using: 'verification_checksum::bytea'
+ t.text :verification_failure
+
+ t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
+ t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
+ t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
+ t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
+ end
+ end
+ end
+
+ add_text_limit :pages_deployment_states, :verification_failure, 255
+ end
+
+ def down
+ drop_table :pages_deployment_states
+ end
+end
diff --git a/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb b/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb
new file mode 100644
index 00000000000..9064242ee30
--- /dev/null
+++ b/db/migrate/20211119170805_remove_test_report_requirement_issue_constraint.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class RemoveTestReportRequirementIssueConstraint < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ TARGET_TABLE = :requirements_management_test_reports
+ CONSTRAINT_NAME = 'requirements_test_reports_requirement_id_xor_issue_id'
+
+ def up
+ remove_check_constraint TARGET_TABLE, CONSTRAINT_NAME
+ end
+
+ def down
+ add_check_constraint(TARGET_TABLE, 'num_nonnulls(requirement_id, issue_id) = 1', CONSTRAINT_NAME)
+ end
+end
diff --git a/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb b/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb
new file mode 100644
index 00000000000..ca6b78efbc7
--- /dev/null
+++ b/db/migrate/20211119194024_add_required_approval_count_to_protected_environments.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddRequiredApprovalCountToProtectedEnvironments < Gitlab::Database::Migration[1.0]
+ def change
+ add_column :protected_environments, :required_approval_count, :integer, default: 0, null: false
+ end
+end
diff --git a/db/migrate/20211119195201_create_deployment_approvals.rb b/db/migrate/20211119195201_create_deployment_approvals.rb
new file mode 100644
index 00000000000..a238da302f9
--- /dev/null
+++ b/db/migrate/20211119195201_create_deployment_approvals.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CreateDeploymentApprovals < Gitlab::Database::Migration[1.0]
+ def change
+ create_table :deployment_approvals do |t|
+ t.bigint :deployment_id, null: false
+ t.bigint :user_id, null: false, index: true
+ t.timestamps_with_timezone null: false
+ t.integer :status, limit: 2, null: false
+ t.index [:deployment_id, :user_id], unique: true
+ end
+ end
+end
diff --git a/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb b/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb
new file mode 100644
index 00000000000..b1c7bc4d5ce
--- /dev/null
+++ b/db/migrate/20211122215001_add_policy_idx_to_approval_merge_request_rule.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPolicyIdxToApprovalMergeRequestRule < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def change
+ add_column :approval_merge_request_rules, :orchestration_policy_idx, :integer, limit: 2
+ end
+end
diff --git a/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb b/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb
new file mode 100644
index 00000000000..da20e9a8f8e
--- /dev/null
+++ b/db/migrate/20211123181236_add_user_foreign_key_to_deployment_approvals.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddUserForeignKeyToDeploymentApprovals < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :deployment_approvals, :users, column: :user_id
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :deployment_approvals, :users
+ end
+ end
+end
diff --git a/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb b/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb
new file mode 100644
index 00000000000..10a0c6ca402
--- /dev/null
+++ b/db/migrate/20211123182614_make_iteration_cadences_start_date_nullable.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class MakeIterationCadencesStartDateNullable < Gitlab::Database::Migration[1.0]
+ def change
+ change_column_null :iterations_cadences, :start_date, true
+ end
+end
diff --git a/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb b/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb
new file mode 100644
index 00000000000..868bc4f14f2
--- /dev/null
+++ b/db/migrate/20211124132319_add_encrypted_static_objects_external_storage_auth_token.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddEncryptedStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0]
+ def up
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20211126113029_add_text_limit_for_static_objects_external_storage_auth_token
+ add_column :application_settings, :static_objects_external_storage_auth_token_encrypted, :text
+ # rubocop:enable Migration/AddLimitToTextColumns
+ end
+
+ def down
+ remove_column :application_settings, :static_objects_external_storage_auth_token_encrypted
+ end
+end
diff --git a/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb b/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb
new file mode 100644
index 00000000000..cbe5dbf99fc
--- /dev/null
+++ b/db/migrate/20211126042235_add_sequence_column_to_sprints_table.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddSequenceColumnToSprintsTable < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def up
+ add_column :sprints, :sequence, :integer
+ execute "ALTER TABLE sprints ADD CONSTRAINT sequence_is_unique_per_iterations_cadence_id UNIQUE (iterations_cadence_id, sequence) DEFERRABLE INITIALLY DEFERRED"
+ end
+
+ def down
+ remove_column :sprints, :sequence
+ end
+end
diff --git a/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb b/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb
new file mode 100644
index 00000000000..45c4686e674
--- /dev/null
+++ b/db/migrate/20211126113029_add_text_limit_for_static_objects_external_storage_auth_token.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+class AddTextLimitForStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :application_settings, :static_objects_external_storage_auth_token_encrypted, 255
+ end
+
+ def down
+ remove_text_limit :application_settings, :static_objects_external_storage_auth_token_encrypted
+ end
+end
diff --git a/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb b/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb
new file mode 100644
index 00000000000..9ce034b0065
--- /dev/null
+++ b/db/migrate/20211126115449_encrypt_static_objects_external_storage_auth_token.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class EncryptStaticObjectsExternalStorageAuthToken < Gitlab::Database::Migration[1.0]
+ class ApplicationSetting < ActiveRecord::Base
+ self.table_name = 'application_settings'
+
+ scope :encrypted_token_is_null, -> { where(static_objects_external_storage_auth_token_encrypted: nil) }
+ scope :encrypted_token_is_not_null, -> { where.not(static_objects_external_storage_auth_token_encrypted: nil) }
+ scope :plaintext_token_is_not_null, -> { where.not(static_objects_external_storage_auth_token: nil) }
+ end
+
+ def up
+ ApplicationSetting.reset_column_information
+
+ ApplicationSetting.encrypted_token_is_null.plaintext_token_is_not_null.find_each do |application_setting|
+ token_encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(application_setting.static_objects_external_storage_auth_token)
+ application_setting.update!(static_objects_external_storage_auth_token_encrypted: token_encrypted)
+ end
+ end
+
+ def down
+ ApplicationSetting.reset_column_information
+
+ ApplicationSetting.encrypted_token_is_not_null.find_each do |application_setting|
+ token = Gitlab::CryptoHelper.aes256_gcm_decrypt(application_setting.static_objects_external_storage_auth_token_encrypted)
+ application_setting.update!(static_objects_external_storage_auth_token: token, static_objects_external_storage_auth_token_encrypted: nil)
+ end
+ end
+end
diff --git a/db/migrate/20211126142200_add_encrypted_static_object_token.rb b/db/migrate/20211126142200_add_encrypted_static_object_token.rb
new file mode 100644
index 00000000000..839354244e7
--- /dev/null
+++ b/db/migrate/20211126142200_add_encrypted_static_object_token.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddEncryptedStaticObjectToken < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def up
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20211126142354_add_text_limit_to_encrypted_static_object_token
+ add_column :users, :static_object_token_encrypted, :text # rubocop:disable Migration/AddColumnsToWideTables
+ # rubocop:enable Migration/AddLimitToTextColumns
+ end
+
+ def down
+ remove_column :users, :static_object_token_encrypted
+ end
+end
diff --git a/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb b/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb
new file mode 100644
index 00000000000..a43e7d9a741
--- /dev/null
+++ b/db/migrate/20211126142354_add_text_limit_to_encrypted_static_object_token.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToEncryptedStaticObjectToken < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :users, :static_object_token_encrypted, 255
+ end
+
+ def down
+ remove_text_limit :users, :static_object_token_encrypted
+ end
+end
diff --git a/db/migrate/20211126204445_add_task_to_work_item_types.rb b/db/migrate/20211126204445_add_task_to_work_item_types.rb
new file mode 100644
index 00000000000..875c2272c6d
--- /dev/null
+++ b/db/migrate/20211126204445_add_task_to_work_item_types.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class AddTaskToWorkItemTypes < Gitlab::Database::Migration[1.0]
+ TASK_ENUM_VALUE = 4
+
+ class WorkItemType < ActiveRecord::Base
+ self.inheritance_column = :_type_disabled
+ self.table_name = 'work_item_types'
+
+ validates :name, uniqueness: { case_sensitive: false, scope: [:namespace_id] }
+ end
+
+ def up
+ # New instances will not run this migration and add this type via fixtures
+ # checking if record exists mostly because migration specs will run all migrations
+ # and that will conflict with the preloaded base work item types
+ task_work_item = WorkItemType.find_by(name: 'Task', namespace_id: nil)
+
+ if task_work_item
+ say('Task item record exist, skipping creation')
+ else
+ WorkItemType.create(name: 'Task', namespace_id: nil, base_type: TASK_ENUM_VALUE, icon_name: 'issue-type-task')
+ end
+ end
+
+ def down
+ # There's the remote possibility that issues could already be
+ # using this issue type, with a tight foreign constraint.
+ # Therefore we will not attempt to remove any data.
+ end
+end
diff --git a/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb b/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..8c3cf82d7c7
--- /dev/null
+++ b/db/migrate/20211129151155_add_migrated_to_new_structure_column_to_vulnerability_occurrences.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddMigratedToNewStructureColumnToVulnerabilityOccurrences < Gitlab::Database::Migration[1.0]
+ def change
+ add_column :vulnerability_occurrences, :migrated_to_new_structure, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb b/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb
new file mode 100644
index 00000000000..4cf8263f8f0
--- /dev/null
+++ b/db/migrate/20211129151832_add_index_on_vulnerability_occurrences_migrated_to_new_structure_column.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexOnVulnerabilityOccurrencesMigratedToNewStructureColumn < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'index_vulnerability_occurrences_on_migrated_to_new_structure'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerability_occurrences, [:migrated_to_new_structure, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb b/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb
new file mode 100644
index 00000000000..a09409900f7
--- /dev/null
+++ b/db/migrate/20211130151724_add_foreign_key_to_incident_management_timeline_events_on_note.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToIncidentManagementTimelineEventsOnNote < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :incident_management_timeline_events, :notes, column: :promoted_from_note_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :incident_management_timeline_events, column: :promoted_from_note_id
+ end
+ end
+end
diff --git a/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb b/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb
new file mode 100644
index 00000000000..1aca3e7e8e2
--- /dev/null
+++ b/db/migrate/20211130205719_add_uniqueness_for_evidence_occurrence_id.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddUniquenessForEvidenceOccurrenceId < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'finding_evidences_on_vulnerability_occurrence_id'
+ UNIQUE_INDEX_NAME = 'finding_evidences_on_unique_vulnerability_occurrence_id'
+
+ def up
+ add_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], unique: true, name: UNIQUE_INDEX_NAME
+ remove_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: INDEX_NAME
+ remove_concurrent_index :vulnerability_finding_evidences, [:vulnerability_occurrence_id], name: UNIQUE_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb b/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb
new file mode 100644
index 00000000000..9cbbef42327
--- /dev/null
+++ b/db/migrate/20211201061733_add_future_subscriptions_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddFutureSubscriptionsToApplicationSettings < Gitlab::Database::Migration[1.0]
+ def change
+ add_column :application_settings, :future_subscriptions, :jsonb, null: false, default: []
+ end
+end
diff --git a/db/migrate/20211201143042_create_lfs_object_states.rb b/db/migrate/20211201143042_create_lfs_object_states.rb
new file mode 100644
index 00000000000..91accbcd438
--- /dev/null
+++ b/db/migrate/20211201143042_create_lfs_object_states.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class CreateLfsObjectStates < Gitlab::Database::Migration[1.0]
+ VERIFICATION_STATE_INDEX_NAME = "index_lfs_object_states_on_verification_state"
+ PENDING_VERIFICATION_INDEX_NAME = "index_lfs_object_states_pending_verification"
+ FAILED_VERIFICATION_INDEX_NAME = "index_lfs_object_states_failed_verification"
+ NEEDS_VERIFICATION_INDEX_NAME = "index_lfs_object_states_needs_verification"
+
+ disable_ddl_transaction!
+
+ def up
+ create_table :lfs_object_states, id: false do |t|
+ t.datetime_with_timezone :verification_started_at
+ t.datetime_with_timezone :verification_retry_at
+ t.datetime_with_timezone :verified_at
+ t.references :lfs_object, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :verification_state, default: 0, limit: 2, null: false
+ t.integer :verification_retry_count, limit: 2
+ t.binary :verification_checksum, using: 'verification_checksum::bytea'
+ t.text :verification_failure, limit: 255
+
+ t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME
+ t.index :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
+ t.index :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
+ t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
+ end
+ end
+
+ def down
+ drop_table :lfs_object_states
+ end
+end
diff --git a/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb b/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb
new file mode 100644
index 00000000000..60bc892d792
--- /dev/null
+++ b/db/migrate/20211202041233_add_deployment_foreign_key_to_deployment_approvals.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddDeploymentForeignKeyToDeploymentApprovals < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :deployment_approvals, :deployments, column: :deployment_id
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :deployment_approvals, :deployments
+ end
+ end
+end
diff --git a/db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb b/db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb
new file mode 100644
index 00000000000..84bc551d2b5
--- /dev/null
+++ b/db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class MoveLooseFkDeletedRecordsToDynamicSchema < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def up
+ if table_exists?('gitlab_partitions_static.loose_foreign_keys_deleted_records_1')
+ execute 'ALTER TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1 SET SCHEMA gitlab_partitions_dynamic'
+ end
+ end
+
+ def down
+ if table_exists?('gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1')
+ execute 'ALTER TABLE gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1 SET SCHEMA gitlab_partitions_static'
+ end
+ end
+end
diff --git a/db/migrate/20211202135508_add_index_on_packages_build_infos_package_id_pipeline_id.rb b/db/migrate/20211202135508_add_index_on_packages_build_infos_package_id_pipeline_id.rb
new file mode 100644
index 00000000000..47a155d40fa
--- /dev/null
+++ b/db/migrate/20211202135508_add_index_on_packages_build_infos_package_id_pipeline_id.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnPackagesBuildInfosPackageIdPipelineId < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_packages_build_infos_package_id_pipeline_id'
+ OLD_INDEX_NAME = 'idx_packages_build_infos_on_package_id'
+
+ def up
+ add_concurrent_index :packages_build_infos, [:package_id, :pipeline_id], name: INDEX_NAME
+ remove_concurrent_index_by_name :packages_build_infos, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :packages_build_infos, :package_id, name: OLD_INDEX_NAME
+ remove_concurrent_index :packages_build_infos, [:package_id, :pipeline_id], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20211204010826_add_index_snippets_on_project_id_and_title.rb b/db/migrate/20211204010826_add_index_snippets_on_project_id_and_title.rb
new file mode 100644
index 00000000000..35a3a98030a
--- /dev/null
+++ b/db/migrate/20211204010826_add_index_snippets_on_project_id_and_title.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexSnippetsOnProjectIdAndTitle < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_snippets_on_project_id_and_title'
+
+ def up
+ add_concurrent_index :snippets, [:project_id, :title], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :snippets, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20211207154413_add_ci_runners_index_on_created_at_where_active_is_false.rb b/db/migrate/20211207154413_add_ci_runners_index_on_created_at_where_active_is_false.rb
new file mode 100644
index 00000000000..da391da33ec
--- /dev/null
+++ b/db/migrate/20211207154413_add_ci_runners_index_on_created_at_where_active_is_false.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddCiRunnersIndexOnCreatedAtWhereActiveIsFalse < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'index_ci_runners_on_created_at_and_id_where_inactive'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_runners, [:created_at, :id], where: 'active = FALSE', order: { created_at: :desc, id: :desc }, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_runners, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20211207154414_add_ci_runners_index_on_contacted_at_where_active_is_false.rb b/db/migrate/20211207154414_add_ci_runners_index_on_contacted_at_where_active_is_false.rb
new file mode 100644
index 00000000000..e25d3c0dffa
--- /dev/null
+++ b/db/migrate/20211207154414_add_ci_runners_index_on_contacted_at_where_active_is_false.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddCiRunnersIndexOnContactedAtWhereActiveIsFalse < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'index_ci_runners_on_contacted_at_and_id_where_inactive'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_runners, [:contacted_at, :id], where: 'active = FALSE', order: { contacted_at: :desc, id: :desc }, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_runners, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20211207165508_add_protected_environments_required_approval_count_check_constraint.rb b/db/migrate/20211207165508_add_protected_environments_required_approval_count_check_constraint.rb
new file mode 100644
index 00000000000..fb1339cecfa
--- /dev/null
+++ b/db/migrate/20211207165508_add_protected_environments_required_approval_count_check_constraint.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddProtectedEnvironmentsRequiredApprovalCountCheckConstraint < Gitlab::Database::Migration[1.0]
+ CONSTRAINT_NAME = 'protected_environments_required_approval_count_positive'
+
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint :protected_environments, 'required_approval_count >= 0', CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :protected_environments, CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb b/db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb
new file mode 100644
index 00000000000..1e1fdbdb122
--- /dev/null
+++ b/db/migrate/20211208111425_add_executor_type_column_to_ci_runners.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddExecutorTypeColumnToCiRunners < Gitlab::Database::Migration[1.0]
+ def change
+ add_column :ci_runners, :executor_type, :smallint, null: true
+ end
+end
diff --git a/db/migrate/20211213130324_update_timelogs_spent_at_default.rb b/db/migrate/20211213130324_update_timelogs_spent_at_default.rb
new file mode 100644
index 00000000000..f90b19b5f68
--- /dev/null
+++ b/db/migrate/20211213130324_update_timelogs_spent_at_default.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class UpdateTimelogsSpentAtDefault < Gitlab::Database::Migration[1.0]
+ def change
+ change_column_default(:timelogs, :spent_at, from: nil, to: -> { 'NOW()' })
+ end
+end
diff --git a/db/migrate/20211214110307_remove_temp_index_from_vulnerability_occurrences.rb b/db/migrate/20211214110307_remove_temp_index_from_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..99f985d528c
--- /dev/null
+++ b/db/migrate/20211214110307_remove_temp_index_from_vulnerability_occurrences.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoveTempIndexFromVulnerabilityOccurrences < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'vulnerability_occurrences_location_temp_index'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :vulnerability_occurrences, name: INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :vulnerability_occurrences, :id, where: 'location IS NULL', name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb b/db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb
new file mode 100644
index 00000000000..34701d8ba46
--- /dev/null
+++ b/db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+# When the `ci_sources_pipelines` table was first introduced in GitLab
+# 9.3 EE, the foreign key names generate for the table appeared to
+# have been calculated via a hash using the table name
+# `ci_pipeline_source_pipelines`. This led to a merge conflict and
+# confusion during a CE to EE merge in GitLab 10.0, which regenerated
+# the schema with the correct foreign key names.
+#
+# Hence anyone who installed GitLab prior to 10.0 may have been seeded
+# the database with stale, incorrect foreign key names.
+#
+# During the Great BigInt Conversion of 2021, several migrations
+# assumed that the foreign key `fk_be5624bf37` existed for
+# `ci_sources_pipeline`. However, older installations may have had the
+# correct foreign key under the name `fk_3f0c88d7dc`.
+#
+# To eliminate future confusion and migration failures, we now rename
+# the foreign key constraints and index to what they should be today.
+class FixCiSourcesPipelinesIndexNames < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_sources_pipelines'
+
+ # GitLab 9.5.4: https://gitlab.com/gitlab-org/gitlab/-/blob/v9.5.4-ee/db/schema.rb#L2026-2030
+ # GitLab 10.0: https://gitlab.com/gitlab-org/gitlab/-/blob/v10.0.0-ee/db/schema.rb#L2064-2068
+ OLD_TO_NEW_FOREIGN_KEY_DEFS = {
+ 'fk_3f0c88d7dc' => { table: :ci_builds, column: :source_job_id, name: 'fk_be5624bf37' },
+ 'fk_b8c0fac459' => { table: :ci_pipelines, column: :pipeline_id, name: 'fk_e1bad85861' },
+ 'fk_3a3e3cb83a' => { table: :ci_pipelines, column: :source_pipeline_id, name: 'fk_d4e29af7d7' },
+ 'fk_8868d0f3e4' => { table: :projects, column: :source_project_id, name: 'fk_acd9737679' },
+ 'fk_83b4346e48' => { table: :projects, name: 'fk_1e53c97c0a' }
+ }
+ OLD_INDEX_NAME = 'index_ci_pipeline_source_pipelines_on_source_job_id'
+ NEW_INDEX_NAME = 'index_ci_sources_pipelines_on_source_job_id'
+
+ def up
+ OLD_TO_NEW_FOREIGN_KEY_DEFS.each do |old_name, entry|
+ options = { column: entry[:column], name: old_name }.compact
+
+ if foreign_key_exists?(TABLE_NAME, entry[:table], **options)
+ rename_constraint(TABLE_NAME, old_name, entry[:name])
+ end
+ end
+
+ if index_exists_by_name?(TABLE_NAME, OLD_INDEX_NAME)
+ if index_exists_by_name?(TABLE_NAME, NEW_INDEX_NAME)
+ remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME)
+ else
+ rename_index(TABLE_NAME, OLD_INDEX_NAME, NEW_INDEX_NAME)
+ end
+ end
+ end
+
+ # There's no reason to revert this change since it should apply on stale schemas
+ def down; end
+end
diff --git a/db/post_migrate/20211022214523_schedule_recalculate_vulnerability_finding_signatures_for_findings.rb b/db/post_migrate/20211022214523_schedule_recalculate_vulnerability_finding_signatures_for_findings.rb
new file mode 100644
index 00000000000..bccbc4e3209
--- /dev/null
+++ b/db/post_migrate/20211022214523_schedule_recalculate_vulnerability_finding_signatures_for_findings.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class ScheduleRecalculateVulnerabilityFindingSignaturesForFindings < Gitlab::Database::Migration[1.0]
+ MIGRATION = 'RecalculateVulnerabilityFindingSignaturesForFindings'
+ BATCH_SIZE = 1_000
+ DELAY_INTERVAL = 2.minutes
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.ee?
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('vulnerability_finding_signatures'),
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ track_jobs: true
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211023102243_schedule_delete_invalid_epic_issues.rb b/db/post_migrate/20211023102243_schedule_delete_invalid_epic_issues.rb
new file mode 100644
index 00000000000..e08ad8d89d1
--- /dev/null
+++ b/db/post_migrate/20211023102243_schedule_delete_invalid_epic_issues.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class ScheduleDeleteInvalidEpicIssues < Gitlab::Database::Migration[1.0]
+ # This is a now a no-op
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/348477
+
+ def up
+ # no-op
+ end
+
+ def down
+ # also no-op
+ end
+end
diff --git a/db/post_migrate/20211027043206_track_ci_pipeline_deletions.rb b/db/post_migrate/20211027043206_track_ci_pipeline_deletions.rb
new file mode 100644
index 00000000000..3836159c2cd
--- /dev/null
+++ b/db/post_migrate/20211027043206_track_ci_pipeline_deletions.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackCiPipelineDeletions < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:ci_pipelines)
+ end
+
+ def down
+ untrack_record_deletions(:ci_pipelines)
+ end
+end
diff --git a/db/post_migrate/20211027043229_track_ci_build_deletions.rb b/db/post_migrate/20211027043229_track_ci_build_deletions.rb
new file mode 100644
index 00000000000..b76d5f3261c
--- /dev/null
+++ b/db/post_migrate/20211027043229_track_ci_build_deletions.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackCiBuildDeletions < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:ci_builds)
+ end
+
+ def down
+ untrack_record_deletions(:ci_builds)
+ end
+end
diff --git a/db/post_migrate/20211101222614_consume_remaining_user_namespace_jobs.rb b/db/post_migrate/20211101222614_consume_remaining_user_namespace_jobs.rb
new file mode 100644
index 00000000000..ded9e717bb1
--- /dev/null
+++ b/db/post_migrate/20211101222614_consume_remaining_user_namespace_jobs.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class ConsumeRemainingUserNamespaceJobs < Gitlab::Database::Migration[1.0]
+ MIGRATION = 'BackfillUserNamespace'
+ BATCH_SIZE = 200
+ DEFAULT_VALUE = 'User'
+
+ disable_ddl_transaction!
+
+ def up
+ Gitlab::BackgroundMigration.steal(MIGRATION)
+
+ # Do a manual update in case we lost BG jobs. The expected record count should be 0 or very low.
+ define_batchable_model('namespaces').where(type: nil).each_batch(of: BATCH_SIZE) do |batch|
+ min, max = batch.pluck('MIN(id), MAX(id)').flatten
+
+ Gitlab::BackgroundMigration::BackfillUserNamespace.new.perform(min, max, :namespaces, :id, BATCH_SIZE, 0)
+ end
+
+ change_column_null :namespaces, :type, false
+ end
+
+ def down
+ change_column_null :namespaces, :type, true
+ end
+end
diff --git a/db/post_migrate/20211103141403_remove_propagate_service_template_worker.rb b/db/post_migrate/20211103141403_remove_propagate_service_template_worker.rb
new file mode 100644
index 00000000000..d949641dbce
--- /dev/null
+++ b/db/post_migrate/20211103141403_remove_propagate_service_template_worker.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemovePropagateServiceTemplateWorker < Gitlab::Database::Migration[1.0]
+ def up
+ Sidekiq::Queue.new('propagate_service_template').clear
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211104165220_remove_vulnerability_finding_links.rb b/db/post_migrate/20211104165220_remove_vulnerability_finding_links.rb
new file mode 100644
index 00000000000..fc50aa812a7
--- /dev/null
+++ b/db/post_migrate/20211104165220_remove_vulnerability_finding_links.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveVulnerabilityFindingLinks < Gitlab::Database::Migration[1.0]
+ BATCH_SIZE = 50_000
+ MIGRATION = 'RemoveVulnerabilityFindingLinks'
+
+ disable_ddl_transaction!
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('vulnerability_finding_links'),
+ MIGRATION,
+ 2.minutes,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ def down
+ # no ops
+ end
+end
diff --git a/db/post_migrate/20211110143306_add_not_null_constraint_to_security_findings_uuid.rb b/db/post_migrate/20211110143306_add_not_null_constraint_to_security_findings_uuid.rb
new file mode 100644
index 00000000000..bdb8f5cd120
--- /dev/null
+++ b/db/post_migrate/20211110143306_add_not_null_constraint_to_security_findings_uuid.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddNotNullConstraintToSecurityFindingsUuid < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_not_null_constraint(
+ :security_findings,
+ :uuid,
+ validate: false
+ )
+ end
+
+ def down
+ remove_not_null_constraint(
+ :security_findings,
+ :uuid
+ )
+ end
+end
diff --git a/db/post_migrate/20211110151320_add_temporary_index_on_security_findings_uuid.rb b/db/post_migrate/20211110151320_add_temporary_index_on_security_findings_uuid.rb
new file mode 100644
index 00000000000..7bc4af0ec4d
--- /dev/null
+++ b/db/post_migrate/20211110151320_add_temporary_index_on_security_findings_uuid.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddTemporaryIndexOnSecurityFindingsUuid < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = "tmp_index_uuid_is_null"
+
+ def up
+ add_concurrent_index(
+ :security_findings,
+ :id,
+ where: "uuid IS NULL",
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name(
+ :security_findings,
+ INDEX_NAME
+ )
+ end
+end
diff --git a/db/post_migrate/20211110151350_schedule_drop_invalid_security_findings.rb b/db/post_migrate/20211110151350_schedule_drop_invalid_security_findings.rb
new file mode 100644
index 00000000000..98e7b2a8a15
--- /dev/null
+++ b/db/post_migrate/20211110151350_schedule_drop_invalid_security_findings.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class ScheduleDropInvalidSecurityFindings < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ MIGRATION = "DropInvalidSecurityFindings"
+ DELAY_INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 100_000
+ SUB_BATCH_SIZE = 10_000
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('security_findings').where(uuid: nil),
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ other_job_arguments: [SUB_BATCH_SIZE],
+ track_jobs: true
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211116091751_change_namespace_type_default_to_user.rb b/db/post_migrate/20211116091751_change_namespace_type_default_to_user.rb
new file mode 100644
index 00000000000..468b26e9eb1
--- /dev/null
+++ b/db/post_migrate/20211116091751_change_namespace_type_default_to_user.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ChangeNamespaceTypeDefaultToUser < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ change_column_default :namespaces, :type, 'User'
+ end
+ end
+
+ def down
+ with_lock_retries do
+ change_column_default :namespaces, :type, nil
+ end
+ end
+end
diff --git a/db/post_migrate/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings.rb b/db/post_migrate/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings.rb
new file mode 100644
index 00000000000..0424d32a81e
--- /dev/null
+++ b/db/post_migrate/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings < Gitlab::Database::Migration[1.0]
+ MIGRATION = 'RemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings'
+ DELAY_INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 10_000
+
+ disable_ddl_transaction!
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('vulnerability_occurrences'),
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ track_jobs: true
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb b/db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb
new file mode 100644
index 00000000000..ae9dba32a4a
--- /dev/null
+++ b/db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class MigrateRemainingU2fRegistrations < Gitlab::Database::Migration[1.0]
+ BATCH_SIZE = 100
+
+ disable_ddl_transaction!
+
+ def up
+ # We expect only a few number of records satisfying these conditions.
+ # on gitlab.com database, this number is 70 as on 17th Nov, 2021.
+ define_batchable_model('u2f_registrations')
+ .joins("LEFT JOIN webauthn_registrations ON webauthn_registrations.u2f_registration_id = u2f_registrations.id")
+ .where(webauthn_registrations: { u2f_registration_id: nil })
+ .each_batch(of: BATCH_SIZE) do |batch, index|
+ batch.each do |record|
+ Gitlab::BackgroundMigration::MigrateU2fWebauthn.new.perform(record.id, record.id)
+ rescue StandardError => e
+ Gitlab::ErrorTracking.track_exception(e, u2f_registration_id: record.id)
+ end
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211118130836_drop_pages_deployments_builds_fk.rb b/db/post_migrate/20211118130836_drop_pages_deployments_builds_fk.rb
new file mode 100644
index 00000000000..5eb532f2a00
--- /dev/null
+++ b/db/post_migrate/20211118130836_drop_pages_deployments_builds_fk.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class DropPagesDeploymentsBuildsFk < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ FK_NAME = 'fk_rails_c3a90cf29b'
+
+ def up
+ remove_foreign_key_if_exists(:pages_deployments, :ci_builds, name: FK_NAME)
+ end
+
+ def down
+ add_concurrent_foreign_key(
+ :pages_deployments,
+ :ci_builds,
+ name: FK_NAME,
+ column: :ci_build_id,
+ target_column: :id,
+ on_delete: :nullify
+ )
+ end
+end
diff --git a/db/post_migrate/20211118194239_drop_invalid_remediations.rb b/db/post_migrate/20211118194239_drop_invalid_remediations.rb
new file mode 100644
index 00000000000..93edde87936
--- /dev/null
+++ b/db/post_migrate/20211118194239_drop_invalid_remediations.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class DropInvalidRemediations < Gitlab::Database::Migration[1.0]
+ BATCH_SIZE = 3_000
+ DELAY_INTERVAL = 3.minutes
+ MIGRATION_NAME = 'DropInvalidRemediations'
+ DAY_PRIOR_TO_BUG_INTRODUCTION = DateTime.new(2021, 8, 1, 0, 0, 0)
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.ee?
+
+ relation = Gitlab::BackgroundMigration::DropInvalidRemediations::FindingRemediation.where("created_at > ?", DAY_PRIOR_TO_BUG_INTRODUCTION)
+ queue_background_migration_jobs_by_range_at_intervals(relation,
+ MIGRATION_NAME,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ track_jobs: true)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211119085036_add_text_limit_to_job_artifact_original_filename.rb b/db/post_migrate/20211119085036_add_text_limit_to_job_artifact_original_filename.rb
new file mode 100644
index 00000000000..3eccbb1b3a4
--- /dev/null
+++ b/db/post_migrate/20211119085036_add_text_limit_to_job_artifact_original_filename.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddTextLimitToJobArtifactOriginalFilename < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :ci_job_artifacts, :original_filename, 512
+ end
+
+ def down
+ remove_text_limit :ci_job_artifacts, :original_filename
+ end
+end
diff --git a/db/post_migrate/20211122033501_improve_index_on_events_for_calendar.rb b/db/post_migrate/20211122033501_improve_index_on_events_for_calendar.rb
new file mode 100644
index 00000000000..517e0f08d6a
--- /dev/null
+++ b/db/post_migrate/20211122033501_improve_index_on_events_for_calendar.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ImproveIndexOnEventsForCalendar < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'index_events_author_id_project_id_action_target_type_created_at'
+
+ def up
+ prepare_async_index :events, [:author_id, :project_id, :action, :target_type, :created_at], name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :events, [:author_id, :project_id, :action, :target_type, :created_at], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211122193948_cleanup_background_migration_of_requirements_to_work_items.rb b/db/post_migrate/20211122193948_cleanup_background_migration_of_requirements_to_work_items.rb
new file mode 100644
index 00000000000..df4867d6ae7
--- /dev/null
+++ b/db/post_migrate/20211122193948_cleanup_background_migration_of_requirements_to_work_items.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CleanupBackgroundMigrationOfRequirementsToWorkItems < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ MIGRATION = 'MigrateRequirementsToWorkItems'
+
+ disable_ddl_transaction!
+
+ def up
+ finalize_background_migration(MIGRATION)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211124132705_change_index_users_on_public_email.rb b/db/post_migrate/20211124132705_change_index_users_on_public_email.rb
new file mode 100644
index 00000000000..6e74a325033
--- /dev/null
+++ b/db/post_migrate/20211124132705_change_index_users_on_public_email.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ChangeIndexUsersOnPublicEmail < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'index_users_on_public_email'
+ INDEX_EXCLUDING_NULL_NAME = 'index_users_on_public_email_excluding_null_and_empty'
+
+ disable_ddl_transaction!
+
+ def up
+ index_condition = "public_email != '' AND public_email IS NOT NULL"
+
+ add_concurrent_index :users, [:public_email], where: index_condition, name: INDEX_EXCLUDING_NULL_NAME
+ remove_concurrent_index_by_name :users, INDEX_NAME
+ end
+
+ def down
+ index_condition = "public_email != ''"
+
+ add_concurrent_index :users, [:public_email], where: index_condition, name: INDEX_NAME
+ remove_concurrent_index_by_name :users, INDEX_EXCLUDING_NULL_NAME
+ end
+end
diff --git a/db/post_migrate/20211125120444_add_index_todos_project_id_user_id.rb b/db/post_migrate/20211125120444_add_index_todos_project_id_user_id.rb
new file mode 100644
index 00000000000..5cc78fc75c4
--- /dev/null
+++ b/db/post_migrate/20211125120444_add_index_todos_project_id_user_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexTodosProjectIdUserId < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_todos_on_project_id_and_user_id_and_id'
+
+ def up
+ add_concurrent_index :todos, [:project_id, :user_id, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :todos, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211130165043_backfill_sequence_column_for_sprints_table.rb b/db/post_migrate/20211130165043_backfill_sequence_column_for_sprints_table.rb
new file mode 100644
index 00000000000..420bfb8bcbc
--- /dev/null
+++ b/db/post_migrate/20211130165043_backfill_sequence_column_for_sprints_table.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class BackfillSequenceColumnForSprintsTable < Gitlab::Database::Migration[1.0]
+ enable_lock_retries!
+
+ def up
+ execute(
+ <<-SQL
+ UPDATE sprints
+ SET sequence=t.row_number
+ FROM (
+ SELECT id, row_number() OVER (PARTITION BY iterations_cadence_id ORDER BY start_date)
+ FROM sprints as s1
+ WHERE s1.iterations_cadence_id IS NOT NULL
+ ) as t
+ WHERE t.id=sprints.id AND (sprints.sequence IS NULL OR sprints.sequence <> t.row_number)
+ SQL
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211130201100_track_deletions_in_namespaces.rb b/db/post_migrate/20211130201100_track_deletions_in_namespaces.rb
new file mode 100644
index 00000000000..e688e0b467d
--- /dev/null
+++ b/db/post_migrate/20211130201100_track_deletions_in_namespaces.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackDeletionsInNamespaces < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:namespaces)
+ end
+
+ def down
+ untrack_record_deletions(:namespaces)
+ end
+end
diff --git a/db/post_migrate/20211130201101_track_deletions_in_projects.rb b/db/post_migrate/20211130201101_track_deletions_in_projects.rb
new file mode 100644
index 00000000000..dfe7ab4c037
--- /dev/null
+++ b/db/post_migrate/20211130201101_track_deletions_in_projects.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackDeletionsInProjects < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:projects)
+ end
+
+ def down
+ untrack_record_deletions(:projects)
+ end
+end
diff --git a/db/post_migrate/20211201101541_drop_clusters_applications_runners_ci_runners_fk.rb b/db/post_migrate/20211201101541_drop_clusters_applications_runners_ci_runners_fk.rb
new file mode 100644
index 00000000000..9a02f64e350
--- /dev/null
+++ b/db/post_migrate/20211201101541_drop_clusters_applications_runners_ci_runners_fk.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DropClustersApplicationsRunnersCiRunnersFk < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(:clusters_applications_runners, :ci_runners, name: 'fk_02de2ded36')
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key(:clusters_applications_runners, :ci_runners, name: 'fk_02de2ded36', column: :runner_id, target_column: :id, on_delete: 'set null')
+ end
+end
diff --git a/db/post_migrate/20211202145237_add_todos_project_and_id_index.rb b/db/post_migrate/20211202145237_add_todos_project_and_id_index.rb
new file mode 100644
index 00000000000..69f7822c057
--- /dev/null
+++ b/db/post_migrate/20211202145237_add_todos_project_and_id_index.rb
@@ -0,0 +1,32 @@
+# 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 AddTodosProjectAndIdIndex < Gitlab::Database::Migration[1.0]
+ # When using the methods "add_concurrent_index" or "remove_concurrent_index"
+ # you must disable the use of transactions
+ # as these methods can not run in an existing transaction.
+ # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure
+ # that either of them is the _only_ method called in the migration,
+ # any other changes should go in a separate migration.
+ # This ensures that upon failure _only_ the index creation or removing fails
+ # and can be retried or reverted easily.
+ #
+ # To disable transactions uncomment the following line and remove these
+ # comments:
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'index_todos_on_project_id_and_id'
+ OLD_INDEX_NAME = 'index_todos_on_project_id'
+
+ def up
+ add_concurrent_index :todos, [:project_id, :id], name: NEW_INDEX_NAME
+ remove_concurrent_index_by_name :todos, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :todos, :project_id, name: OLD_INDEX_NAME
+ remove_concurrent_index_by_name :todos, NEW_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211203091642_add_index_to_projects_on_marked_for_deletion_at.rb b/db/post_migrate/20211203091642_add_index_to_projects_on_marked_for_deletion_at.rb
new file mode 100644
index 00000000000..56b0df1f393
--- /dev/null
+++ b/db/post_migrate/20211203091642_add_index_to_projects_on_marked_for_deletion_at.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToProjectsOnMarkedForDeletionAt < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_projects_not_aimed_for_deletion'
+
+ def up
+ add_concurrent_index :projects, :id, where: 'marked_for_deletion_at IS NULL', name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :projects, :id, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211206073851_create_calendar_events_index_synchronously.rb b/db/post_migrate/20211206073851_create_calendar_events_index_synchronously.rb
new file mode 100644
index 00000000000..020dceac004
--- /dev/null
+++ b/db/post_migrate/20211206073851_create_calendar_events_index_synchronously.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateCalendarEventsIndexSynchronously < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_events_author_id_project_id_action_target_type_created_at'
+
+ def up
+ add_concurrent_index :events, [:author_id, :project_id, :action, :target_type, :created_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :events, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211206074547_remove_old_calendar_events_index.rb b/db/post_migrate/20211206074547_remove_old_calendar_events_index.rb
new file mode 100644
index 00000000000..51460a9dc95
--- /dev/null
+++ b/db/post_migrate/20211206074547_remove_old_calendar_events_index.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class RemoveOldCalendarEventsIndex < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ OLD_INDEX_NAME = 'index_events_on_author_id_and_project_id'
+
+ def up
+ remove_concurrent_index_by_name :events, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :events, [:author_id, :project_id], name: OLD_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211207090503_cleanup_first_mentioned_in_commit_jobs.rb b/db/post_migrate/20211207090503_cleanup_first_mentioned_in_commit_jobs.rb
new file mode 100644
index 00000000000..3788a680fb6
--- /dev/null
+++ b/db/post_migrate/20211207090503_cleanup_first_mentioned_in_commit_jobs.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CleanupFirstMentionedInCommitJobs < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ MIGRATION = 'FixFirstMentionedInCommitAt'
+ INDEX_NAME = 'index_issue_metrics_first_mentioned_in_commit'
+
+ def up
+ finalize_background_migration(MIGRATION)
+
+ remove_concurrent_index_by_name :issue_metrics, name: INDEX_NAME
+ end
+
+ def down
+ # Handles reported schema inconsistencies (column with or without timezone)
+ # We did the same in db/post_migrate/20211004110500_add_temporary_index_to_issue_metrics.rb
+ condition = Gitlab::BackgroundMigration::FixFirstMentionedInCommitAt::TmpIssueMetrics
+ .first_mentioned_in_commit_at_condition
+ add_concurrent_index :issue_metrics, :issue_id, where: condition, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211208171402_reschedule_recalculate_vulnerability_finding_signatures_for_findings.rb b/db/post_migrate/20211208171402_reschedule_recalculate_vulnerability_finding_signatures_for_findings.rb
new file mode 100644
index 00000000000..8eee082809b
--- /dev/null
+++ b/db/post_migrate/20211208171402_reschedule_recalculate_vulnerability_finding_signatures_for_findings.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class RescheduleRecalculateVulnerabilityFindingSignaturesForFindings < Gitlab::Database::Migration[1.0]
+ MIGRATION = 'RecalculateVulnerabilityFindingSignaturesForFindings'
+ BATCH_SIZE = 1_000
+ DELAY_INTERVAL = 2.minutes
+
+ disable_ddl_transaction!
+
+ # Due to production incident previous migration was orphaned and must be rescheduled,
+ # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/72919#note_741188600
+ def up
+ return unless Gitlab.ee?
+
+ delete_queued_jobs(MIGRATION)
+
+ requeue_background_migration_jobs_by_range_at_intervals(
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20211209093636_track_ci_job_artifacts_deletes.rb b/db/post_migrate/20211209093636_track_ci_job_artifacts_deletes.rb
new file mode 100644
index 00000000000..8c95c76d1fe
--- /dev/null
+++ b/db/post_migrate/20211209093636_track_ci_job_artifacts_deletes.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackCiJobArtifactsDeletes < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:ci_job_artifacts)
+ end
+
+ def down
+ untrack_record_deletions(:ci_job_artifacts)
+ end
+end
diff --git a/db/post_migrate/20211209093828_track_users_deletes.rb b/db/post_migrate/20211209093828_track_users_deletes.rb
new file mode 100644
index 00000000000..e25a8a36cb2
--- /dev/null
+++ b/db/post_migrate/20211209093828_track_users_deletes.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackUsersDeletes < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:users)
+ end
+
+ def down
+ untrack_record_deletions(:users)
+ end
+end
diff --git a/db/post_migrate/20211209093923_track_external_pull_requests_deletes.rb b/db/post_migrate/20211209093923_track_external_pull_requests_deletes.rb
new file mode 100644
index 00000000000..cd8a6baf407
--- /dev/null
+++ b/db/post_migrate/20211209093923_track_external_pull_requests_deletes.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackExternalPullRequestsDeletes < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:external_pull_requests)
+ end
+
+ def down
+ untrack_record_deletions(:external_pull_requests)
+ end
+end
diff --git a/db/post_migrate/20211209094222_track_merge_requests_deletes.rb b/db/post_migrate/20211209094222_track_merge_requests_deletes.rb
new file mode 100644
index 00000000000..51007082e9e
--- /dev/null
+++ b/db/post_migrate/20211209094222_track_merge_requests_deletes.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class TrackMergeRequestsDeletes < Gitlab::Database::Migration[1.0]
+ include Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers
+
+ enable_lock_retries!
+
+ def up
+ track_record_deletions(:merge_requests)
+ end
+
+ def down
+ untrack_record_deletions(:merge_requests)
+ end
+end
diff --git a/db/post_migrate/20211210173137_remove_vulnerability_finding_links_again.rb b/db/post_migrate/20211210173137_remove_vulnerability_finding_links_again.rb
new file mode 100644
index 00000000000..98ac4433193
--- /dev/null
+++ b/db/post_migrate/20211210173137_remove_vulnerability_finding_links_again.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class RemoveVulnerabilityFindingLinksAgain < Gitlab::Database::Migration[1.0]
+ BATCH_SIZE = 50_000
+ MIGRATION = 'RemoveVulnerabilityFindingLinks'
+
+ disable_ddl_transaction!
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('vulnerability_finding_links'),
+ MIGRATION,
+ 2.minutes,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ def down
+ # no ops
+ end
+end
diff --git a/db/post_migrate/20211213064821_add_agent_id_location_index_to_vulnerability_occurrences.rb b/db/post_migrate/20211213064821_add_agent_id_location_index_to_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..92b5a1b085c
--- /dev/null
+++ b/db/post_migrate/20211213064821_add_agent_id_location_index_to_vulnerability_occurrences.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddAgentIdLocationIndexToVulnerabilityOccurrences < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_vulnerability_occurrences_on_location_agent_id'
+
+ def up
+ add_concurrent_index :vulnerability_occurrences, "(location -> 'agent_id')",
+ using: 'GIN',
+ where: 'report_type = 7',
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20211213102111_drop_ci_pipelines_mr_metrics_fk.rb b/db/post_migrate/20211213102111_drop_ci_pipelines_mr_metrics_fk.rb
new file mode 100644
index 00000000000..49f498c911d
--- /dev/null
+++ b/db/post_migrate/20211213102111_drop_ci_pipelines_mr_metrics_fk.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DropCiPipelinesMrMetricsFk < Gitlab::Database::Migration[1.0]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(:merge_request_metrics, :ci_pipelines, name: "fk_rails_33ae169d48")
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key(:merge_request_metrics, :ci_pipelines, name: "fk_rails_33ae169d48", column: :pipeline_id, target_column: :id, on_delete: "cascade")
+ end
+end
diff --git a/db/post_migrate/20211215090620_schedule_update_timelogs_null_spent_at.rb b/db/post_migrate/20211215090620_schedule_update_timelogs_null_spent_at.rb
new file mode 100644
index 00000000000..5876d3f8a9a
--- /dev/null
+++ b/db/post_migrate/20211215090620_schedule_update_timelogs_null_spent_at.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class ScheduleUpdateTimelogsNullSpentAt < Gitlab::Database::Migration[1.0]
+ DOWNTIME = false
+ BATCH_SIZE = 5_000
+ DELAY_INTERVAL = 2.minutes
+ MIGRATION = 'UpdateTimelogsNullSpentAt'
+
+ disable_ddl_transaction!
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('timelogs').where(spent_at: nil),
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/schema_migrations/20210713042000 b/db/schema_migrations/20210713042000
new file mode 100644
index 00000000000..ed775d6e188
--- /dev/null
+++ b/db/schema_migrations/20210713042000
@@ -0,0 +1 @@
+ede336cca4f5d692fb9fccb60db7846a917d887412a10699e818a6caf0ef6a45 \ No newline at end of file
diff --git a/db/schema_migrations/20211008043855 b/db/schema_migrations/20211008043855
new file mode 100644
index 00000000000..0abc8393efa
--- /dev/null
+++ b/db/schema_migrations/20211008043855
@@ -0,0 +1 @@
+166ae24ae4856488c81a71c650dca038c8cd7cb2221545e84431e118da097688 \ No newline at end of file
diff --git a/db/schema_migrations/20211011140930 b/db/schema_migrations/20211011140930
new file mode 100644
index 00000000000..6347ee5d51d
--- /dev/null
+++ b/db/schema_migrations/20211011140930
@@ -0,0 +1 @@
+cdae819e8de3b5ad721014376bfd9af97a45e953e2d345daf62784f986a5eb31 \ No newline at end of file
diff --git a/db/schema_migrations/20211011140931 b/db/schema_migrations/20211011140931
new file mode 100644
index 00000000000..c959d97074e
--- /dev/null
+++ b/db/schema_migrations/20211011140931
@@ -0,0 +1 @@
+7e51eb4443fd74da9bef4d9c1c3cc40376c311abbc05ca7871f725fada79b48a \ No newline at end of file
diff --git a/db/schema_migrations/20211011140932 b/db/schema_migrations/20211011140932
new file mode 100644
index 00000000000..af0e000b9f3
--- /dev/null
+++ b/db/schema_migrations/20211011140932
@@ -0,0 +1 @@
+0209db1e7be48bcbf0e52b451d37da0ef2ecadd567cdfa47907fc5032c258a27 \ No newline at end of file
diff --git a/db/schema_migrations/20211011141239 b/db/schema_migrations/20211011141239
new file mode 100644
index 00000000000..f215f234a7e
--- /dev/null
+++ b/db/schema_migrations/20211011141239
@@ -0,0 +1 @@
+bc0ae055b331801fbe020c12a66e4e6ae790780121bfd66fd161093c94c7a84a \ No newline at end of file
diff --git a/db/schema_migrations/20211011141242 b/db/schema_migrations/20211011141242
new file mode 100644
index 00000000000..01d082a4bc8
--- /dev/null
+++ b/db/schema_migrations/20211011141242
@@ -0,0 +1 @@
+9fd4977cdb57df827fe1a01f55a305d832ee4240d40af9396e093e3b4dbd1e33 \ No newline at end of file
diff --git a/db/schema_migrations/20211011141243 b/db/schema_migrations/20211011141243
new file mode 100644
index 00000000000..cb2df22b8d7
--- /dev/null
+++ b/db/schema_migrations/20211011141243
@@ -0,0 +1 @@
+b3ce6aa41c70cdcf8637a94c3d4d4e97730899221530f5507c4581aaf2fc3a6c \ No newline at end of file
diff --git a/db/schema_migrations/20211022214523 b/db/schema_migrations/20211022214523
new file mode 100644
index 00000000000..b47f13696b0
--- /dev/null
+++ b/db/schema_migrations/20211022214523
@@ -0,0 +1 @@
+b372da05f40fa67680b6a28ddf9bed3dc4b95795c144bf4367e4826b5cd64d6b \ No newline at end of file
diff --git a/db/schema_migrations/20211023102243 b/db/schema_migrations/20211023102243
new file mode 100644
index 00000000000..ec507da6b47
--- /dev/null
+++ b/db/schema_migrations/20211023102243
@@ -0,0 +1 @@
+f5039be0bd028dab4f2623fe9997a95d50bd9020ffd8b92074418024cda39b6a \ No newline at end of file
diff --git a/db/schema_migrations/20211027043206 b/db/schema_migrations/20211027043206
new file mode 100644
index 00000000000..7387484a118
--- /dev/null
+++ b/db/schema_migrations/20211027043206
@@ -0,0 +1 @@
+543feeedace6596d63207738829dcd62249a9f048a08928fbe4131ec69058322 \ No newline at end of file
diff --git a/db/schema_migrations/20211027043229 b/db/schema_migrations/20211027043229
new file mode 100644
index 00000000000..75c99cb5491
--- /dev/null
+++ b/db/schema_migrations/20211027043229
@@ -0,0 +1 @@
+2bceb12bdb90052cc8c1aedbd52c11cb8125471e1b59de3d75ef476fc64851c9 \ No newline at end of file
diff --git a/db/schema_migrations/20211101165656 b/db/schema_migrations/20211101165656
new file mode 100644
index 00000000000..6886ce7b564
--- /dev/null
+++ b/db/schema_migrations/20211101165656
@@ -0,0 +1 @@
+853e68aa974f49b7ab9f60acc0191da47598db115748e96752145c3cea89a986 \ No newline at end of file
diff --git a/db/schema_migrations/20211101222614 b/db/schema_migrations/20211101222614
new file mode 100644
index 00000000000..619ca607a75
--- /dev/null
+++ b/db/schema_migrations/20211101222614
@@ -0,0 +1 @@
+a579b14aff1d186d89173e383442f2ffbd69b1baed3f9a4c758fbb001b445139 \ No newline at end of file
diff --git a/db/schema_migrations/20211103141403 b/db/schema_migrations/20211103141403
new file mode 100644
index 00000000000..357a24ae4bb
--- /dev/null
+++ b/db/schema_migrations/20211103141403
@@ -0,0 +1 @@
+d16d62b2984586540a99aa5fc67de6459a4cd473089ddbae8d45e8783863d78d \ No newline at end of file
diff --git a/db/schema_migrations/20211104165220 b/db/schema_migrations/20211104165220
new file mode 100644
index 00000000000..abfa37a45a4
--- /dev/null
+++ b/db/schema_migrations/20211104165220
@@ -0,0 +1 @@
+52625ff0a6117724cc1d7c6417ef95fe8dbcbb394486bb4734e28d3b41d23fd2 \ No newline at end of file
diff --git a/db/schema_migrations/20211108204736 b/db/schema_migrations/20211108204736
new file mode 100644
index 00000000000..6d37b1b1184
--- /dev/null
+++ b/db/schema_migrations/20211108204736
@@ -0,0 +1 @@
+9e01b1817e4c578f5be7d7378dc12a8535c2bbbff5ecbc77f5a7cfdb148927f5 \ No newline at end of file
diff --git a/db/schema_migrations/20211110014701 b/db/schema_migrations/20211110014701
new file mode 100644
index 00000000000..fe3721eb055
--- /dev/null
+++ b/db/schema_migrations/20211110014701
@@ -0,0 +1 @@
+1c5f65a25c9cf81a50bd9ffa2e74e2621cff04e58a2f90b19c66741ebb459d3e \ No newline at end of file
diff --git a/db/schema_migrations/20211110015252 b/db/schema_migrations/20211110015252
new file mode 100644
index 00000000000..06a6a5b0ad7
--- /dev/null
+++ b/db/schema_migrations/20211110015252
@@ -0,0 +1 @@
+4038c269ce9c47ca9327fb1b81bb588e9065f0821f291d17c7965d7f8fe1f275 \ No newline at end of file
diff --git a/db/schema_migrations/20211110092710 b/db/schema_migrations/20211110092710
new file mode 100644
index 00000000000..691194456d4
--- /dev/null
+++ b/db/schema_migrations/20211110092710
@@ -0,0 +1 @@
+f6312d56d2ac77537383c8671d73ad202fed9bb8eddba4bdb24d19dbe821cdf3 \ No newline at end of file
diff --git a/db/schema_migrations/20211110143306 b/db/schema_migrations/20211110143306
new file mode 100644
index 00000000000..e1618c07f75
--- /dev/null
+++ b/db/schema_migrations/20211110143306
@@ -0,0 +1 @@
+7724e5a2c52be99b1b40c449f25abdc23f279f5b0bdaebcfd897c39d295fda41 \ No newline at end of file
diff --git a/db/schema_migrations/20211110151320 b/db/schema_migrations/20211110151320
new file mode 100644
index 00000000000..91f780811c3
--- /dev/null
+++ b/db/schema_migrations/20211110151320
@@ -0,0 +1 @@
+dab6123f19fb44a1566a8de9c760dedec5548dd64e472a180e7748cd7c93eea9 \ No newline at end of file
diff --git a/db/schema_migrations/20211110151350 b/db/schema_migrations/20211110151350
new file mode 100644
index 00000000000..98d590c26e9
--- /dev/null
+++ b/db/schema_migrations/20211110151350
@@ -0,0 +1 @@
+f5e69502e582c5f30ba686f8b668d8f0ce5cf8078b0833d2eda67f5ed97ac074 \ No newline at end of file
diff --git a/db/schema_migrations/20211111112425 b/db/schema_migrations/20211111112425
new file mode 100644
index 00000000000..5201a7d3156
--- /dev/null
+++ b/db/schema_migrations/20211111112425
@@ -0,0 +1 @@
+0ab93a0bfd52d6c13203a0b183b2fcb9d6770334e5b1bd00a28fb623b65c428d \ No newline at end of file
diff --git a/db/schema_migrations/20211111112639 b/db/schema_migrations/20211111112639
new file mode 100644
index 00000000000..e05cba2db8a
--- /dev/null
+++ b/db/schema_migrations/20211111112639
@@ -0,0 +1 @@
+870100261e3704522d390885b8ff13ebbcb093aa508d79b90f9738f6a0fffd10 \ No newline at end of file
diff --git a/db/schema_migrations/20211111112713 b/db/schema_migrations/20211111112713
new file mode 100644
index 00000000000..368378c28b8
--- /dev/null
+++ b/db/schema_migrations/20211111112713
@@ -0,0 +1 @@
+0cc2f19a8e31d9418ffd4fa1307f5210f0f2d781b957d417f06e19aca0b53985 \ No newline at end of file
diff --git a/db/schema_migrations/20211111164025 b/db/schema_migrations/20211111164025
new file mode 100644
index 00000000000..409cc160b9e
--- /dev/null
+++ b/db/schema_migrations/20211111164025
@@ -0,0 +1 @@
+d78fe687517e14ff67dc76eff63391e33b73d29446d2a0445595175c7cd6806a \ No newline at end of file
diff --git a/db/schema_migrations/20211111164047 b/db/schema_migrations/20211111164047
new file mode 100644
index 00000000000..30e0875cf73
--- /dev/null
+++ b/db/schema_migrations/20211111164047
@@ -0,0 +1 @@
+c8ed7f8c0f818156dba9c25be848da97d4eb6dbf0aa9c48f87e940f3ca0967d9 \ No newline at end of file
diff --git a/db/schema_migrations/20211112073413 b/db/schema_migrations/20211112073413
new file mode 100644
index 00000000000..11551bb5819
--- /dev/null
+++ b/db/schema_migrations/20211112073413
@@ -0,0 +1 @@
+8960c0a2b7e621e466fde3bde6a252119008579c058046a16d57a6f6bff42008 \ No newline at end of file
diff --git a/db/schema_migrations/20211115132613 b/db/schema_migrations/20211115132613
new file mode 100644
index 00000000000..be6f19bdc70
--- /dev/null
+++ b/db/schema_migrations/20211115132613
@@ -0,0 +1 @@
+a9cc7d1fc3317958ecda959b62b42f93b2609c4e784566f9696fef51c5ebdf3b \ No newline at end of file
diff --git a/db/schema_migrations/20211115142803 b/db/schema_migrations/20211115142803
new file mode 100644
index 00000000000..0e9022f7c0e
--- /dev/null
+++ b/db/schema_migrations/20211115142803
@@ -0,0 +1 @@
+52fd12693481ae7e08eb084ef679434592538d99117c1906f30ca6a36b12a212 \ No newline at end of file
diff --git a/db/schema_migrations/20211115142847 b/db/schema_migrations/20211115142847
new file mode 100644
index 00000000000..049efcf8bcf
--- /dev/null
+++ b/db/schema_migrations/20211115142847
@@ -0,0 +1 @@
+cded37f94d578a503e5b389e6483ec68666983f71395c13b4f0011db04e807c3 \ No newline at end of file
diff --git a/db/schema_migrations/20211115142911 b/db/schema_migrations/20211115142911
new file mode 100644
index 00000000000..43bae5192c5
--- /dev/null
+++ b/db/schema_migrations/20211115142911
@@ -0,0 +1 @@
+63141e62fc21cf0a4b47355ecd3814c1f0cc829b7f4851d833f95369206c8919 \ No newline at end of file
diff --git a/db/schema_migrations/20211115145107 b/db/schema_migrations/20211115145107
new file mode 100644
index 00000000000..25270a5c587
--- /dev/null
+++ b/db/schema_migrations/20211115145107
@@ -0,0 +1 @@
+2b6bc8067402744b79eee06022cf3c91ba7ffd519df83aae4067600a6bbf43ad \ No newline at end of file
diff --git a/db/schema_migrations/20211115154103 b/db/schema_migrations/20211115154103
new file mode 100644
index 00000000000..2b721bc7b39
--- /dev/null
+++ b/db/schema_migrations/20211115154103
@@ -0,0 +1 @@
+ad65e6deb885397dc91f33dc117a50e9a1b6d60f4caed8c5b77d474ec0340995 \ No newline at end of file
diff --git a/db/schema_migrations/20211116091751 b/db/schema_migrations/20211116091751
new file mode 100644
index 00000000000..8b13b53e437
--- /dev/null
+++ b/db/schema_migrations/20211116091751
@@ -0,0 +1 @@
+d71889bba2150265e9482be0b5ee89f43168d4a35b47469a36873d65f00df878 \ No newline at end of file
diff --git a/db/schema_migrations/20211116093739 b/db/schema_migrations/20211116093739
new file mode 100644
index 00000000000..b0ded3f2a0f
--- /dev/null
+++ b/db/schema_migrations/20211116093739
@@ -0,0 +1 @@
+39d1988fe409944877df24e9859b171eab13c4a4703c8e85a2bff33318fb61fc \ No newline at end of file
diff --git a/db/schema_migrations/20211116111644 b/db/schema_migrations/20211116111644
new file mode 100644
index 00000000000..c2bc9dbee0d
--- /dev/null
+++ b/db/schema_migrations/20211116111644
@@ -0,0 +1 @@
+664c7fa75d3283b6e984fcca4ffcefab6dba24a78e4cc24ac86f791ab4495def \ No newline at end of file
diff --git a/db/schema_migrations/20211117084814 b/db/schema_migrations/20211117084814
new file mode 100644
index 00000000000..d24eb0a0c04
--- /dev/null
+++ b/db/schema_migrations/20211117084814
@@ -0,0 +1 @@
+d6b0ca9d1e88e9e531ee0da5c82723309d746b6d83ea5dfb8326d3cc718a31b6 \ No newline at end of file
diff --git a/db/schema_migrations/20211117174209 b/db/schema_migrations/20211117174209
new file mode 100644
index 00000000000..f5e8cd180c2
--- /dev/null
+++ b/db/schema_migrations/20211117174209
@@ -0,0 +1 @@
+c7c29b136fbe00271807fcd3133baf7a6e9ded40989fc274e941fc99f2c19e4d \ No newline at end of file
diff --git a/db/schema_migrations/20211118100959 b/db/schema_migrations/20211118100959
new file mode 100644
index 00000000000..e3c42353b8d
--- /dev/null
+++ b/db/schema_migrations/20211118100959
@@ -0,0 +1 @@
+8b1bb9758150151518f16307d3f145431000b7edf946fd44e54cf7301087b002 \ No newline at end of file
diff --git a/db/schema_migrations/20211118103439 b/db/schema_migrations/20211118103439
new file mode 100644
index 00000000000..5b5891c3b16
--- /dev/null
+++ b/db/schema_migrations/20211118103439
@@ -0,0 +1 @@
+721f1ada9fe5a3d7e5da3750a43d5021a85a26e8adc4d649e7f0fff8cdf68344 \ No newline at end of file
diff --git a/db/schema_migrations/20211118114228 b/db/schema_migrations/20211118114228
new file mode 100644
index 00000000000..82c7984750d
--- /dev/null
+++ b/db/schema_migrations/20211118114228
@@ -0,0 +1 @@
+7686fd3e33b25b811aba459aba514cde8e88102277edb3be7e12378cb7e8de85 \ No newline at end of file
diff --git a/db/schema_migrations/20211118124537 b/db/schema_migrations/20211118124537
new file mode 100644
index 00000000000..537c3aa88fa
--- /dev/null
+++ b/db/schema_migrations/20211118124537
@@ -0,0 +1 @@
+d9a0886d95cd54add9e63475a2f1ca0601304bb64ffe6e6d9e62cb8997d5fe40 \ No newline at end of file
diff --git a/db/schema_migrations/20211118124628 b/db/schema_migrations/20211118124628
new file mode 100644
index 00000000000..e6364327ca4
--- /dev/null
+++ b/db/schema_migrations/20211118124628
@@ -0,0 +1 @@
+f25ee0df287f1c44740be143831537bf262d09d7068ceca1c516ee964bc3aa24 \ No newline at end of file
diff --git a/db/schema_migrations/20211118124650 b/db/schema_migrations/20211118124650
new file mode 100644
index 00000000000..739cfeb80b3
--- /dev/null
+++ b/db/schema_migrations/20211118124650
@@ -0,0 +1 @@
+e032fd334d175d803b943c6328048705e81bd70af6ac226a032281304840f1cd \ No newline at end of file
diff --git a/db/schema_migrations/20211118130836 b/db/schema_migrations/20211118130836
new file mode 100644
index 00000000000..df16d8c5c5e
--- /dev/null
+++ b/db/schema_migrations/20211118130836
@@ -0,0 +1 @@
+2630b21c7134ac539a18798f2f2b99f468e171b79e30a184f7e8cdaccd11d465 \ No newline at end of file
diff --git a/db/schema_migrations/20211118194239 b/db/schema_migrations/20211118194239
new file mode 100644
index 00000000000..ce3c1eb83d1
--- /dev/null
+++ b/db/schema_migrations/20211118194239
@@ -0,0 +1 @@
+04a4b10085bae2006ac78600b3cc410d130f9ac6944103c7bd85f71e060d4a67 \ No newline at end of file
diff --git a/db/schema_migrations/20211119085015 b/db/schema_migrations/20211119085015
new file mode 100644
index 00000000000..874bd158e7c
--- /dev/null
+++ b/db/schema_migrations/20211119085015
@@ -0,0 +1 @@
+88b289d724f98f75e0340cde4c6e2bc3cb55df2a979934fb2bc544d22e4c032d \ No newline at end of file
diff --git a/db/schema_migrations/20211119085036 b/db/schema_migrations/20211119085036
new file mode 100644
index 00000000000..f9d1eeffbcb
--- /dev/null
+++ b/db/schema_migrations/20211119085036
@@ -0,0 +1 @@
+2b2c28e0370ae1bb84bee5ff769c9b313902d1f1afc50fa54e23a1627b1121f3 \ No newline at end of file
diff --git a/db/schema_migrations/20211119154221 b/db/schema_migrations/20211119154221
new file mode 100644
index 00000000000..c8b6005b48b
--- /dev/null
+++ b/db/schema_migrations/20211119154221
@@ -0,0 +1 @@
+020e17ffd6851fb861a17c1b120ca7cdfa300434d4a9ec923a4edcaa7f951b31 \ No newline at end of file
diff --git a/db/schema_migrations/20211119170805 b/db/schema_migrations/20211119170805
new file mode 100644
index 00000000000..fffb02d4285
--- /dev/null
+++ b/db/schema_migrations/20211119170805
@@ -0,0 +1 @@
+adb95bc78104382fb1d3af2c2775b4b5bd23394b4260c3a97667b4bd7917e0da \ No newline at end of file
diff --git a/db/schema_migrations/20211119194024 b/db/schema_migrations/20211119194024
new file mode 100644
index 00000000000..0d90b09e732
--- /dev/null
+++ b/db/schema_migrations/20211119194024
@@ -0,0 +1 @@
+ac2e376ad32f0e2fd45d8695f13a0b46c2d5964b881f79e3a30a51ac85d4359b \ No newline at end of file
diff --git a/db/schema_migrations/20211119195201 b/db/schema_migrations/20211119195201
new file mode 100644
index 00000000000..dd7f7b83d8d
--- /dev/null
+++ b/db/schema_migrations/20211119195201
@@ -0,0 +1 @@
+caaf92f12bf0ed144d99f629c9e5d64fd45832a90bbd743e40febcdc4802cd59 \ No newline at end of file
diff --git a/db/schema_migrations/20211122033501 b/db/schema_migrations/20211122033501
new file mode 100644
index 00000000000..08673370b57
--- /dev/null
+++ b/db/schema_migrations/20211122033501
@@ -0,0 +1 @@
+e010b4c12ae8203d9ea8a4c2035be5e7165aba0030f4d5fd0b0f978f84748707 \ No newline at end of file
diff --git a/db/schema_migrations/20211122193948 b/db/schema_migrations/20211122193948
new file mode 100644
index 00000000000..94dbab4cd73
--- /dev/null
+++ b/db/schema_migrations/20211122193948
@@ -0,0 +1 @@
+12203afb7b66a12946d971dd601d2ce91e1408fcdf36d9d8b2fadcf09d7c1e56 \ No newline at end of file
diff --git a/db/schema_migrations/20211122215001 b/db/schema_migrations/20211122215001
new file mode 100644
index 00000000000..be0fd652eb7
--- /dev/null
+++ b/db/schema_migrations/20211122215001
@@ -0,0 +1 @@
+fc29e10717357f7dd57940042d69a6c43a0d17fdf3c951917a76eae8c1d93ba3 \ No newline at end of file
diff --git a/db/schema_migrations/20211123181236 b/db/schema_migrations/20211123181236
new file mode 100644
index 00000000000..25f00af5d72
--- /dev/null
+++ b/db/schema_migrations/20211123181236
@@ -0,0 +1 @@
+ac21109099642d5934c16b3f0130736a587c4f20143552545c2b524062ff71e0 \ No newline at end of file
diff --git a/db/schema_migrations/20211123182614 b/db/schema_migrations/20211123182614
new file mode 100644
index 00000000000..8b67ec7cd26
--- /dev/null
+++ b/db/schema_migrations/20211123182614
@@ -0,0 +1 @@
+9a3ba69a1df02059b240393cc381c4a5ba9db0f116818aa9f3d4f1009f055b09 \ No newline at end of file
diff --git a/db/schema_migrations/20211124132319 b/db/schema_migrations/20211124132319
new file mode 100644
index 00000000000..1809d13a553
--- /dev/null
+++ b/db/schema_migrations/20211124132319
@@ -0,0 +1 @@
+cdb85c8633687338a11ebce0603f82f5cab00e7c58f923d30b68a877b94e2db2 \ No newline at end of file
diff --git a/db/schema_migrations/20211124132705 b/db/schema_migrations/20211124132705
new file mode 100644
index 00000000000..12e3f08365b
--- /dev/null
+++ b/db/schema_migrations/20211124132705
@@ -0,0 +1 @@
+4eacad00017890c71f3354d80061fae7af40499256475cdf035bdf41b916e5f3 \ No newline at end of file
diff --git a/db/schema_migrations/20211125120444 b/db/schema_migrations/20211125120444
new file mode 100644
index 00000000000..8dca57e74ef
--- /dev/null
+++ b/db/schema_migrations/20211125120444
@@ -0,0 +1 @@
+19062282d022e5d93cd525cff44c67f1fbc5557f1201e523a57725dc0b6ecd70 \ No newline at end of file
diff --git a/db/schema_migrations/20211126042235 b/db/schema_migrations/20211126042235
new file mode 100644
index 00000000000..8c34dd173a9
--- /dev/null
+++ b/db/schema_migrations/20211126042235
@@ -0,0 +1 @@
+c6992d23fc43c26861accf7c516603802c95367460ad688d1a420a60a33833f1 \ No newline at end of file
diff --git a/db/schema_migrations/20211126113029 b/db/schema_migrations/20211126113029
new file mode 100644
index 00000000000..aaf1a421982
--- /dev/null
+++ b/db/schema_migrations/20211126113029
@@ -0,0 +1 @@
+96abde258e6527a2b09bb60e1cc0cb90802c8a7e43a2132e9956536390a8aab8 \ No newline at end of file
diff --git a/db/schema_migrations/20211126115449 b/db/schema_migrations/20211126115449
new file mode 100644
index 00000000000..693dfb46149
--- /dev/null
+++ b/db/schema_migrations/20211126115449
@@ -0,0 +1 @@
+2e6e432ecf7b2c885905fd4df6b57fa99b324f56cb0850d9fc792b4a9b363423 \ No newline at end of file
diff --git a/db/schema_migrations/20211126142200 b/db/schema_migrations/20211126142200
new file mode 100644
index 00000000000..136addef509
--- /dev/null
+++ b/db/schema_migrations/20211126142200
@@ -0,0 +1 @@
+a00ce6a11c7671b6d2efe47e3859afaec72c437fdf5383b990ee09cf14081c9b \ No newline at end of file
diff --git a/db/schema_migrations/20211126142354 b/db/schema_migrations/20211126142354
new file mode 100644
index 00000000000..fc84b266263
--- /dev/null
+++ b/db/schema_migrations/20211126142354
@@ -0,0 +1 @@
+31d5fa3caff916a485f26b6834e37037455068cdcf502802196bf1d663716f49 \ No newline at end of file
diff --git a/db/schema_migrations/20211126204445 b/db/schema_migrations/20211126204445
new file mode 100644
index 00000000000..b130d90b8ec
--- /dev/null
+++ b/db/schema_migrations/20211126204445
@@ -0,0 +1 @@
+e31592bbeb6ba6175f19cfceaafb37672633028dd021052542909999b46eac38 \ No newline at end of file
diff --git a/db/schema_migrations/20211129151155 b/db/schema_migrations/20211129151155
new file mode 100644
index 00000000000..4aa3e56bae6
--- /dev/null
+++ b/db/schema_migrations/20211129151155
@@ -0,0 +1 @@
+c1ba97f01fca6330628090010abb54220c0d057514386c6bb867c1b6f13f252c \ No newline at end of file
diff --git a/db/schema_migrations/20211129151832 b/db/schema_migrations/20211129151832
new file mode 100644
index 00000000000..fdfc464d136
--- /dev/null
+++ b/db/schema_migrations/20211129151832
@@ -0,0 +1 @@
+c6d257f635049f88cd6efba903c9384a0a1af23b3c8fe6fa7f0842dcdf9f7e39 \ No newline at end of file
diff --git a/db/schema_migrations/20211130151724 b/db/schema_migrations/20211130151724
new file mode 100644
index 00000000000..090d49ca482
--- /dev/null
+++ b/db/schema_migrations/20211130151724
@@ -0,0 +1 @@
+f9bd521c92558ba9ad3cfa3fd6ff1a647847c0fc767e1e4f45b43422542d5cc7 \ No newline at end of file
diff --git a/db/schema_migrations/20211130165043 b/db/schema_migrations/20211130165043
new file mode 100644
index 00000000000..3d4f7b52a69
--- /dev/null
+++ b/db/schema_migrations/20211130165043
@@ -0,0 +1 @@
+2eece823b66fec7f5a9a5c24b93d354a47939a7cdd915349a433b7bbec6abc22 \ No newline at end of file
diff --git a/db/schema_migrations/20211130201100 b/db/schema_migrations/20211130201100
new file mode 100644
index 00000000000..80c2d68671b
--- /dev/null
+++ b/db/schema_migrations/20211130201100
@@ -0,0 +1 @@
+cc0146769929c9fbb0b7b6788826d2e188c8664a14e1015563ba4f9e65397c4e \ No newline at end of file
diff --git a/db/schema_migrations/20211130201101 b/db/schema_migrations/20211130201101
new file mode 100644
index 00000000000..ef1178c10c5
--- /dev/null
+++ b/db/schema_migrations/20211130201101
@@ -0,0 +1 @@
+b0215ac45031593ca98de4f8858d21f1c29af03742a422bffd83598e39a6871c \ No newline at end of file
diff --git a/db/schema_migrations/20211130205719 b/db/schema_migrations/20211130205719
new file mode 100644
index 00000000000..aae23faabc9
--- /dev/null
+++ b/db/schema_migrations/20211130205719
@@ -0,0 +1 @@
+567a80916756adcca93bdbe82d69a923e539aac74146e714b58a1b023134d2c9 \ No newline at end of file
diff --git a/db/schema_migrations/20211201061733 b/db/schema_migrations/20211201061733
new file mode 100644
index 00000000000..722e7dd828c
--- /dev/null
+++ b/db/schema_migrations/20211201061733
@@ -0,0 +1 @@
+c5282e48f31c0896a3ce21fe238eb602dc006b0bfe62aa4f12ee39bbd620c76c \ No newline at end of file
diff --git a/db/schema_migrations/20211201101541 b/db/schema_migrations/20211201101541
new file mode 100644
index 00000000000..52f43ddcd2f
--- /dev/null
+++ b/db/schema_migrations/20211201101541
@@ -0,0 +1 @@
+277cfcd1002e32c6cd664d6c0b6a7cbdf2ed7e5242e46dbddc4f99b0e8422361 \ No newline at end of file
diff --git a/db/schema_migrations/20211201143042 b/db/schema_migrations/20211201143042
new file mode 100644
index 00000000000..a5f0c8be842
--- /dev/null
+++ b/db/schema_migrations/20211201143042
@@ -0,0 +1 @@
+0d27ca1250d10b8915fa4523707044f9a8c2372110537f5639a1811aeb0858b8 \ No newline at end of file
diff --git a/db/schema_migrations/20211202041233 b/db/schema_migrations/20211202041233
new file mode 100644
index 00000000000..fb19264fbd5
--- /dev/null
+++ b/db/schema_migrations/20211202041233
@@ -0,0 +1 @@
+61c949b42338b248a0950cfafc82d58816c3fec44a2bf41c4ecb4cf09340a424 \ No newline at end of file
diff --git a/db/schema_migrations/20211202094944 b/db/schema_migrations/20211202094944
new file mode 100644
index 00000000000..b917cca67fa
--- /dev/null
+++ b/db/schema_migrations/20211202094944
@@ -0,0 +1 @@
+2bca61880005c9303b2ff71747cde64d3418b6ef8ad2a9f114d584f4149e386b \ No newline at end of file
diff --git a/db/schema_migrations/20211202135508 b/db/schema_migrations/20211202135508
new file mode 100644
index 00000000000..6ca4701268d
--- /dev/null
+++ b/db/schema_migrations/20211202135508
@@ -0,0 +1 @@
+b565abbbb43f04ba4a6b77154ecb24b30328ac6d964f4be9fc5f9d05144606f0 \ No newline at end of file
diff --git a/db/schema_migrations/20211202145237 b/db/schema_migrations/20211202145237
new file mode 100644
index 00000000000..f5b91a189c8
--- /dev/null
+++ b/db/schema_migrations/20211202145237
@@ -0,0 +1 @@
+d109142aa838faedcd307f6cd235c969ca265813493eef50d63cbc2fe5d203b3 \ No newline at end of file
diff --git a/db/schema_migrations/20211203091642 b/db/schema_migrations/20211203091642
new file mode 100644
index 00000000000..ef53b1d2ed9
--- /dev/null
+++ b/db/schema_migrations/20211203091642
@@ -0,0 +1 @@
+9954fb041a3f284f53cc9c5c68b1a9dff36513a1851e663c221eccd40736fb16 \ No newline at end of file
diff --git a/db/schema_migrations/20211204010826 b/db/schema_migrations/20211204010826
new file mode 100644
index 00000000000..11311e66ad0
--- /dev/null
+++ b/db/schema_migrations/20211204010826
@@ -0,0 +1 @@
+6a3591e70ddd6573ad68360c1a8774ef61e7812ce831c75066baec5754e2bd76 \ No newline at end of file
diff --git a/db/schema_migrations/20211206073851 b/db/schema_migrations/20211206073851
new file mode 100644
index 00000000000..bfd8140b109
--- /dev/null
+++ b/db/schema_migrations/20211206073851
@@ -0,0 +1 @@
+403592fda1d82ed3c3fb8d5315593b67954a4ecbc368d9bcd5eedc75bb3c9821 \ No newline at end of file
diff --git a/db/schema_migrations/20211206074547 b/db/schema_migrations/20211206074547
new file mode 100644
index 00000000000..dd84a987827
--- /dev/null
+++ b/db/schema_migrations/20211206074547
@@ -0,0 +1 @@
+ba1c0d20e21ef51278109d0eaeb23f1c541eb5eb9aeb9a92583ee6de83c68918 \ No newline at end of file
diff --git a/db/schema_migrations/20211207090503 b/db/schema_migrations/20211207090503
new file mode 100644
index 00000000000..13daa5c81e6
--- /dev/null
+++ b/db/schema_migrations/20211207090503
@@ -0,0 +1 @@
+c30656c3f079e789f386b5b607710a7d4df6d2eb20bd457bab3a2e8d9eeb051b \ No newline at end of file
diff --git a/db/schema_migrations/20211207154413 b/db/schema_migrations/20211207154413
new file mode 100644
index 00000000000..26bc9a47632
--- /dev/null
+++ b/db/schema_migrations/20211207154413
@@ -0,0 +1 @@
+98098b41864158fc4de3b8fe42603b2c0c5c2fbc664397c431712311bdaa3621 \ No newline at end of file
diff --git a/db/schema_migrations/20211207154414 b/db/schema_migrations/20211207154414
new file mode 100644
index 00000000000..c7e1f8de4d1
--- /dev/null
+++ b/db/schema_migrations/20211207154414
@@ -0,0 +1 @@
+278907a15d04b455aa852eb9d17000c6b353be6ef78a8dcc2e71a9772a6e43ea \ No newline at end of file
diff --git a/db/schema_migrations/20211207165508 b/db/schema_migrations/20211207165508
new file mode 100644
index 00000000000..df0c91bad7d
--- /dev/null
+++ b/db/schema_migrations/20211207165508
@@ -0,0 +1 @@
+d1ed3ddf51c0bcebbac2a8dee05aa168daa35129110a463ac296ff2e640b0dbd \ No newline at end of file
diff --git a/db/schema_migrations/20211208111425 b/db/schema_migrations/20211208111425
new file mode 100644
index 00000000000..0b1aa9199b6
--- /dev/null
+++ b/db/schema_migrations/20211208111425
@@ -0,0 +1 @@
+1e3f29ed1a820588da9fe135fbdd0feaa960038b99397dbd7921d4804dce1e1f \ No newline at end of file
diff --git a/db/schema_migrations/20211208171402 b/db/schema_migrations/20211208171402
new file mode 100644
index 00000000000..a563797dea5
--- /dev/null
+++ b/db/schema_migrations/20211208171402
@@ -0,0 +1 @@
+09a9e7fc042aab19bf768a79401f33b6e7408acff303fc0ee68360dfd7605101 \ No newline at end of file
diff --git a/db/schema_migrations/20211209093636 b/db/schema_migrations/20211209093636
new file mode 100644
index 00000000000..2d2601ff51c
--- /dev/null
+++ b/db/schema_migrations/20211209093636
@@ -0,0 +1 @@
+e544953376948489daf4840d4a6228b18dc6e18d071a1025dab24c3559640489 \ No newline at end of file
diff --git a/db/schema_migrations/20211209093828 b/db/schema_migrations/20211209093828
new file mode 100644
index 00000000000..7f6b5a0c442
--- /dev/null
+++ b/db/schema_migrations/20211209093828
@@ -0,0 +1 @@
+583ee4809560fec645e6f0942b332f9ab2630d06b0a422b360c5bb546d0aad93 \ No newline at end of file
diff --git a/db/schema_migrations/20211209093923 b/db/schema_migrations/20211209093923
new file mode 100644
index 00000000000..654d4b3967e
--- /dev/null
+++ b/db/schema_migrations/20211209093923
@@ -0,0 +1 @@
+8ec578ddc956b2648bcdd8a2ce1728723e2b0eef1a0a4845f4cb0deb19c417ec \ No newline at end of file
diff --git a/db/schema_migrations/20211209094222 b/db/schema_migrations/20211209094222
new file mode 100644
index 00000000000..29156e38fe9
--- /dev/null
+++ b/db/schema_migrations/20211209094222
@@ -0,0 +1 @@
+1b461efe52d55ba9dca05e64efaae411c3de01612cbc55f9525e522e9b181b3d \ No newline at end of file
diff --git a/db/schema_migrations/20211210173137 b/db/schema_migrations/20211210173137
new file mode 100644
index 00000000000..3dfcb177167
--- /dev/null
+++ b/db/schema_migrations/20211210173137
@@ -0,0 +1 @@
+9bbd4c3e396e0de130418e705a370ce629ca507c82fa2ff5bbf085cdf01c2ff3 \ No newline at end of file
diff --git a/db/schema_migrations/20211213064821 b/db/schema_migrations/20211213064821
new file mode 100644
index 00000000000..119805a99b7
--- /dev/null
+++ b/db/schema_migrations/20211213064821
@@ -0,0 +1 @@
+9d7e85ac7c9ee2b9505c479b878cb07888cf089c04d34bdeb834fbb0c5111931 \ No newline at end of file
diff --git a/db/schema_migrations/20211213102111 b/db/schema_migrations/20211213102111
new file mode 100644
index 00000000000..214d061f265
--- /dev/null
+++ b/db/schema_migrations/20211213102111
@@ -0,0 +1 @@
+3d011cc67fc6ac661788f2d0e3766e51d624a4248ac9dbd861a4db810d396091 \ No newline at end of file
diff --git a/db/schema_migrations/20211213130324 b/db/schema_migrations/20211213130324
new file mode 100644
index 00000000000..529fe91ab5f
--- /dev/null
+++ b/db/schema_migrations/20211213130324
@@ -0,0 +1 @@
+2267855b2f12747b1f31f392677fac4d4f82ee234d7c54fd209b8bad417c8c75 \ No newline at end of file
diff --git a/db/schema_migrations/20211214110307 b/db/schema_migrations/20211214110307
new file mode 100644
index 00000000000..6e3101bbe59
--- /dev/null
+++ b/db/schema_migrations/20211214110307
@@ -0,0 +1 @@
+a1a6e3c5b4a8f959c55edbb084b37ba555b3977e450a549925de47605638f66e \ No newline at end of file
diff --git a/db/schema_migrations/20211215090620 b/db/schema_migrations/20211215090620
new file mode 100644
index 00000000000..9393ffee22e
--- /dev/null
+++ b/db/schema_migrations/20211215090620
@@ -0,0 +1 @@
+43ae6290e11e3944b23ce2865b5c466a29c9ba3cfd2e0b58bd834568414b5bf2 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 5373aa7a31e..716b3e89be1 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -27,14 +27,35 @@ CREATE FUNCTION insert_into_loose_foreign_keys_deleted_records() RETURNS trigger
AS $$
BEGIN
INSERT INTO loose_foreign_keys_deleted_records
- (partition, fully_qualified_table_name, primary_key_value)
- SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table
- ON CONFLICT DO NOTHING;
+ (fully_qualified_table_name, primary_key_value)
+ SELECT TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table;
RETURN NULL;
END
$$;
+CREATE FUNCTION insert_namespaces_sync_event() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+INSERT INTO namespaces_sync_events (namespace_id)
+VALUES(COALESCE(NEW.id, OLD.id));
+RETURN NULL;
+
+END
+$$;
+
+CREATE FUNCTION insert_projects_sync_event() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+INSERT INTO projects_sync_events (project_id)
+VALUES(COALESCE(NEW.id, OLD.id));
+RETURN NULL;
+
+END
+$$;
+
CREATE FUNCTION integrations_set_type_new() RETURNS trigger
LANGUAGE plpgsql
AS $$
@@ -126,6 +147,18 @@ CREATE TABLE incident_management_pending_issue_escalations (
)
PARTITION BY RANGE (process_at);
+CREATE TABLE loose_foreign_keys_deleted_records (
+ id bigint NOT NULL,
+ partition bigint DEFAULT 1 NOT NULL,
+ primary_key_value bigint NOT NULL,
+ status smallint DEFAULT 1 NOT NULL,
+ created_at timestamp with time zone DEFAULT now() NOT NULL,
+ fully_qualified_table_name text NOT NULL,
+ consume_after timestamp with time zone DEFAULT now(),
+ CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150))
+)
+PARTITION BY LIST (partition);
+
CREATE TABLE verification_codes (
created_at timestamp with time zone DEFAULT now() NOT NULL,
visitor_id_code text NOT NULL,
@@ -1014,39 +1047,6 @@ CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_st
);
ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_31 FOR VALUES WITH (modulus 32, remainder 31);
-CREATE TABLE loose_foreign_keys_deleted_records (
- id bigint NOT NULL,
- partition bigint NOT NULL,
- primary_key_value bigint NOT NULL,
- status smallint DEFAULT 1 NOT NULL,
- created_at timestamp with time zone DEFAULT now() NOT NULL,
- fully_qualified_table_name text NOT NULL,
- consume_after timestamp with time zone DEFAULT now(),
- CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150))
-)
-PARTITION BY LIST (partition);
-
-CREATE SEQUENCE loose_foreign_keys_deleted_records_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE loose_foreign_keys_deleted_records_id_seq OWNED BY loose_foreign_keys_deleted_records.id;
-
-CREATE TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1 (
- id bigint DEFAULT nextval('loose_foreign_keys_deleted_records_id_seq'::regclass) NOT NULL,
- partition bigint NOT NULL,
- primary_key_value bigint NOT NULL,
- status smallint DEFAULT 1 NOT NULL,
- created_at timestamp with time zone DEFAULT now() NOT NULL,
- fully_qualified_table_name text NOT NULL,
- consume_after timestamp with time zone DEFAULT now(),
- CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150))
-);
-ALTER TABLE ONLY loose_foreign_keys_deleted_records ATTACH PARTITION gitlab_partitions_static.loose_foreign_keys_deleted_records_1 FOR VALUES IN ('1');
-
CREATE TABLE product_analytics_events_experimental (
id bigint NOT NULL,
project_id integer NOT NULL,
@@ -9721,6 +9721,30 @@ CREATE SEQUENCE abuse_reports_id_seq
ALTER SEQUENCE abuse_reports_id_seq OWNED BY abuse_reports.id;
+CREATE TABLE agent_activity_events (
+ id bigint NOT NULL,
+ agent_id bigint NOT NULL,
+ user_id bigint,
+ project_id bigint,
+ merge_request_id bigint,
+ agent_token_id bigint,
+ recorded_at timestamp with time zone NOT NULL,
+ kind smallint NOT NULL,
+ level smallint NOT NULL,
+ sha bytea,
+ detail text,
+ CONSTRAINT check_068205e735 CHECK ((char_length(detail) <= 255))
+);
+
+CREATE SEQUENCE agent_activity_events_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE agent_activity_events_id_seq OWNED BY agent_activity_events.id;
+
CREATE TABLE agent_group_authorizations (
id bigint NOT NULL,
group_id bigint NOT NULL,
@@ -10454,6 +10478,9 @@ CREATE TABLE application_settings (
sentry_dsn text,
sentry_clientside_dsn text,
sentry_environment text,
+ max_ssh_key_lifetime integer,
+ static_objects_external_storage_auth_token_encrypted text,
+ future_subscriptions jsonb DEFAULT '[]'::jsonb 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_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)),
@@ -10462,6 +10489,7 @@ CREATE TABLE application_settings (
CONSTRAINT app_settings_yaml_max_size_positive CHECK ((max_yaml_size_bytes > 0)),
CONSTRAINT check_17d9558205 CHECK ((char_length((kroki_url)::text) <= 1024)),
CONSTRAINT check_2dba05b802 CHECK ((char_length(gitpod_url) <= 255)),
+ CONSTRAINT check_32710817e9 CHECK ((char_length(static_objects_external_storage_auth_token_encrypted) <= 255)),
CONSTRAINT check_3def0f1829 CHECK ((char_length(sentry_clientside_dsn) <= 255)),
CONSTRAINT check_4f8b811780 CHECK ((char_length(sentry_dsn) <= 255)),
CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)),
@@ -10524,6 +10552,7 @@ CREATE TABLE approval_merge_request_rules (
report_type smallint,
section text,
modified_from_project_rule boolean DEFAULT false NOT NULL,
+ orchestration_policy_idx smallint,
CONSTRAINT check_6fca5928b2 CHECK ((char_length(section) <= 255))
);
@@ -10593,7 +10622,8 @@ CREATE TABLE approval_project_rules (
vulnerabilities_allowed smallint DEFAULT 0 NOT NULL,
severity_levels text[] DEFAULT '{}'::text[] NOT NULL,
report_type smallint,
- vulnerability_states text[] DEFAULT '{newly_detected}'::text[] NOT NULL
+ vulnerability_states text[] DEFAULT '{newly_detected}'::text[] NOT NULL,
+ orchestration_policy_idx smallint
);
CREATE TABLE approval_project_rules_groups (
@@ -11672,7 +11702,9 @@ CREATE TABLE ci_job_artifacts (
id bigint NOT NULL,
job_id bigint NOT NULL,
locked smallint DEFAULT 2,
- CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL))
+ original_filename text,
+ CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL)),
+ CONSTRAINT check_85573000db CHECK ((char_length(original_filename) <= 512))
);
CREATE SEQUENCE ci_job_artifacts_id_seq
@@ -11740,6 +11772,21 @@ CREATE SEQUENCE ci_minutes_additional_packs_id_seq
ALTER SEQUENCE ci_minutes_additional_packs_id_seq OWNED BY ci_minutes_additional_packs.id;
+CREATE TABLE ci_namespace_mirrors (
+ id bigint NOT NULL,
+ namespace_id integer NOT NULL,
+ traversal_ids integer[] DEFAULT '{}'::integer[] NOT NULL
+);
+
+CREATE SEQUENCE ci_namespace_mirrors_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ci_namespace_mirrors_id_seq OWNED BY ci_namespace_mirrors.id;
+
CREATE TABLE ci_namespace_monthly_usages (
id bigint NOT NULL,
namespace_id bigint NOT NULL,
@@ -11748,6 +11795,7 @@ CREATE TABLE ci_namespace_monthly_usages (
amount_used numeric(18,2) DEFAULT 0.0 NOT NULL,
notification_level smallint DEFAULT 100 NOT NULL,
shared_runners_duration integer DEFAULT 0 NOT NULL,
+ created_at timestamp with time zone,
CONSTRAINT ci_namespace_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone)))
);
@@ -11987,12 +12035,28 @@ CREATE SEQUENCE ci_platform_metrics_id_seq
ALTER SEQUENCE ci_platform_metrics_id_seq OWNED BY ci_platform_metrics.id;
+CREATE TABLE ci_project_mirrors (
+ id bigint NOT NULL,
+ project_id integer NOT NULL,
+ namespace_id integer NOT NULL
+);
+
+CREATE SEQUENCE ci_project_mirrors_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE ci_project_mirrors_id_seq OWNED BY ci_project_mirrors.id;
+
CREATE TABLE ci_project_monthly_usages (
id bigint NOT NULL,
project_id bigint NOT NULL,
date date NOT NULL,
amount_used numeric(18,2) DEFAULT 0.0 NOT NULL,
shared_runners_duration integer DEFAULT 0 NOT NULL,
+ created_at timestamp with time zone,
CONSTRAINT ci_project_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone)))
);
@@ -12111,7 +12175,8 @@ CREATE TABLE ci_runners (
token_encrypted character varying,
public_projects_minutes_cost_factor double precision DEFAULT 0.0 NOT NULL,
private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
- config jsonb DEFAULT '{}'::jsonb NOT NULL
+ config jsonb DEFAULT '{}'::jsonb NOT NULL,
+ executor_type smallint
);
CREATE SEQUENCE ci_runners_id_seq
@@ -13347,6 +13412,24 @@ CREATE SEQUENCE deploy_tokens_id_seq
ALTER SEQUENCE deploy_tokens_id_seq OWNED BY deploy_tokens.id;
+CREATE TABLE deployment_approvals (
+ id bigint NOT NULL,
+ deployment_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,
+ status smallint NOT NULL
+);
+
+CREATE SEQUENCE deployment_approvals_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE deployment_approvals_id_seq OWNED BY deployment_approvals.id;
+
CREATE TABLE deployment_clusters (
deployment_id integer NOT NULL,
cluster_id integer NOT NULL,
@@ -15050,6 +15133,35 @@ CREATE SEQUENCE incident_management_pending_issue_escalations_id_seq
ALTER SEQUENCE incident_management_pending_issue_escalations_id_seq OWNED BY incident_management_pending_issue_escalations.id;
+CREATE TABLE incident_management_timeline_events (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ occurred_at timestamp with time zone NOT NULL,
+ project_id bigint NOT NULL,
+ author_id bigint,
+ issue_id bigint NOT NULL,
+ updated_by_user_id bigint,
+ promoted_from_note_id bigint,
+ cached_markdown_version integer,
+ editable boolean DEFAULT false NOT NULL,
+ note text NOT NULL,
+ note_html text NOT NULL,
+ action text NOT NULL,
+ CONSTRAINT check_18fd072206 CHECK ((char_length(action) <= 128)),
+ CONSTRAINT check_3875ed0aac CHECK ((char_length(note) <= 10000)),
+ CONSTRAINT check_94a235d6a4 CHECK ((char_length(note_html) <= 10000))
+);
+
+CREATE SEQUENCE incident_management_timeline_events_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE incident_management_timeline_events_id_seq OWNED BY incident_management_timeline_events.id;
+
CREATE TABLE index_statuses (
id integer NOT NULL,
project_id integer NOT NULL,
@@ -15253,6 +15365,22 @@ CREATE SEQUENCE issue_email_participants_id_seq
ALTER SEQUENCE issue_email_participants_id_seq OWNED BY issue_email_participants.id;
+CREATE TABLE issue_emails (
+ id bigint NOT NULL,
+ issue_id bigint NOT NULL,
+ email_message_id text NOT NULL,
+ CONSTRAINT check_5abf3e6aea CHECK ((char_length(email_message_id) <= 1000))
+);
+
+CREATE SEQUENCE issue_emails_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE issue_emails_id_seq OWNED BY issue_emails.id;
+
CREATE TABLE issue_links (
id integer NOT NULL,
source_id integer NOT NULL,
@@ -15398,7 +15526,7 @@ CREATE TABLE iterations_cadences (
group_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
- start_date date NOT NULL,
+ start_date date,
last_run_date date,
duration_in_weeks integer,
iterations_in_advance integer,
@@ -15642,6 +15770,27 @@ CREATE SEQUENCE lfs_file_locks_id_seq
ALTER SEQUENCE lfs_file_locks_id_seq OWNED BY lfs_file_locks.id;
+CREATE TABLE lfs_object_states (
+ verification_started_at timestamp with time zone,
+ verification_retry_at timestamp with time zone,
+ verified_at timestamp with time zone,
+ lfs_object_id bigint NOT NULL,
+ verification_state smallint DEFAULT 0 NOT NULL,
+ verification_retry_count smallint,
+ verification_checksum bytea,
+ verification_failure text,
+ CONSTRAINT check_efe45a8ab3 CHECK ((char_length(verification_failure) <= 255))
+);
+
+CREATE SEQUENCE lfs_object_states_lfs_object_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE lfs_object_states_lfs_object_id_seq OWNED BY lfs_object_states.lfs_object_id;
+
CREATE TABLE lfs_objects (
id integer NOT NULL,
oid character varying NOT NULL,
@@ -15741,6 +15890,15 @@ CREATE SEQUENCE lists_id_seq
ALTER SEQUENCE lists_id_seq OWNED BY lists.id;
+CREATE SEQUENCE loose_foreign_keys_deleted_records_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE loose_foreign_keys_deleted_records_id_seq OWNED BY loose_foreign_keys_deleted_records.id;
+
CREATE TABLE member_tasks (
id bigint NOT NULL,
member_id bigint NOT NULL,
@@ -16114,6 +16272,22 @@ CREATE SEQUENCE merge_requests_closing_issues_id_seq
ALTER SEQUENCE merge_requests_closing_issues_id_seq OWNED BY merge_requests_closing_issues.id;
+CREATE TABLE merge_requests_compliance_violations (
+ id bigint NOT NULL,
+ violating_user_id bigint NOT NULL,
+ merge_request_id bigint NOT NULL,
+ reason smallint NOT NULL
+);
+
+CREATE SEQUENCE merge_requests_compliance_violations_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE merge_requests_compliance_violations_id_seq OWNED BY merge_requests_compliance_violations.id;
+
CREATE SEQUENCE merge_requests_id_seq
START WITH 1
INCREMENT BY 1
@@ -16312,7 +16486,7 @@ CREATE TABLE namespaces (
owner_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone,
- type character varying,
+ type character varying DEFAULT 'User'::character varying NOT NULL,
description character varying DEFAULT ''::character varying NOT NULL,
avatar character varying,
membership_lock boolean DEFAULT false,
@@ -16366,6 +16540,20 @@ CREATE SEQUENCE namespaces_id_seq
ALTER SEQUENCE namespaces_id_seq OWNED BY namespaces.id;
+CREATE TABLE namespaces_sync_events (
+ id bigint NOT NULL,
+ namespace_id bigint NOT NULL
+);
+
+CREATE SEQUENCE namespaces_sync_events_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE namespaces_sync_events_id_seq OWNED BY namespaces_sync_events.id;
+
CREATE TABLE note_diff_files (
id integer NOT NULL,
diff_note_id integer NOT NULL,
@@ -17321,6 +17509,27 @@ CREATE SEQUENCE packages_tags_id_seq
ALTER SEQUENCE packages_tags_id_seq OWNED BY packages_tags.id;
+CREATE TABLE pages_deployment_states (
+ pages_deployment_id bigint NOT NULL,
+ verification_state smallint DEFAULT 0 NOT NULL,
+ verification_started_at timestamp with time zone,
+ verification_retry_at timestamp with time zone,
+ verified_at timestamp with time zone,
+ verification_retry_count smallint,
+ verification_checksum bytea,
+ verification_failure text,
+ CONSTRAINT check_15217e8c3a CHECK ((char_length(verification_failure) <= 255))
+);
+
+CREATE SEQUENCE pages_deployment_states_pages_deployment_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE pages_deployment_states_pages_deployment_id_seq OWNED BY pages_deployment_states.pages_deployment_id;
+
CREATE TABLE pages_deployments (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -18258,7 +18467,9 @@ CREATE TABLE project_settings (
warn_about_potentially_unwanted_characters boolean DEFAULT true NOT NULL,
merge_commit_template text,
has_shimo boolean DEFAULT false NOT NULL,
+ squash_commit_template text,
CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)),
+ CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)),
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)),
CONSTRAINT check_eaf7cfb6a7 CHECK ((char_length(merge_commit_template) <= 500))
);
@@ -18418,6 +18629,20 @@ CREATE SEQUENCE projects_id_seq
ALTER SEQUENCE projects_id_seq OWNED BY projects.id;
+CREATE TABLE projects_sync_events (
+ id bigint NOT NULL,
+ project_id bigint NOT NULL
+);
+
+CREATE SEQUENCE projects_sync_events_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE projects_sync_events_id_seq OWNED BY projects_sync_events.id;
+
CREATE TABLE prometheus_alert_events (
id bigint NOT NULL,
project_id integer NOT NULL,
@@ -18586,7 +18811,9 @@ CREATE TABLE protected_environments (
updated_at timestamp with time zone NOT NULL,
name character varying NOT NULL,
group_id bigint,
- CONSTRAINT protected_environments_project_or_group_existence CHECK (((project_id IS NULL) <> (group_id IS NULL)))
+ required_approval_count integer DEFAULT 0 NOT NULL,
+ CONSTRAINT protected_environments_project_or_group_existence CHECK (((project_id IS NULL) <> (group_id IS NULL))),
+ CONSTRAINT protected_environments_required_approval_count_positive CHECK ((required_approval_count >= 0))
);
CREATE SEQUENCE protected_environments_id_seq
@@ -18843,8 +19070,7 @@ CREATE TABLE requirements_management_test_reports (
author_id bigint,
state smallint NOT NULL,
build_id bigint,
- issue_id bigint,
- CONSTRAINT requirements_test_reports_requirement_id_xor_issue_id CHECK ((num_nonnulls(requirement_id, issue_id) = 1))
+ issue_id bigint
);
CREATE SEQUENCE requirements_management_test_reports_id_seq
@@ -19460,6 +19686,7 @@ CREATE TABLE sprints (
description_html text,
state_enum smallint DEFAULT 1 NOT NULL,
iterations_cadence_id integer,
+ sequence integer,
CONSTRAINT sprints_must_belong_to_project_or_group CHECK ((((project_id <> NULL::bigint) AND (group_id IS NULL)) OR ((group_id <> NULL::bigint) AND (project_id IS NULL)))),
CONSTRAINT sprints_title CHECK ((char_length(title) <= 255))
);
@@ -19705,7 +19932,7 @@ CREATE TABLE timelogs (
updated_at timestamp without time zone NOT NULL,
issue_id integer,
merge_request_id integer,
- spent_at timestamp without time zone,
+ spent_at timestamp without time zone DEFAULT now(),
note_id integer,
project_id integer,
summary text,
@@ -19838,6 +20065,27 @@ CREATE SEQUENCE upcoming_reconciliations_id_seq
ALTER SEQUENCE upcoming_reconciliations_id_seq OWNED BY upcoming_reconciliations.id;
+CREATE TABLE upload_states (
+ verification_started_at timestamp with time zone,
+ verification_retry_at timestamp with time zone,
+ verified_at timestamp with time zone,
+ upload_id bigint NOT NULL,
+ verification_state smallint DEFAULT 0 NOT NULL,
+ verification_retry_count smallint,
+ verification_checksum bytea,
+ verification_failure text,
+ CONSTRAINT check_7396dc8591 CHECK ((char_length(verification_failure) <= 255))
+);
+
+CREATE SEQUENCE upload_states_upload_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE upload_states_upload_id_seq OWNED BY upload_states.upload_id;
+
CREATE TABLE uploads (
id integer NOT NULL,
size bigint NOT NULL,
@@ -20184,7 +20432,9 @@ CREATE TABLE users (
last_name character varying(255),
static_object_token character varying(255),
role smallint,
- user_type smallint
+ user_type smallint,
+ static_object_token_encrypted text,
+ CONSTRAINT check_7bde697e8e CHECK ((char_length(static_object_token_encrypted) <= 255))
);
CREATE SEQUENCE users_id_seq
@@ -20723,6 +20973,7 @@ CREATE TABLE vulnerability_occurrences (
cve text,
location jsonb,
detection_method smallint DEFAULT 0 NOT NULL,
+ migrated_to_new_structure boolean DEFAULT false NOT NULL,
CONSTRAINT check_4a3a60f2ba CHECK ((char_length(solution) <= 7000)),
CONSTRAINT check_ade261da6b CHECK ((char_length(description) <= 15000)),
CONSTRAINT check_df6dd20219 CHECK ((char_length(message) <= 3000)),
@@ -20738,6 +20989,30 @@ CREATE SEQUENCE vulnerability_occurrences_id_seq
ALTER SEQUENCE vulnerability_occurrences_id_seq OWNED BY vulnerability_occurrences.id;
+CREATE TABLE vulnerability_reads (
+ id bigint NOT NULL,
+ vulnerability_id bigint NOT NULL,
+ project_id bigint NOT NULL,
+ scanner_id bigint NOT NULL,
+ report_type smallint NOT NULL,
+ severity smallint NOT NULL,
+ state smallint NOT NULL,
+ has_issues boolean DEFAULT false NOT NULL,
+ resolved_on_default_branch boolean DEFAULT false NOT NULL,
+ uuid uuid NOT NULL,
+ location_image text,
+ CONSTRAINT check_380451bdbe CHECK ((char_length(location_image) <= 2048))
+);
+
+CREATE SEQUENCE vulnerability_reads_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE vulnerability_reads_id_seq OWNED BY vulnerability_reads.id;
+
CREATE TABLE vulnerability_remediations (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -21062,6 +21337,8 @@ ALTER SEQUENCE zoom_meetings_id_seq OWNED BY zoom_meetings.id;
ALTER TABLE ONLY abuse_reports ALTER COLUMN id SET DEFAULT nextval('abuse_reports_id_seq'::regclass);
+ALTER TABLE ONLY agent_activity_events ALTER COLUMN id SET DEFAULT nextval('agent_activity_events_id_seq'::regclass);
+
ALTER TABLE ONLY agent_group_authorizations ALTER COLUMN id SET DEFAULT nextval('agent_group_authorizations_id_seq'::regclass);
ALTER TABLE ONLY agent_project_authorizations ALTER COLUMN id SET DEFAULT nextval('agent_project_authorizations_id_seq'::regclass);
@@ -21216,6 +21493,8 @@ ALTER TABLE ONLY ci_job_variables ALTER COLUMN id SET DEFAULT nextval('ci_job_va
ALTER TABLE ONLY ci_minutes_additional_packs ALTER COLUMN id SET DEFAULT nextval('ci_minutes_additional_packs_id_seq'::regclass);
+ALTER TABLE ONLY ci_namespace_mirrors ALTER COLUMN id SET DEFAULT nextval('ci_namespace_mirrors_id_seq'::regclass);
+
ALTER TABLE ONLY ci_namespace_monthly_usages ALTER COLUMN id SET DEFAULT nextval('ci_namespace_monthly_usages_id_seq'::regclass);
ALTER TABLE ONLY ci_pending_builds ALTER COLUMN id SET DEFAULT nextval('ci_pending_builds_id_seq'::regclass);
@@ -21238,6 +21517,8 @@ ALTER TABLE ONLY ci_pipelines_config ALTER COLUMN pipeline_id SET DEFAULT nextva
ALTER TABLE ONLY ci_platform_metrics ALTER COLUMN id SET DEFAULT nextval('ci_platform_metrics_id_seq'::regclass);
+ALTER TABLE ONLY ci_project_mirrors ALTER COLUMN id SET DEFAULT nextval('ci_project_mirrors_id_seq'::regclass);
+
ALTER TABLE ONLY ci_project_monthly_usages ALTER COLUMN id SET DEFAULT nextval('ci_project_monthly_usages_id_seq'::regclass);
ALTER TABLE ONLY ci_refs ALTER COLUMN id SET DEFAULT nextval('ci_refs_id_seq'::regclass);
@@ -21356,6 +21637,8 @@ ALTER TABLE ONLY deploy_keys_projects ALTER COLUMN id SET DEFAULT nextval('deplo
ALTER TABLE ONLY deploy_tokens ALTER COLUMN id SET DEFAULT nextval('deploy_tokens_id_seq'::regclass);
+ALTER TABLE ONLY deployment_approvals ALTER COLUMN id SET DEFAULT nextval('deployment_approvals_id_seq'::regclass);
+
ALTER TABLE ONLY deployments ALTER COLUMN id SET DEFAULT nextval('deployments_id_seq'::regclass);
ALTER TABLE ONLY description_versions ALTER COLUMN id SET DEFAULT nextval('description_versions_id_seq'::regclass);
@@ -21518,6 +21801,8 @@ ALTER TABLE ONLY incident_management_pending_alert_escalations ALTER COLUMN id S
ALTER TABLE ONLY incident_management_pending_issue_escalations ALTER COLUMN id SET DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass);
+ALTER TABLE ONLY incident_management_timeline_events ALTER COLUMN id SET DEFAULT nextval('incident_management_timeline_events_id_seq'::regclass);
+
ALTER TABLE ONLY index_statuses ALTER COLUMN id SET DEFAULT nextval('index_statuses_id_seq'::regclass);
ALTER TABLE ONLY insights ALTER COLUMN id SET DEFAULT nextval('insights_id_seq'::regclass);
@@ -21538,6 +21823,8 @@ ALTER TABLE ONLY issue_customer_relations_contacts ALTER COLUMN id SET DEFAULT n
ALTER TABLE ONLY issue_email_participants ALTER COLUMN id SET DEFAULT nextval('issue_email_participants_id_seq'::regclass);
+ALTER TABLE ONLY issue_emails ALTER COLUMN id SET DEFAULT nextval('issue_emails_id_seq'::regclass);
+
ALTER TABLE ONLY issue_links ALTER COLUMN id SET DEFAULT nextval('issue_links_id_seq'::regclass);
ALTER TABLE ONLY issue_metrics ALTER COLUMN id SET DEFAULT nextval('issue_metrics_id_seq'::regclass);
@@ -21570,6 +21857,8 @@ ALTER TABLE ONLY ldap_group_links ALTER COLUMN id SET DEFAULT nextval('ldap_grou
ALTER TABLE ONLY lfs_file_locks ALTER COLUMN id SET DEFAULT nextval('lfs_file_locks_id_seq'::regclass);
+ALTER TABLE ONLY lfs_object_states ALTER COLUMN lfs_object_id SET DEFAULT nextval('lfs_object_states_lfs_object_id_seq'::regclass);
+
ALTER TABLE ONLY lfs_objects ALTER COLUMN id SET DEFAULT nextval('lfs_objects_id_seq'::regclass);
ALTER TABLE ONLY lfs_objects_projects ALTER COLUMN id SET DEFAULT nextval('lfs_objects_projects_id_seq'::regclass);
@@ -21610,6 +21899,8 @@ ALTER TABLE ONLY merge_requests ALTER COLUMN id SET DEFAULT nextval('merge_reque
ALTER TABLE ONLY merge_requests_closing_issues ALTER COLUMN id SET DEFAULT nextval('merge_requests_closing_issues_id_seq'::regclass);
+ALTER TABLE ONLY merge_requests_compliance_violations ALTER COLUMN id SET DEFAULT nextval('merge_requests_compliance_violations_id_seq'::regclass);
+
ALTER TABLE ONLY merge_trains ALTER COLUMN id SET DEFAULT nextval('merge_trains_id_seq'::regclass);
ALTER TABLE ONLY metrics_dashboard_annotations ALTER COLUMN id SET DEFAULT nextval('metrics_dashboard_annotations_id_seq'::regclass);
@@ -21624,6 +21915,8 @@ ALTER TABLE ONLY namespace_statistics ALTER COLUMN id SET DEFAULT nextval('names
ALTER TABLE ONLY namespaces ALTER COLUMN id SET DEFAULT nextval('namespaces_id_seq'::regclass);
+ALTER TABLE ONLY namespaces_sync_events ALTER COLUMN id SET DEFAULT nextval('namespaces_sync_events_id_seq'::regclass);
+
ALTER TABLE ONLY note_diff_files ALTER COLUMN id SET DEFAULT nextval('note_diff_files_id_seq'::regclass);
ALTER TABLE ONLY notes ALTER COLUMN id SET DEFAULT nextval('notes_id_seq'::regclass);
@@ -21702,6 +21995,8 @@ ALTER TABLE ONLY packages_packages ALTER COLUMN id SET DEFAULT nextval('packages
ALTER TABLE ONLY packages_tags ALTER COLUMN id SET DEFAULT nextval('packages_tags_id_seq'::regclass);
+ALTER TABLE ONLY pages_deployment_states ALTER COLUMN pages_deployment_id SET DEFAULT nextval('pages_deployment_states_pages_deployment_id_seq'::regclass);
+
ALTER TABLE ONLY pages_deployments ALTER COLUMN id SET DEFAULT nextval('pages_deployments_id_seq'::regclass);
ALTER TABLE ONLY pages_domain_acme_orders ALTER COLUMN id SET DEFAULT nextval('pages_domain_acme_orders_id_seq'::regclass);
@@ -21774,6 +22069,8 @@ ALTER TABLE ONLY project_tracing_settings ALTER COLUMN id SET DEFAULT nextval('p
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);
+
ALTER TABLE ONLY prometheus_alert_events ALTER COLUMN id SET DEFAULT nextval('prometheus_alert_events_id_seq'::regclass);
ALTER TABLE ONLY prometheus_alerts ALTER COLUMN id SET DEFAULT nextval('prometheus_alerts_id_seq'::regclass);
@@ -21906,6 +22203,8 @@ ALTER TABLE ONLY u2f_registrations ALTER COLUMN id SET DEFAULT nextval('u2f_regi
ALTER TABLE ONLY upcoming_reconciliations ALTER COLUMN id SET DEFAULT nextval('upcoming_reconciliations_id_seq'::regclass);
+ALTER TABLE ONLY upload_states ALTER COLUMN upload_id SET DEFAULT nextval('upload_states_upload_id_seq'::regclass);
+
ALTER TABLE ONLY uploads ALTER COLUMN id SET DEFAULT nextval('uploads_id_seq'::regclass);
ALTER TABLE ONLY user_agent_details ALTER COLUMN id SET DEFAULT nextval('user_agent_details_id_seq'::regclass);
@@ -21978,6 +22277,8 @@ ALTER TABLE ONLY vulnerability_occurrence_pipelines ALTER COLUMN id SET DEFAULT
ALTER TABLE ONLY vulnerability_occurrences ALTER COLUMN id SET DEFAULT nextval('vulnerability_occurrences_id_seq'::regclass);
+ALTER TABLE ONLY vulnerability_reads ALTER COLUMN id SET DEFAULT nextval('vulnerability_reads_id_seq'::regclass);
+
ALTER TABLE ONLY vulnerability_remediations ALTER COLUMN id SET DEFAULT nextval('vulnerability_remediations_id_seq'::regclass);
ALTER TABLE ONLY vulnerability_scanners ALTER COLUMN id SET DEFAULT nextval('vulnerability_scanners_id_seq'::regclass);
@@ -22206,12 +22507,6 @@ ALTER TABLE ONLY gitlab_partitions_static.analytics_cycle_analytics_merge_reques
ALTER TABLE ONLY gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_31
ADD CONSTRAINT analytics_cycle_analytics_merge_request_stage_events_31_pkey PRIMARY KEY (stage_event_hash_id, merge_request_id);
-ALTER TABLE ONLY loose_foreign_keys_deleted_records
- ADD CONSTRAINT loose_foreign_keys_deleted_records_pkey PRIMARY KEY (partition, id);
-
-ALTER TABLE ONLY gitlab_partitions_static.loose_foreign_keys_deleted_records_1
- ADD CONSTRAINT loose_foreign_keys_deleted_records_1_pkey PRIMARY KEY (partition, id);
-
ALTER TABLE ONLY product_analytics_events_experimental
ADD CONSTRAINT product_analytics_events_experimental_pkey PRIMARY KEY (id, project_id);
@@ -22410,6 +22705,9 @@ ALTER TABLE ONLY gitlab_partitions_static.product_analytics_events_experimental_
ALTER TABLE ONLY abuse_reports
ADD CONSTRAINT abuse_reports_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY agent_activity_events
+ ADD CONSTRAINT agent_activity_events_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY agent_group_authorizations
ADD CONSTRAINT agent_group_authorizations_pkey PRIMARY KEY (id);
@@ -22611,6 +22909,9 @@ ALTER TABLE ONLY chat_teams
ALTER TABLE vulnerability_scanners
ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) NOT VALID;
+ALTER TABLE security_findings
+ ADD CONSTRAINT check_6c2851a8c9 CHECK ((uuid IS NOT NULL)) NOT VALID;
+
ALTER TABLE sprints
ADD CONSTRAINT check_ccd8a1eae0 CHECK ((start_date IS NOT NULL)) NOT VALID;
@@ -22671,6 +22972,9 @@ ALTER TABLE ONLY ci_job_variables
ALTER TABLE ONLY ci_minutes_additional_packs
ADD CONSTRAINT ci_minutes_additional_packs_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ci_namespace_mirrors
+ ADD CONSTRAINT ci_namespace_mirrors_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY ci_namespace_monthly_usages
ADD CONSTRAINT ci_namespace_monthly_usages_pkey PRIMARY KEY (id);
@@ -22704,6 +23008,9 @@ ALTER TABLE ONLY ci_pipelines
ALTER TABLE ONLY ci_platform_metrics
ADD CONSTRAINT ci_platform_metrics_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ci_project_mirrors
+ ADD CONSTRAINT ci_project_mirrors_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY ci_project_monthly_usages
ADD CONSTRAINT ci_project_monthly_usages_pkey PRIMARY KEY (id);
@@ -22905,6 +23212,9 @@ ALTER TABLE ONLY deploy_keys_projects
ALTER TABLE ONLY deploy_tokens
ADD CONSTRAINT deploy_tokens_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY deployment_approvals
+ ADD CONSTRAINT deployment_approvals_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY deployment_clusters
ADD CONSTRAINT deployment_clusters_pkey PRIMARY KEY (deployment_id);
@@ -23172,6 +23482,9 @@ ALTER TABLE ONLY incident_management_pending_alert_escalations
ALTER TABLE ONLY incident_management_pending_issue_escalations
ADD CONSTRAINT incident_management_pending_issue_escalations_pkey PRIMARY KEY (id, process_at);
+ALTER TABLE ONLY incident_management_timeline_events
+ ADD CONSTRAINT incident_management_timeline_events_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY index_statuses
ADD CONSTRAINT index_statuses_pkey PRIMARY KEY (id);
@@ -23205,6 +23518,9 @@ ALTER TABLE ONLY issue_customer_relations_contacts
ALTER TABLE ONLY issue_email_participants
ADD CONSTRAINT issue_email_participants_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY issue_emails
+ ADD CONSTRAINT issue_emails_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY issue_links
ADD CONSTRAINT issue_links_pkey PRIMARY KEY (id);
@@ -23265,6 +23581,9 @@ ALTER TABLE ONLY ldap_group_links
ALTER TABLE ONLY lfs_file_locks
ADD CONSTRAINT lfs_file_locks_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY lfs_object_states
+ ADD CONSTRAINT lfs_object_states_pkey PRIMARY KEY (lfs_object_id);
+
ALTER TABLE ONLY lfs_objects
ADD CONSTRAINT lfs_objects_pkey PRIMARY KEY (id);
@@ -23280,6 +23599,9 @@ ALTER TABLE ONLY list_user_preferences
ALTER TABLE ONLY lists
ADD CONSTRAINT lists_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY loose_foreign_keys_deleted_records
+ ADD CONSTRAINT loose_foreign_keys_deleted_records_pkey PRIMARY KEY (partition, id);
+
ALTER TABLE ONLY member_tasks
ADD CONSTRAINT member_tasks_pkey PRIMARY KEY (id);
@@ -23328,6 +23650,9 @@ ALTER TABLE ONLY merge_request_user_mentions
ALTER TABLE ONLY merge_requests_closing_issues
ADD CONSTRAINT merge_requests_closing_issues_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY merge_requests_compliance_violations
+ ADD CONSTRAINT merge_requests_compliance_violations_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT merge_requests_pkey PRIMARY KEY (id);
@@ -23370,6 +23695,9 @@ ALTER TABLE ONLY namespace_statistics
ALTER TABLE ONLY namespaces
ADD CONSTRAINT namespaces_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY namespaces_sync_events
+ ADD CONSTRAINT namespaces_sync_events_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY note_diff_files
ADD CONSTRAINT note_diff_files_pkey PRIMARY KEY (id);
@@ -23511,6 +23839,9 @@ ALTER TABLE ONLY packages_rubygems_metadata
ALTER TABLE ONLY packages_tags
ADD CONSTRAINT packages_tags_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY pages_deployment_states
+ ADD CONSTRAINT pages_deployment_states_pkey PRIMARY KEY (pages_deployment_id);
+
ALTER TABLE ONLY pages_deployments
ADD CONSTRAINT pages_deployments_pkey PRIMARY KEY (id);
@@ -23640,6 +23971,9 @@ ALTER TABLE ONLY project_tracing_settings
ALTER TABLE ONLY projects
ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY projects_sync_events
+ ADD CONSTRAINT projects_sync_events_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY prometheus_alert_events
ADD CONSTRAINT prometheus_alert_events_pkey PRIMARY KEY (id);
@@ -23763,6 +24097,9 @@ ALTER TABLE ONLY sent_notifications
ALTER TABLE ONLY sentry_issues
ADD CONSTRAINT sentry_issues_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY sprints
+ ADD CONSTRAINT sequence_is_unique_per_iterations_cadence_id UNIQUE (iterations_cadence_id, sequence) DEFERRABLE INITIALLY DEFERRED;
+
ALTER TABLE ONLY serverless_domain_cluster
ADD CONSTRAINT serverless_domain_cluster_pkey PRIMARY KEY (uuid);
@@ -23859,6 +24196,9 @@ ALTER TABLE ONLY u2f_registrations
ALTER TABLE ONLY upcoming_reconciliations
ADD CONSTRAINT upcoming_reconciliations_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY upload_states
+ ADD CONSTRAINT upload_states_pkey PRIMARY KEY (upload_id);
+
ALTER TABLE ONLY uploads
ADD CONSTRAINT uploads_pkey PRIMARY KEY (id);
@@ -23985,6 +24325,9 @@ ALTER TABLE ONLY vulnerability_occurrence_pipelines
ALTER TABLE ONLY vulnerability_occurrences
ADD CONSTRAINT vulnerability_occurrences_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY vulnerability_reads
+ ADD CONSTRAINT vulnerability_reads_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY vulnerability_remediations
ADD CONSTRAINT vulnerability_remediations_pkey PRIMARY KEY (id);
@@ -24038,10 +24381,6 @@ CREATE INDEX index_merge_request_stage_events_project_duration ON ONLY analytics
CREATE INDEX index_006f943df6 ON gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_16 USING btree (stage_event_hash_id, project_id, end_event_timestamp, merge_request_id, start_event_timestamp) WHERE (end_event_timestamp IS NOT NULL);
-CREATE INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ON ONLY loose_foreign_keys_deleted_records USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1);
-
-CREATE INDEX index_01e3390fac ON gitlab_partitions_static.loose_foreign_keys_deleted_records_1 USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1);
-
CREATE INDEX index_02749b504c ON gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_11 USING btree (stage_event_hash_id, project_id, end_event_timestamp, merge_request_id, start_event_timestamp) WHERE (end_event_timestamp IS NOT NULL);
CREATE INDEX index_merge_request_stage_events_group_duration ON ONLY analytics_cycle_analytics_merge_request_stage_events USING btree (stage_event_hash_id, group_id, end_event_timestamp, merge_request_id, start_event_timestamp) WHERE (end_event_timestamp IS NOT NULL);
@@ -24750,7 +25089,7 @@ CREATE INDEX finding_evidence_sources_on_finding_evidence_id ON vulnerability_fi
CREATE INDEX finding_evidence_supporting_messages_on_finding_evidence_id ON vulnerability_finding_evidence_supporting_messages USING btree (vulnerability_finding_evidence_id);
-CREATE INDEX finding_evidences_on_vulnerability_occurrence_id ON vulnerability_finding_evidences USING btree (vulnerability_occurrence_id);
+CREATE UNIQUE INDEX finding_evidences_on_unique_vulnerability_occurrence_id ON vulnerability_finding_evidences USING btree (vulnerability_occurrence_id);
CREATE INDEX finding_links_on_vulnerability_occurrence_id ON vulnerability_finding_links USING btree (vulnerability_occurrence_id);
@@ -24840,8 +25179,6 @@ CREATE UNIQUE INDEX idx_on_external_status_checks_project_id_external_url ON ext
CREATE UNIQUE INDEX idx_on_external_status_checks_project_id_name ON external_status_checks USING btree (project_id, name);
-CREATE INDEX idx_packages_build_infos_on_package_id ON packages_build_infos USING btree (package_id);
-
CREATE INDEX idx_packages_debian_group_component_files_on_architecture_id ON packages_debian_group_component_files USING btree (architecture_id);
CREATE INDEX idx_packages_debian_project_component_files_on_architecture_id ON packages_debian_project_component_files USING btree (architecture_id);
@@ -24902,6 +25239,16 @@ CREATE UNIQUE INDEX idx_vulnerability_issue_links_on_vulnerability_id_and_link_t
CREATE INDEX index_abuse_reports_on_user_id ON abuse_reports USING btree (user_id);
+CREATE INDEX index_agent_activity_events_on_agent_id_and_recorded_at_and_id ON agent_activity_events USING btree (agent_id, recorded_at, id);
+
+CREATE INDEX index_agent_activity_events_on_agent_token_id ON agent_activity_events USING btree (agent_token_id) WHERE (agent_token_id IS NOT NULL);
+
+CREATE INDEX index_agent_activity_events_on_merge_request_id ON agent_activity_events USING btree (merge_request_id) WHERE (merge_request_id IS NOT NULL);
+
+CREATE INDEX index_agent_activity_events_on_project_id ON agent_activity_events USING btree (project_id) WHERE (project_id IS NOT NULL);
+
+CREATE INDEX index_agent_activity_events_on_user_id ON agent_activity_events USING btree (user_id) WHERE (user_id IS NOT NULL);
+
CREATE UNIQUE INDEX index_agent_group_authorizations_on_agent_id_and_group_id ON agent_group_authorizations USING btree (agent_id, group_id);
CREATE INDEX index_agent_group_authorizations_on_group_id ON agent_group_authorizations USING btree (group_id);
@@ -25268,6 +25615,8 @@ CREATE UNIQUE INDEX index_ci_job_variables_on_key_and_job_id ON ci_job_variables
CREATE INDEX index_ci_minutes_additional_packs_on_namespace_id_purchase_xid ON ci_minutes_additional_packs USING btree (namespace_id, purchase_xid);
+CREATE UNIQUE INDEX index_ci_namespace_mirrors_on_namespace_id ON ci_namespace_mirrors USING btree (namespace_id);
+
CREATE UNIQUE INDEX index_ci_namespace_monthly_usages_on_namespace_id_and_date ON ci_namespace_monthly_usages USING btree (namespace_id, date);
CREATE INDEX index_ci_pending_builds_id_on_protected_partial ON ci_pending_builds USING btree (id) WHERE (protected = true);
@@ -25356,6 +25705,10 @@ CREATE INDEX index_ci_pipelines_on_user_id_and_created_at_and_source ON ci_pipel
CREATE INDEX index_ci_pipelines_on_user_id_and_id_and_cancelable_status ON ci_pipelines USING btree (user_id, id) WHERE ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('waiting_for_resource'::character varying)::text, ('preparing'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text, ('scheduled'::character varying)::text]));
+CREATE INDEX index_ci_project_mirrors_on_namespace_id ON ci_project_mirrors USING btree (namespace_id);
+
+CREATE UNIQUE INDEX index_ci_project_mirrors_on_project_id ON ci_project_mirrors USING btree (project_id);
+
CREATE UNIQUE INDEX index_ci_project_monthly_usages_on_project_id_and_date ON ci_project_monthly_usages USING btree (project_id, date);
CREATE UNIQUE INDEX index_ci_refs_on_project_id_and_ref_path ON ci_refs USING btree (project_id, ref_path);
@@ -25376,10 +25729,14 @@ CREATE INDEX index_ci_runner_projects_on_runner_id ON ci_runner_projects USING b
CREATE INDEX index_ci_runners_on_contacted_at_and_id_desc ON ci_runners USING btree (contacted_at, id DESC);
+CREATE INDEX index_ci_runners_on_contacted_at_and_id_where_inactive ON ci_runners USING btree (contacted_at DESC, id DESC) WHERE (active = false);
+
CREATE INDEX index_ci_runners_on_contacted_at_desc_and_id_desc ON ci_runners USING btree (contacted_at DESC, id DESC);
CREATE INDEX index_ci_runners_on_created_at_and_id_desc ON ci_runners USING btree (created_at, id DESC);
+CREATE INDEX index_ci_runners_on_created_at_and_id_where_inactive ON ci_runners USING btree (created_at DESC, id DESC) WHERE (active = false);
+
CREATE INDEX index_ci_runners_on_created_at_desc_and_id_desc ON ci_runners USING btree (created_at DESC, id DESC);
CREATE INDEX index_ci_runners_on_description_trigram ON ci_runners USING gin (description gin_trgm_ops);
@@ -25532,7 +25889,7 @@ CREATE INDEX index_container_repository_on_name_trigram ON container_repositorie
CREATE UNIQUE INDEX index_content_blocked_states_on_container_id_commit_sha_path ON content_blocked_states USING btree (container_identifier, commit_sha, path);
-CREATE INDEX index_coverage_fuzzing_corpuses_on_package_id ON coverage_fuzzing_corpuses USING btree (package_id);
+CREATE UNIQUE INDEX index_coverage_fuzzing_corpuses_on_package_id ON coverage_fuzzing_corpuses USING btree (package_id);
CREATE INDEX index_coverage_fuzzing_corpuses_on_project_id ON coverage_fuzzing_corpuses USING btree (project_id);
@@ -25622,6 +25979,10 @@ CREATE INDEX index_deploy_tokens_on_token_and_expires_at_and_id ON deploy_tokens
CREATE UNIQUE INDEX index_deploy_tokens_on_token_encrypted ON deploy_tokens USING btree (token_encrypted);
+CREATE UNIQUE INDEX index_deployment_approvals_on_deployment_id_and_user_id ON deployment_approvals USING btree (deployment_id, user_id);
+
+CREATE INDEX index_deployment_approvals_on_user_id ON deployment_approvals USING btree (user_id);
+
CREATE UNIQUE INDEX index_deployment_clusters_on_cluster_id_and_deployment_id ON deployment_clusters USING btree (cluster_id, deployment_id);
CREATE INDEX index_deployment_merge_requests_on_merge_request_id ON deployment_merge_requests USING btree (merge_request_id);
@@ -25810,14 +26171,14 @@ CREATE INDEX index_et_errors_on_project_id_and_status_first_seen_at_id_desc ON e
CREATE INDEX index_et_errors_on_project_id_and_status_last_seen_at_id_desc ON error_tracking_errors USING btree (project_id, status, last_seen_at DESC, id DESC);
+CREATE INDEX index_events_author_id_project_id_action_target_type_created_at ON events USING btree (author_id, project_id, action, target_type, created_at);
+
CREATE INDEX index_events_on_action ON events USING btree (action);
CREATE INDEX index_events_on_author_id_and_created_at ON events USING btree (author_id, created_at);
CREATE INDEX index_events_on_author_id_and_created_at_merge_requests ON events USING btree (author_id, created_at) WHERE ((target_type)::text = 'MergeRequest'::text);
-CREATE INDEX index_events_on_author_id_and_project_id ON events USING btree (author_id, project_id);
-
CREATE INDEX index_events_on_created_at_and_id ON events USING btree (created_at, id) WHERE (created_at > '2021-08-27 00:00:00+00'::timestamp with time zone);
CREATE INDEX index_events_on_group_id_partial ON events USING btree (group_id) WHERE (group_id IS NOT NULL);
@@ -25932,6 +26293,8 @@ CREATE INDEX index_geo_repository_updated_events_on_source ON geo_repository_upd
CREATE INDEX index_geo_reset_checksum_events_on_project_id ON geo_reset_checksum_events USING btree (project_id);
+CREATE INDEX index_gin_ci_namespace_mirrors_on_traversal_ids ON ci_namespace_mirrors USING gin (traversal_ids);
+
CREATE INDEX index_gin_ci_pending_builds_on_namespace_traversal_ids ON ci_pending_builds USING gin (namespace_traversal_ids);
CREATE INDEX index_gitlab_subscription_histories_on_gitlab_subscription_id ON gitlab_subscription_histories USING btree (gitlab_subscription_id);
@@ -26022,6 +26385,16 @@ CREATE INDEX index_im_issuable_escalation_statuses_on_policy_id ON incident_mana
CREATE UNIQUE INDEX index_im_oncall_schedules_on_project_id_and_iid ON incident_management_oncall_schedules USING btree (project_id, iid);
+CREATE INDEX index_im_timeline_events_author_id ON incident_management_timeline_events USING btree (author_id);
+
+CREATE INDEX index_im_timeline_events_issue_id ON incident_management_timeline_events USING btree (issue_id);
+
+CREATE INDEX index_im_timeline_events_project_id ON incident_management_timeline_events USING btree (project_id);
+
+CREATE INDEX index_im_timeline_events_promoted_from_note_id ON incident_management_timeline_events USING btree (promoted_from_note_id);
+
+CREATE INDEX index_im_timeline_events_updated_by_user_id ON incident_management_timeline_events USING btree (updated_by_user_id);
+
CREATE UNIQUE INDEX index_import_export_uploads_on_group_id ON import_export_uploads USING btree (group_id) WHERE (group_id IS NOT NULL);
CREATE INDEX index_import_export_uploads_on_project_id ON import_export_uploads USING btree (project_id);
@@ -26116,14 +26489,16 @@ CREATE INDEX index_issue_customer_relations_contacts_on_contact_id ON issue_cust
CREATE UNIQUE INDEX index_issue_email_participants_on_issue_id_and_lower_email ON issue_email_participants USING btree (issue_id, lower(email));
+CREATE INDEX index_issue_emails_on_email_message_id ON issue_emails USING btree (email_message_id);
+
+CREATE INDEX index_issue_emails_on_issue_id ON issue_emails USING btree (issue_id);
+
CREATE INDEX index_issue_links_on_source_id ON issue_links USING btree (source_id);
CREATE UNIQUE INDEX index_issue_links_on_source_id_and_target_id ON issue_links USING btree (source_id, target_id);
CREATE INDEX index_issue_links_on_target_id ON issue_links USING btree (target_id);
-CREATE INDEX index_issue_metrics_first_mentioned_in_commit ON issue_metrics USING btree (issue_id) WHERE (date_part('year'::text, first_mentioned_in_commit_at) > (2019)::double precision);
-
CREATE INDEX index_issue_metrics_on_issue_id_and_timestamps ON issue_metrics USING btree (issue_id, first_mentioned_in_commit_at, first_associated_with_milestone_at, first_added_to_board_at);
CREATE INDEX index_issue_on_project_id_state_id_and_blocking_issues_count ON issues USING btree (project_id, state_id, blocking_issues_count);
@@ -26232,6 +26607,16 @@ CREATE UNIQUE INDEX index_lfs_file_locks_on_project_id_and_path ON lfs_file_lock
CREATE INDEX index_lfs_file_locks_on_user_id ON lfs_file_locks USING btree (user_id);
+CREATE INDEX index_lfs_object_states_failed_verification ON lfs_object_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
+
+CREATE INDEX index_lfs_object_states_needs_verification ON lfs_object_states USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3));
+
+CREATE INDEX index_lfs_object_states_on_lfs_object_id ON lfs_object_states USING btree (lfs_object_id);
+
+CREATE INDEX index_lfs_object_states_on_verification_state ON lfs_object_states USING btree (verification_state);
+
+CREATE INDEX index_lfs_object_states_pending_verification ON lfs_object_states USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0);
+
CREATE INDEX index_lfs_objects_on_file_store ON lfs_objects USING btree (file_store);
CREATE UNIQUE INDEX index_lfs_objects_on_oid ON lfs_objects USING btree (oid);
@@ -26258,6 +26643,8 @@ CREATE INDEX index_lists_on_milestone_id ON lists USING btree (milestone_id);
CREATE INDEX index_lists_on_user_id ON lists USING btree (user_id);
+CREATE INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ON ONLY loose_foreign_keys_deleted_records USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1);
+
CREATE INDEX index_member_tasks_on_member_id ON member_tasks USING btree (member_id);
CREATE UNIQUE INDEX index_member_tasks_on_member_id_and_project_id ON member_tasks USING btree (member_id, project_id);
@@ -26342,6 +26729,10 @@ CREATE INDEX index_merge_requests_closing_issues_on_issue_id ON merge_requests_c
CREATE INDEX index_merge_requests_closing_issues_on_merge_request_id ON merge_requests_closing_issues USING btree (merge_request_id);
+CREATE INDEX index_merge_requests_compliance_violations_on_violating_user_id ON merge_requests_compliance_violations USING btree (violating_user_id);
+
+CREATE UNIQUE INDEX index_merge_requests_compliance_violations_unique_columns ON merge_requests_compliance_violations USING btree (merge_request_id, violating_user_id, reason);
+
CREATE INDEX index_merge_requests_on_assignee_id ON merge_requests USING btree (assignee_id);
CREATE INDEX index_merge_requests_on_author_id ON merge_requests USING btree (author_id);
@@ -26488,6 +26879,8 @@ CREATE INDEX index_namespaces_on_type_and_id ON namespaces USING btree (type, id
CREATE INDEX index_namespaces_public_groups_name_id ON namespaces USING btree (name, id) WHERE (((type)::text = 'Group'::text) AND (visibility_level = 20));
+CREATE INDEX index_namespaces_sync_events_on_namespace_id ON namespaces_sync_events USING btree (namespace_id);
+
CREATE INDEX index_non_requested_project_members_on_source_id_and_type ON members USING btree (source_id, source_type) WHERE ((requested_at IS NULL) AND ((type)::text = 'ProjectMember'::text));
CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id ON note_diff_files USING btree (diff_note_id);
@@ -26504,8 +26897,6 @@ CREATE INDEX index_notes_on_discussion_id ON notes USING btree (discussion_id);
CREATE INDEX index_notes_on_line_code ON notes USING btree (line_code);
-CREATE INDEX index_notes_on_note_trigram ON notes USING gin (note gin_trgm_ops);
-
CREATE INDEX index_notes_on_noteable_id_and_noteable_type_and_system ON notes USING btree (noteable_id, noteable_type, system);
CREATE INDEX index_notes_on_project_id_and_id_and_system_false ON notes USING btree (project_id, id) WHERE (NOT system);
@@ -26604,6 +26995,8 @@ CREATE UNIQUE INDEX index_ops_strategies_user_lists_on_strategy_id_and_user_list
CREATE INDEX index_packages_build_infos_on_pipeline_id ON packages_build_infos USING btree (pipeline_id);
+CREATE INDEX index_packages_build_infos_package_id_pipeline_id ON packages_build_infos USING btree (package_id, pipeline_id);
+
CREATE UNIQUE INDEX index_packages_composer_cache_namespace_and_sha ON packages_composer_cache_files USING btree (namespace_id, file_sha256);
CREATE UNIQUE INDEX index_packages_composer_metadata_on_package_id_and_target_sha ON packages_composer_metadata USING btree (package_id, target_sha);
@@ -26682,6 +27075,16 @@ CREATE INDEX index_packages_tags_on_package_id ON packages_tags USING btree (pac
CREATE INDEX index_packages_tags_on_package_id_and_updated_at ON packages_tags USING btree (package_id, updated_at DESC);
+CREATE INDEX index_pages_deployment_states_failed_verification ON pages_deployment_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
+
+CREATE INDEX index_pages_deployment_states_needs_verification ON pages_deployment_states USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3));
+
+CREATE INDEX index_pages_deployment_states_on_pages_deployment_id ON pages_deployment_states USING btree (pages_deployment_id);
+
+CREATE INDEX index_pages_deployment_states_on_verification_state ON pages_deployment_states USING btree (verification_state);
+
+CREATE INDEX index_pages_deployment_states_pending_verification ON pages_deployment_states USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0);
+
CREATE INDEX index_pages_deployments_on_ci_build_id ON pages_deployments USING btree (ci_build_id);
CREATE INDEX index_pages_deployments_on_file_store_and_id ON pages_deployments USING btree (file_store, id);
@@ -26886,6 +27289,8 @@ CREATE INDEX index_projects_api_vis20_path ON projects USING btree (path, id) WH
CREATE INDEX index_projects_api_vis20_updated_at ON projects USING btree (updated_at, id) WHERE (visibility_level = 20);
+CREATE INDEX index_projects_not_aimed_for_deletion ON projects USING btree (id) WHERE (marked_for_deletion_at IS NULL);
+
CREATE INDEX index_projects_on_created_at_and_id ON projects USING btree (created_at, id);
CREATE INDEX index_projects_on_creator_id_and_created_at_and_id ON projects USING btree (creator_id, created_at, id);
@@ -26948,6 +27353,8 @@ 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);
+CREATE INDEX index_projects_sync_events_on_project_id ON projects_sync_events USING btree (project_id);
+
CREATE UNIQUE INDEX index_prometheus_alert_event_scoped_payload_key ON prometheus_alert_events USING btree (prometheus_alert_id, payload_key);
CREATE INDEX index_prometheus_alert_events_on_project_id_and_status ON prometheus_alert_events USING btree (project_id, status);
@@ -27226,6 +27633,8 @@ CREATE INDEX index_snippets_on_id_and_created_at ON snippets USING btree (id, cr
CREATE INDEX index_snippets_on_id_and_type ON snippets USING btree (id, type);
+CREATE INDEX index_snippets_on_project_id_and_title ON snippets USING btree (project_id, title);
+
CREATE INDEX index_snippets_on_project_id_and_visibility_level ON snippets USING btree (project_id, visibility_level);
CREATE INDEX index_snippets_on_title_trigram ON snippets USING gin (title gin_trgm_ops);
@@ -27348,7 +27757,9 @@ CREATE INDEX index_todos_on_group_id ON todos USING btree (group_id);
CREATE INDEX index_todos_on_note_id ON todos USING btree (note_id);
-CREATE INDEX index_todos_on_project_id ON todos USING btree (project_id);
+CREATE INDEX index_todos_on_project_id_and_id ON todos USING btree (project_id, id);
+
+CREATE INDEX index_todos_on_project_id_and_user_id_and_id ON todos USING btree (project_id, user_id, id);
CREATE INDEX index_todos_on_target_type_and_target_id ON todos USING btree (target_type, target_id);
@@ -27384,6 +27795,16 @@ CREATE UNIQUE INDEX index_unit_test_failures_unique_columns ON ci_unit_test_fail
CREATE UNIQUE INDEX index_upcoming_reconciliations_on_namespace_id ON upcoming_reconciliations USING btree (namespace_id);
+CREATE INDEX index_upload_states_failed_verification ON upload_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
+
+CREATE INDEX index_upload_states_needs_verification ON upload_states USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3));
+
+CREATE INDEX index_upload_states_on_upload_id ON upload_states USING btree (upload_id);
+
+CREATE INDEX index_upload_states_on_verification_state ON upload_states USING btree (verification_state);
+
+CREATE INDEX index_upload_states_pending_verification ON upload_states USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0);
+
CREATE INDEX index_uploads_on_checksum ON uploads USING btree (checksum);
CREATE INDEX index_uploads_on_model_id_and_model_type ON uploads USING btree (model_id, model_type);
@@ -27464,7 +27885,7 @@ CREATE INDEX index_users_on_name ON users USING btree (name);
CREATE INDEX index_users_on_name_trigram ON users USING gin (name gin_trgm_ops);
-CREATE INDEX index_users_on_public_email ON users USING btree (public_email) WHERE ((public_email)::text <> ''::text);
+CREATE INDEX index_users_on_public_email_excluding_null_and_empty ON users USING btree (public_email) WHERE (((public_email)::text <> ''::text) AND (public_email IS NOT NULL));
CREATE INDEX index_users_on_require_two_factor_authentication_from_group ON users USING btree (require_two_factor_authentication_from_group) WHERE (require_two_factor_authentication_from_group = true);
@@ -27504,6 +27925,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_project_id_state_severity_and_vuln_id ON vulnerability_reads USING btree (project_id, state, severity, vulnerability_id DESC);
+
CREATE INDEX index_vulnerabilities_on_author_id ON vulnerabilities USING btree (author_id);
CREATE INDEX index_vulnerabilities_on_confirmed_by_id ON vulnerabilities USING btree (confirmed_by_id);
@@ -27582,10 +28005,14 @@ CREATE INDEX index_vulnerability_occurrences_deduplication ON vulnerability_occu
CREATE INDEX index_vulnerability_occurrences_for_issue_links_migration ON vulnerability_occurrences USING btree (project_id, report_type, encode(project_fingerprint, 'hex'::text));
+CREATE INDEX index_vulnerability_occurrences_on_location_agent_id ON vulnerability_occurrences USING gin (((location -> 'agent_id'::text))) WHERE (report_type = 7);
+
CREATE INDEX index_vulnerability_occurrences_on_location_cluster_id ON vulnerability_occurrences USING gin (((location -> 'cluster_id'::text))) WHERE (report_type = 7);
CREATE INDEX index_vulnerability_occurrences_on_location_image ON vulnerability_occurrences USING gin (((location -> 'image'::text))) WHERE (report_type = ANY (ARRAY[2, 7]));
+CREATE INDEX index_vulnerability_occurrences_on_migrated_to_new_structure ON vulnerability_occurrences USING btree (migrated_to_new_structure, id);
+
CREATE INDEX index_vulnerability_occurrences_on_primary_identifier_id ON vulnerability_occurrences USING btree (primary_identifier_id);
CREATE INDEX index_vulnerability_occurrences_on_project_fingerprint ON vulnerability_occurrences USING btree (project_fingerprint);
@@ -27598,6 +28025,14 @@ CREATE UNIQUE INDEX index_vulnerability_occurrences_on_uuid ON vulnerability_occ
CREATE INDEX index_vulnerability_occurrences_on_vulnerability_id ON vulnerability_occurrences USING btree (vulnerability_id);
+CREATE INDEX index_vulnerability_reads_on_location_image ON vulnerability_reads USING btree (location_image) WHERE (report_type = ANY (ARRAY[2, 7]));
+
+CREATE INDEX index_vulnerability_reads_on_scanner_id ON vulnerability_reads USING btree (scanner_id);
+
+CREATE UNIQUE INDEX index_vulnerability_reads_on_uuid ON vulnerability_reads USING btree (uuid);
+
+CREATE UNIQUE INDEX index_vulnerability_reads_on_vulnerability_id ON vulnerability_reads USING btree (vulnerability_id);
+
CREATE UNIQUE INDEX index_vulnerability_remediations_on_project_id_and_checksum ON vulnerability_remediations USING btree (project_id, checksum);
CREATE UNIQUE INDEX index_vulnerability_scanners_on_project_id_and_external_id ON vulnerability_scanners USING btree (project_id, external_id);
@@ -27720,6 +28155,8 @@ CREATE UNIQUE INDEX tmp_index_on_tmp_project_id_on_namespaces ON namespaces USIN
CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING btree (id) WHERE (state <> 2);
+CREATE INDEX tmp_index_uuid_is_null ON security_findings USING btree (id) WHERE (uuid IS NULL);
+
CREATE UNIQUE INDEX uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name ON packages_debian_group_architectures USING btree (distribution_id, name);
CREATE UNIQUE INDEX uniq_pkgs_deb_grp_components_on_distribution_id_and_name ON packages_debian_group_components USING btree (distribution_id, name);
@@ -27744,8 +28181,6 @@ CREATE UNIQUE INDEX vulnerability_feedback_unique_idx ON vulnerability_feedback
CREATE UNIQUE INDEX vulnerability_occurrence_pipelines_on_unique_keys ON vulnerability_occurrence_pipelines USING btree (occurrence_id, pipeline_id);
-CREATE INDEX vulnerability_occurrences_location_temp_index ON vulnerability_occurrences USING btree (id) WHERE (location IS NULL);
-
CREATE UNIQUE INDEX work_item_types_namespace_id_and_name_unique ON work_item_types USING btree (namespace_id, btrim(lower(name)));
ALTER INDEX analytics_cycle_analytics_issue_stage_events_pkey ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00_pkey;
@@ -27880,8 +28315,6 @@ ALTER INDEX index_issue_stage_events_project_duration ATTACH PARTITION gitlab_pa
ALTER INDEX index_merge_request_stage_events_project_duration ATTACH PARTITION gitlab_partitions_static.index_006f943df6;
-ALTER INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ATTACH PARTITION gitlab_partitions_static.index_01e3390fac;
-
ALTER INDEX index_merge_request_stage_events_project_duration ATTACH PARTITION gitlab_partitions_static.index_02749b504c;
ALTER INDEX index_merge_request_stage_events_group_duration ATTACH PARTITION gitlab_partitions_static.index_0287f5ba09;
@@ -28390,8 +28823,6 @@ ALTER INDEX index_issue_stage_events_project_duration ATTACH PARTITION gitlab_pa
ALTER INDEX index_issue_stage_events_group_in_progress_duration ATTACH PARTITION gitlab_partitions_static.index_ff8741d8d7;
-ALTER INDEX loose_foreign_keys_deleted_records_pkey ATTACH PARTITION gitlab_partitions_static.loose_foreign_keys_deleted_records_1_pkey;
-
ALTER INDEX index_product_analytics_events_experimental_project_and_time ATTACH PARTITION gitlab_partitions_static.product_analytics_events_expe_project_id_collector_tstamp_idx10;
ALTER INDEX index_product_analytics_events_experimental_project_and_time ATTACH PARTITION gitlab_partitions_static.product_analytics_events_expe_project_id_collector_tstamp_idx11;
@@ -28650,8 +29081,22 @@ ALTER INDEX product_analytics_events_experimental_pkey ATTACH PARTITION gitlab_p
CREATE TRIGGER chat_names_loose_fk_trigger AFTER DELETE ON chat_names REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+CREATE TRIGGER ci_builds_loose_fk_trigger AFTER DELETE ON ci_builds REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
+CREATE TRIGGER ci_job_artifacts_loose_fk_trigger AFTER DELETE ON ci_job_artifacts REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
+CREATE TRIGGER ci_pipelines_loose_fk_trigger AFTER DELETE ON ci_pipelines REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
CREATE TRIGGER ci_runners_loose_fk_trigger AFTER DELETE ON ci_runners REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+CREATE TRIGGER external_pull_requests_loose_fk_trigger AFTER DELETE ON external_pull_requests REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
+CREATE TRIGGER merge_requests_loose_fk_trigger AFTER DELETE ON merge_requests REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
+CREATE TRIGGER namespaces_loose_fk_trigger AFTER DELETE ON namespaces REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
+CREATE TRIGGER projects_loose_fk_trigger AFTER DELETE ON projects REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
CREATE TRIGGER trigger_delete_project_namespace_on_project_delete AFTER DELETE ON projects FOR EACH ROW WHEN ((old.project_namespace_id IS NOT NULL)) EXECUTE FUNCTION delete_associated_project_namespace();
CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON integrations FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_issue_tracker();
@@ -28668,8 +29113,18 @@ CREATE TRIGGER trigger_has_external_wiki_on_type_new_updated AFTER UPDATE OF typ
CREATE TRIGGER trigger_has_external_wiki_on_update AFTER UPDATE ON integrations FOR EACH ROW WHEN (((new.type_new = 'Integrations::ExternalWiki'::text) AND (old.active <> new.active) AND (new.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_wiki();
+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();
+
+CREATE TRIGGER trigger_projects_parent_id_on_insert AFTER INSERT ON projects FOR EACH ROW EXECUTE FUNCTION insert_projects_sync_event();
+
+CREATE TRIGGER trigger_projects_parent_id_on_update AFTER UPDATE ON projects FOR EACH ROW WHEN ((old.namespace_id IS DISTINCT FROM new.namespace_id)) EXECUTE FUNCTION insert_projects_sync_event();
+
CREATE TRIGGER trigger_type_new_on_insert AFTER INSERT ON integrations FOR EACH ROW EXECUTE FUNCTION integrations_set_type_new();
+CREATE TRIGGER users_loose_fk_trigger AFTER DELETE ON users REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
+
ALTER TABLE ONLY chat_names
ADD CONSTRAINT fk_00797a2bf9 FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE;
@@ -28679,9 +29134,6 @@ ALTER TABLE ONLY deployments
ALTER TABLE ONLY epics
ADD CONSTRAINT fk_013c9f36ca FOREIGN KEY (due_date_sourcing_epic_id) REFERENCES epics(id) ON DELETE SET NULL;
-ALTER TABLE ONLY clusters_applications_runners
- ADD CONSTRAINT fk_02de2ded36 FOREIGN KEY (runner_id) REFERENCES ci_runners(id) ON DELETE SET NULL;
-
ALTER TABLE ONLY incident_management_escalation_rules
ADD CONSTRAINT fk_0314ee86eb FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -28718,6 +29170,9 @@ ALTER TABLE ONLY lists
ALTER TABLE ONLY ci_unit_test_failures
ADD CONSTRAINT fk_0f09856e1f FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE CASCADE;
+ALTER TABLE ONLY deployment_approvals
+ ADD CONSTRAINT fk_0f58311058 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY project_pages_metadata
ADD CONSTRAINT fk_0fd5b22688 FOREIGN KEY (pages_deployment_id) REFERENCES pages_deployments(id) ON DELETE SET NULL;
@@ -28745,6 +29200,12 @@ ALTER TABLE ONLY internal_ids
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_176d3fbb5d FOREIGN KEY (job_artifact_deleted_event_id) REFERENCES geo_job_artifact_deleted_events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY incident_management_timeline_events
+ ADD CONSTRAINT fk_17a5fafbd4 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY incident_management_timeline_events
+ ADD CONSTRAINT fk_1800597ef9 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY project_features
ADD CONSTRAINT fk_18513d9b92 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -28796,6 +29257,9 @@ ALTER TABLE ONLY import_failures
ALTER TABLE ONLY project_ci_cd_settings
ADD CONSTRAINT fk_24c15d2f2e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY agent_activity_events
+ ADD CONSTRAINT fk_256c631779 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY epics
ADD CONSTRAINT fk_25b99c1be3 FOREIGN KEY (parent_id) REFERENCES epics(id) ON DELETE CASCADE;
@@ -28811,12 +29275,18 @@ ALTER TABLE ONLY geo_event_log
ALTER TABLE ONLY deployments
ADD CONSTRAINT fk_289bba3222 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE SET NULL;
+ALTER TABLE ONLY merge_requests_compliance_violations
+ ADD CONSTRAINT fk_290ec1ab02 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY coverage_fuzzing_corpuses
ADD CONSTRAINT fk_29f6f15f82 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE ONLY agent_group_authorizations
ADD CONSTRAINT fk_2c9f941965 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY deployment_approvals
+ ADD CONSTRAINT fk_2d060dfc73 FOREIGN KEY (deployment_id) REFERENCES deployments(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY ci_freeze_periods
ADD CONSTRAINT fk_2e02bbd1a6 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -28862,12 +29332,18 @@ ALTER TABLE ONLY sprints
ALTER TABLE ONLY push_event_payloads
ADD CONSTRAINT fk_36c74129da FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY incident_management_timeline_events
+ ADD CONSTRAINT fk_38a74279df FOREIGN KEY (updated_by_user_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY bulk_import_exports
ADD CONSTRAINT fk_39c726d3b5 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_builds
ADD CONSTRAINT fk_3a9eaa254d FOREIGN KEY (stage_id) REFERENCES ci_stages(id) ON DELETE CASCADE;
+ALTER TABLE ONLY agent_activity_events
+ ADD CONSTRAINT fk_3af186389b FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY issues
ADD CONSTRAINT fk_3b8c72ea56 FOREIGN KEY (sprint_id) REFERENCES sprints(id) ON DELETE SET NULL;
@@ -28886,6 +29362,9 @@ ALTER TABLE ONLY geo_event_log
ALTER TABLE ONLY remote_mirrors
ADD CONSTRAINT fk_43a9aa4ca8 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY incident_management_timeline_events
+ ADD CONSTRAINT fk_4432fc4d78 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY ci_runner_projects
ADD CONSTRAINT fk_4478a6f1e4 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -28898,6 +29377,9 @@ 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 vulnerability_reads
+ ADD CONSTRAINT fk_5001652292 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY alert_management_alerts
ADD CONSTRAINT fk_51ab4b6089 FOREIGN KEY (prometheus_alert_id) REFERENCES prometheus_alerts(id) ON DELETE CASCADE;
@@ -28946,6 +29428,9 @@ ALTER TABLE ONLY dast_profile_schedules
ALTER TABLE ONLY events
ADD CONSTRAINT fk_61fbf6ca48 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY vulnerability_reads
+ ADD CONSTRAINT fk_62736f638f FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_641731faff FOREIGN KEY (updated_by_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -29237,6 +29722,9 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY project_access_tokens
ADD CONSTRAINT fk_b27801bfbf FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY vulnerability_reads
+ ADD CONSTRAINT fk_b28c28abf1 FOREIGN KEY (scanner_id) REFERENCES vulnerability_scanners(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY issues
ADD CONSTRAINT fk_b37be69be6 FOREIGN KEY (work_item_type_id) REFERENCES work_item_types(id);
@@ -29312,6 +29800,12 @@ ALTER TABLE ONLY geo_event_log
ALTER TABLE ONLY issues
ADD CONSTRAINT fk_c63cbf6c25 FOREIGN KEY (closed_by_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY agent_activity_events
+ ADD CONSTRAINT fk_c815368376 FOREIGN KEY (agent_id) REFERENCES cluster_agents(id) ON DELETE CASCADE;
+
+ALTER TABLE ONLY agent_activity_events
+ ADD CONSTRAINT fk_c8b006d40f FOREIGN KEY (agent_token_id) REFERENCES cluster_agent_tokens(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY issue_links
ADD CONSTRAINT fk_c900194ff2 FOREIGN KEY (source_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -29363,9 +29857,15 @@ ALTER TABLE ONLY ci_sources_pipelines
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_d5af95fcd9 FOREIGN KEY (lfs_object_deleted_event_id) REFERENCES geo_lfs_object_deleted_events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY incident_management_timeline_events
+ ADD CONSTRAINT fk_d606a2a890 FOREIGN KEY (promoted_from_note_id) REFERENCES notes(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_d6cf4279f7 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+ALTER TABLE ONLY agent_activity_events
+ ADD CONSTRAINT fk_d6f785c9fc FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY metrics_users_starred_dashboards
ADD CONSTRAINT fk_d76a2b9a8c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -29453,6 +29953,9 @@ ALTER TABLE ONLY pages_domains
ALTER TABLE ONLY application_settings
ADD CONSTRAINT fk_ec757bd087 FOREIGN KEY (file_template_project_id) REFERENCES projects(id) ON DELETE SET NULL;
+ALTER TABLE ONLY merge_requests_compliance_violations
+ ADD CONSTRAINT fk_ec881c1c6f FOREIGN KEY (violating_user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY events
ADD CONSTRAINT fk_edfd187b6f FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -29864,9 +30367,6 @@ ALTER TABLE ONLY container_repositories
ALTER TABLE ONLY clusters_applications_jupyter
ADD CONSTRAINT fk_rails_331f0aff78 FOREIGN KEY (oauth_application_id) REFERENCES oauth_applications(id) ON DELETE SET NULL;
-ALTER TABLE ONLY merge_request_metrics
- ADD CONSTRAINT fk_rails_33ae169d48 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY suggestions
ADD CONSTRAINT fk_rails_33b03a535c FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE;
@@ -29948,6 +30448,9 @@ ALTER TABLE ONLY description_versions
ALTER TABLE ONLY clusters_kubernetes_namespaces
ADD CONSTRAINT fk_rails_40cc7ccbc3 FOREIGN KEY (cluster_project_id) REFERENCES cluster_projects(id) ON DELETE SET NULL;
+ALTER TABLE ONLY lfs_object_states
+ ADD CONSTRAINT fk_rails_4188448cd5 FOREIGN KEY (lfs_object_id) REFERENCES lfs_objects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY geo_node_namespace_links
ADD CONSTRAINT fk_rails_41ff5fb854 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -30536,6 +31039,9 @@ ALTER TABLE ONLY gpg_keys
ALTER TABLE ONLY analytics_language_trend_repository_languages
ADD CONSTRAINT fk_rails_9d851d566c FOREIGN KEY (programming_language_id) REFERENCES programming_languages(id) ON DELETE CASCADE;
+ALTER TABLE ONLY namespaces_sync_events
+ ADD CONSTRAINT fk_rails_9da32a0431 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY badges
ADD CONSTRAINT fk_rails_9df4a56538 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -30710,6 +31216,9 @@ ALTER TABLE ONLY security_findings
ALTER TABLE ONLY packages_debian_project_component_files
ADD CONSTRAINT fk_rails_bbe9ebfbd9 FOREIGN KEY (component_id) REFERENCES packages_debian_project_components(id) ON DELETE RESTRICT;
+ALTER TABLE ONLY projects_sync_events
+ ADD CONSTRAINT fk_rails_bbf0eef59f FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY approval_merge_request_rules_users
ADD CONSTRAINT fk_rails_bc8972fa55 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -30764,9 +31273,6 @@ ALTER TABLE ONLY packages_nuget_dependency_link_metadata
ALTER TABLE ONLY group_deploy_keys_groups
ADD CONSTRAINT fk_rails_c3854f19f5 FOREIGN KEY (group_deploy_key_id) REFERENCES group_deploy_keys(id) ON DELETE CASCADE;
-ALTER TABLE ONLY pages_deployments
- ADD CONSTRAINT fk_rails_c3a90cf29b FOREIGN KEY (ci_build_id) REFERENCES ci_builds(id) ON DELETE SET NULL;
-
ALTER TABLE ONLY merge_request_user_mentions
ADD CONSTRAINT fk_rails_c440b9ea31 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE;
@@ -30839,6 +31345,9 @@ ALTER TABLE ONLY resource_iteration_events
ALTER TABLE ONLY vulnerability_finding_evidence_requests
ADD CONSTRAINT fk_rails_cf0f278cb0 FOREIGN KEY (vulnerability_finding_evidence_supporting_message_id) REFERENCES vulnerability_finding_evidence_supporting_messages(id) ON DELETE CASCADE;
+ALTER TABLE ONLY upload_states
+ ADD CONSTRAINT fk_rails_d00f153613 FOREIGN KEY (upload_id) REFERENCES uploads(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY epic_metrics
ADD CONSTRAINT fk_rails_d071904753 FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE CASCADE;
@@ -30932,6 +31441,9 @@ ALTER TABLE ONLY packages_packages
ALTER TABLE ONLY cluster_platforms_kubernetes
ADD CONSTRAINT fk_rails_e1e2cf841a FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
+ALTER TABLE ONLY issue_emails
+ ADD CONSTRAINT fk_rails_e2ee00a8f7 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY vulnerability_finding_evidences
ADD CONSTRAINT fk_rails_e3205a0c65 FOREIGN KEY (vulnerability_occurrence_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE;
@@ -31130,6 +31642,9 @@ ALTER TABLE ONLY project_tracing_settings
ALTER TABLE ONLY resource_label_events
ADD CONSTRAINT fk_rails_fe91ece594 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY pages_deployment_states
+ ADD CONSTRAINT fk_rails_ff6ca551a4 FOREIGN KEY (pages_deployment_id) REFERENCES pages_deployments(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY ci_builds_metadata
ADD CONSTRAINT fk_rails_ffcf702a02 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;