summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /db
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
downloadgitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'db')
l---------db/ci_migrate1
-rw-r--r--db/ci_migrate/20210617101848_create_ci_instance_variables_on_ci.rb31
-rw-r--r--db/ci_schema_migrations/202106171018481
l---------[-rw-r--r--]db/ci_structure.sql46
-rw-r--r--db/fixtures/development/17_cycle_analytics.rb2
-rw-r--r--db/fixtures/development/31_error_tracking.rb49
-rw-r--r--db/migrate/20201203144655_add_allow_to_edit_commit_to_project_settings.rb8
-rw-r--r--db/migrate/20210611082822_add_pages_file_entries_to_plan_limits.rb7
-rw-r--r--db/migrate/20210628154900_create_detached_partitions_table.rb17
-rw-r--r--db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb77
-rw-r--r--db/migrate/20210630222522_add_customers_dot_jwt_signing_key_to_application_settings.rb10
-rw-r--r--db/migrate/20210630224625_generate_customers_dot_jwt_signing_key.rb32
-rw-r--r--db/migrate/20210706151154_add_remaining_ci_minutes_to_ci_pending_build.rb21
-rw-r--r--db/migrate/20210706151446_add_namespace_foreign_key_to_ci_pending_build.rb18
-rw-r--r--db/migrate/20210708202548_add_scanners_column_to_approval_project_rules.rb11
-rw-r--r--db/migrate/20210709221051_create_work_item_types.rb34
-rw-r--r--db/migrate/20210709221659_add_work_item_type_id_to_issue.rb31
-rw-r--r--db/migrate/20210712052519_add_label_applied_issuable_closed_to_issuable_sla.rb8
-rw-r--r--db/migrate/20210713123345_create_dast_profile_schedule.rb36
-rw-r--r--db/migrate/20210713211008_create_banned_users.rb20
-rw-r--r--db/migrate/20210713223941_remove_null_constraint_from_security_findings.rb11
-rw-r--r--db/migrate/20210714043818_add_index_for_label_applied_to_issuable_sla.rb17
-rw-r--r--db/migrate/20210715074359_add_foreign_key_to_dast_profile_schedules_on_dast_profile.rb17
-rw-r--r--db/migrate/20210715074933_add_foreign_key_to_dast_profile_schedules_on_user.rb17
-rw-r--r--db/migrate/20210715075203_add_foreign_key_to_dast_profile_schedules_on_project.rb17
-rw-r--r--db/migrate/20210719145532_add_foreign_keys_view.rb26
-rw-r--r--db/migrate/20210719182944_add_request_response_to_supporing_message.rb20
-rw-r--r--db/migrate/20210719192928_add_invite_email_success_to_member.rb11
-rw-r--r--db/migrate/20210720130006_create_error_tracking_client_keys.rb24
-rw-r--r--db/migrate/20210720140841_create_postgres_async_indexes_table.rb21
-rw-r--r--db/migrate/20210721125525_add_signed_file_to_packages_debian_project_distributions.rb13
-rw-r--r--db/migrate/20210721125545_add_signed_file_to_packages_debian_group_distributions.rb13
-rw-r--r--db/migrate/20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files.rb14
-rw-r--r--db/migrate/20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files.rb14
-rw-r--r--db/migrate/20210721134706_add_type_new_to_integrations.rb10
-rw-r--r--db/migrate/20210721134707_add_text_limit_to_integrations_type_new.rb15
-rw-r--r--db/migrate/20210721135638_add_triggers_to_integrations_type_new.rb79
-rw-r--r--db/migrate/20210721145029_add_state_to_members.rb13
-rw-r--r--db/migrate/20210721174411_add_is_removed_to_escalation_rules.rb7
-rw-r--r--db/migrate/20210721174441_update_escalation_rule_fk_for_pending_alert_escalations.rb29
-rw-r--r--db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb34
-rw-r--r--db/migrate/20210721211602_add_vulnerability_amount_column_into_approval_project_rules.rb11
-rw-r--r--db/migrate/20210722074220_remove_null_constraint_on_schedule_from_escalation_rules.rb13
-rw-r--r--db/migrate/20210722074242_add_user_to_escalation_rules.rb17
-rw-r--r--db/migrate/20210722074256_add_user_index_to_escalation_rules.rb33
-rw-r--r--db/migrate/20210722074309_add_user_fk_to_escalation_rules.rb17
-rw-r--r--db/migrate/20210722074339_add_xor_check_constraint_for_escalation_rules.rb17
-rw-r--r--db/migrate/20210722132844_devops_adoption_drop_redundant_indexes.rb20
-rw-r--r--db/migrate/20210722150102_operations_feature_flags_correct_flexible_rollout_values.rb29
-rw-r--r--db/migrate/20210722151951_add_columns_to_security_scans.rb21
-rw-r--r--db/migrate/20210722210041_add_overridden_uuid_to_security_findings.rb17
-rw-r--r--db/migrate/20210723173132_create_index_on_environments_auto_delete_at.rb20
-rw-r--r--db/migrate/20210726134950_add_integrated_to_error_tracking_setting.rb11
-rw-r--r--db/migrate/20210726202748_add_vulnerability_severities_into_approval_project_rules.rb11
-rw-r--r--db/migrate/20210728110654_add_status_to_error_tracking_error.rb11
-rw-r--r--db/migrate/20210728174349_add_fk_to_security_scans_columns.rb21
-rw-r--r--db/migrate/20210729061526_add_pronunciation_to_user_details.rb20
-rw-r--r--db/migrate/20210729061556_add_text_limit_to_user_details_pronunciation.rb15
-rw-r--r--db/migrate/20210729123101_confirm_security_bot.rb18
-rw-r--r--db/migrate/20210729161242_remove_foreign_keys_from_ci_test_case_failures.rb24
-rw-r--r--db/migrate/20210729192148_remove_foreign_keys_from_ci_test_cases.rb19
-rw-r--r--db/migrate/20210729202143_create_incident_management_issuable_escalation_statuses.rb20
-rw-r--r--db/migrate/20210730101609_create_analytics_cycle_analytics_stage_event_hashes.rb10
-rw-r--r--db/migrate/20210730102952_add_stage_hash_fk_to_project_stages.rb20
-rw-r--r--db/migrate/20210730103808_add_stage_hash_fk_to_group_stages.rb20
-rw-r--r--db/migrate/20210803110920_add_unique_index_to_vulnerability_flags_table.rb17
-rw-r--r--db/migrate/20210804150320_create_base_work_item_types.rb35
-rw-r--r--db/migrate/20210804200114_create_customer_relations_organizations.rb27
-rw-r--r--db/migrate/20210804202057_add_tmp_index_approval_project_rules_scanners.rb20
-rw-r--r--db/migrate/20210805085706_add_rule_index_to_security_orchestration_policy_rule_schedules.rb7
-rw-r--r--db/migrate/20210806152104_add_pypi_package_requests_forwarding_to_application_settings.rb17
-rw-r--r--db/migrate/20210809194250_rename_tables_ci_build_trace_section.rb11
-rw-r--r--db/migrate/20210812171704_create_project_ci_feature_usages.rb12
-rw-r--r--db/migrate/20210813101742_create_zentao_tracker_data.rb18
-rw-r--r--db/migrate/20210813111909_create_ci_build_trace_metadata.rb32
-rw-r--r--db/migrate/20210816161107_remove_index_containing_faulty_regex.rb18
-rw-r--r--db/migrate/20210817084338_add_foreign_key_from_ci_build_metadata_to_ci_job_artifacts.rb20
-rw-r--r--db/migrate/20210818034001_index_historical_data_on_recorded_at.rb17
-rw-r--r--db/migrate/20210818055357_add_unique_commit_design_user_mention_indexes.rb29
-rw-r--r--db/post_migrate/20190517153211_migrate_k8s_service_integration.rb2
-rw-r--r--db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb2
-rw-r--r--db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb27
-rw-r--r--db/post_migrate/20210622141148_schedule_delete_orphaned_deployments.rb13
-rw-r--r--db/post_migrate/20210701033622_finalize_ci_builds_needs_bigint_conversion.rb69
-rw-r--r--db/post_migrate/20210706142819_re_schedule_latest_pipeline_id_population.rb27
-rw-r--r--db/post_migrate/20210706212710_finalize_ci_job_artifacts_bigint_conversion.rb84
-rw-r--r--db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb77
-rw-r--r--db/post_migrate/20210709024048_finalize_push_event_payloads_bigint_conversion_2.rb13
-rw-r--r--db/post_migrate/20210713042153_finalize_ci_sources_pipelines_bigint_conversion.rb67
-rw-r--r--db/post_migrate/20210713075117_re_schedule_latest_pipeline_id_population_with_logging.rb12
-rw-r--r--db/post_migrate/20210714015537_finalize_ci_build_trace_chunks_bigint_conversion.rb67
-rw-r--r--db/post_migrate/20210721125804_remove_signing_keys_from_packages_debian_project_distributions.rb10
-rw-r--r--db/post_migrate/20210721125820_remove_signing_keys_from_packages_debian_group_distributions.rb10
-rw-r--r--db/post_migrate/20210721174521_add_non_null_constraint_for_escalation_rule_on_pending_alert_escalations.rb56
-rw-r--r--db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb28
-rw-r--r--db/post_migrate/20210722042939_update_issuable_slas_where_issue_closed.rb31
-rw-r--r--db/post_migrate/20210722055217_add_updated_at_index_on_merge_requests.rb17
-rw-r--r--db/post_migrate/20210722155635_finalize_convert_geo_job_artifact_deleted_events_bigint.rb55
-rw-r--r--db/post_migrate/20210727113447_backfill_integrations_type_new.rb23
-rw-r--r--db/post_migrate/20210727175201_remove_unused_columns_from_elastic_reindexing_tasks.rb27
-rw-r--r--db/post_migrate/20210729163312_re_schedule_latest_pipeline_id_population_with_all_security_related_artifact_types.rb30
-rw-r--r--db/post_migrate/20210729192959_drop_ci_test_case_failures_table.rb24
-rw-r--r--db/post_migrate/20210729193056_drop_ci_test_cases_table.rb23
-rw-r--r--db/post_migrate/20210730170823_schedule_security_setting_creation.rb26
-rw-r--r--db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb87
-rw-r--r--db/post_migrate/20210802112233_add_index_issues_on_project_id_and_state_id_and_created_at_and_id.rb18
-rw-r--r--db/post_migrate/20210802131812_finalize_convert_deployments_bigint.rb45
-rw-r--r--db/post_migrate/20210804150624_remove_cluster_image_scanning_from_approval_project_rules.rb11
-rw-r--r--db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb34
-rw-r--r--db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb29
-rw-r--r--db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb19
-rw-r--r--db/post_migrate/20210805131510_finalize_ci_builds_runner_session_bigint_conversion.rb67
-rw-r--r--db/post_migrate/20210805192450_update_trial_plans_ci_daily_pipeline_schedule_triggers.rb48
-rw-r--r--db/post_migrate/20210806011811_schedule_backfill_draft_column_on_merge_requests_rerun.rb13
-rw-r--r--db/post_migrate/20210809123658_orphaned_invite_tokens_cleanup.rb28
-rw-r--r--db/post_migrate/20210809143931_finalize_job_id_conversion_to_bigint_for_ci_job_artifacts.rb79
-rw-r--r--db/post_migrate/20210811214811_schedule_copy_ci_builds_columns_to_security_scans.rb13
-rw-r--r--db/post_migrate/20210812145010_reset_job_token_scope_enabled_again.rb16
-rw-r--r--db/post_migrate/20210813195518_schedule_recalculate_uuid_on_vulnerabilities_occurrences3.rb30
-rw-r--r--db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb35
-rw-r--r--db/schema_migrations/202106110828221
-rw-r--r--db/schema_migrations/202106281549001
-rw-r--r--db/schema_migrations/202106290319001
-rw-r--r--db/schema_migrations/202106302225221
-rw-r--r--db/schema_migrations/202106302246251
-rw-r--r--db/schema_migrations/202107010336221
-rw-r--r--db/schema_migrations/202107061511541
-rw-r--r--db/schema_migrations/202107061514461
-rw-r--r--db/schema_migrations/202107062127101
-rw-r--r--db/schema_migrations/202107072109161
-rw-r--r--db/schema_migrations/202107082025481
-rw-r--r--db/schema_migrations/202107090240481
-rw-r--r--db/schema_migrations/202107092210511
-rw-r--r--db/schema_migrations/202107092216591
-rw-r--r--db/schema_migrations/202107120525191
-rw-r--r--db/schema_migrations/202107130421531
-rw-r--r--db/schema_migrations/202107130751171
-rw-r--r--db/schema_migrations/202107131233451
-rw-r--r--db/schema_migrations/202107132110081
-rw-r--r--db/schema_migrations/202107132239411
-rw-r--r--db/schema_migrations/202107140155371
-rw-r--r--db/schema_migrations/202107140438181
-rw-r--r--db/schema_migrations/202107150743591
-rw-r--r--db/schema_migrations/202107150749331
-rw-r--r--db/schema_migrations/202107150752031
-rw-r--r--db/schema_migrations/202107191455321
-rw-r--r--db/schema_migrations/202107191829441
-rw-r--r--db/schema_migrations/202107191929281
-rw-r--r--db/schema_migrations/202107201300061
-rw-r--r--db/schema_migrations/202107201408411
-rw-r--r--db/schema_migrations/202107211255251
-rw-r--r--db/schema_migrations/202107211255451
-rw-r--r--db/schema_migrations/202107211256201
-rw-r--r--db/schema_migrations/202107211256371
-rw-r--r--db/schema_migrations/202107211258041
-rw-r--r--db/schema_migrations/202107211258201
-rw-r--r--db/schema_migrations/202107211347061
-rw-r--r--db/schema_migrations/202107211347071
-rw-r--r--db/schema_migrations/202107211356381
-rw-r--r--db/schema_migrations/202107211450291
-rw-r--r--db/schema_migrations/202107211744111
-rw-r--r--db/schema_migrations/202107211744411
-rw-r--r--db/schema_migrations/202107211744531
-rw-r--r--db/schema_migrations/202107211745211
-rw-r--r--db/schema_migrations/202107212116021
-rw-r--r--db/schema_migrations/202107220101011
-rw-r--r--db/schema_migrations/202107220429391
-rw-r--r--db/schema_migrations/202107220552171
-rw-r--r--db/schema_migrations/202107220742201
-rw-r--r--db/schema_migrations/202107220742421
-rw-r--r--db/schema_migrations/202107220742561
-rw-r--r--db/schema_migrations/202107220743091
-rw-r--r--db/schema_migrations/202107220743391
-rw-r--r--db/schema_migrations/202107221328441
-rw-r--r--db/schema_migrations/202107221501021
-rw-r--r--db/schema_migrations/202107221519511
-rw-r--r--db/schema_migrations/202107221556351
-rw-r--r--db/schema_migrations/202107222100411
-rw-r--r--db/schema_migrations/202107231731321
-rw-r--r--db/schema_migrations/202107261349501
-rw-r--r--db/schema_migrations/202107262027481
-rw-r--r--db/schema_migrations/202107271134471
-rw-r--r--db/schema_migrations/202107271752011
-rw-r--r--db/schema_migrations/202107281106541
-rw-r--r--db/schema_migrations/202107281743491
-rw-r--r--db/schema_migrations/202107290615261
-rw-r--r--db/schema_migrations/202107290615561
-rw-r--r--db/schema_migrations/202107291231011
-rw-r--r--db/schema_migrations/202107291612421
-rw-r--r--db/schema_migrations/202107291633121
-rw-r--r--db/schema_migrations/202107291921481
-rw-r--r--db/schema_migrations/202107291929591
-rw-r--r--db/schema_migrations/202107291930561
-rw-r--r--db/schema_migrations/202107292021431
-rw-r--r--db/schema_migrations/202107301016091
-rw-r--r--db/schema_migrations/202107301029521
-rw-r--r--db/schema_migrations/202107301038081
-rw-r--r--db/schema_migrations/202107301708231
-rw-r--r--db/schema_migrations/202108020432531
-rw-r--r--db/schema_migrations/202108021122331
-rw-r--r--db/schema_migrations/202108021318121
-rw-r--r--db/schema_migrations/202108031109201
-rw-r--r--db/schema_migrations/202108041503201
-rw-r--r--db/schema_migrations/202108041506241
-rw-r--r--db/schema_migrations/202108041514441
-rw-r--r--db/schema_migrations/202108041533071
-rw-r--r--db/schema_migrations/202108041544071
-rw-r--r--db/schema_migrations/202108042001141
-rw-r--r--db/schema_migrations/202108042020571
-rw-r--r--db/schema_migrations/202108050857061
-rw-r--r--db/schema_migrations/202108051315101
-rw-r--r--db/schema_migrations/202108051924501
-rw-r--r--db/schema_migrations/202108060118111
-rw-r--r--db/schema_migrations/202108061521041
-rw-r--r--db/schema_migrations/202108091236581
-rw-r--r--db/schema_migrations/202108091439311
-rw-r--r--db/schema_migrations/202108091942501
-rw-r--r--db/schema_migrations/202108112148111
-rw-r--r--db/schema_migrations/202108121450101
-rw-r--r--db/schema_migrations/202108121717041
-rw-r--r--db/schema_migrations/202108131017421
-rw-r--r--db/schema_migrations/202108131119091
-rw-r--r--db/schema_migrations/202108131955181
-rw-r--r--db/schema_migrations/202108161611071
-rw-r--r--db/schema_migrations/202108161833041
-rw-r--r--db/schema_migrations/202108170843381
-rw-r--r--db/schema_migrations/202108180340011
-rw-r--r--db/schema_migrations/202108180553571
-rw-r--r--db/structure.sql760
229 files changed, 3549 insertions, 308 deletions
diff --git a/db/ci_migrate b/db/ci_migrate
new file mode 120000
index 00000000000..1f0710ccbe7
--- /dev/null
+++ b/db/ci_migrate
@@ -0,0 +1 @@
+migrate \ No newline at end of file
diff --git a/db/ci_migrate/20210617101848_create_ci_instance_variables_on_ci.rb b/db/ci_migrate/20210617101848_create_ci_instance_variables_on_ci.rb
deleted file mode 100644
index 7274e6bcdf2..00000000000
--- a/db/ci_migrate/20210617101848_create_ci_instance_variables_on_ci.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-class CreateCiInstanceVariablesOnCi < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- disable_ddl_transaction!
-
- def up
- unless table_exists?(:ci_instance_variables)
- create_table :ci_instance_variables do |t|
- t.integer :variable_type, null: false, limit: 2, default: 1
- t.boolean :masked, default: false, allow_null: false
- t.boolean :protected, default: false, allow_null: false
- t.text :key, null: false
- t.text :encrypted_value
- t.text :encrypted_value_iv
-
- t.index [:key], name: 'index_ci_instance_variables_on_key', unique: true, using: :btree
- end
- end
-
- add_text_limit(:ci_instance_variables, :key, 255)
- # Use constraint_name generated from db/migrate/20200625193358_increase_size_on_instance_level_variable_values.rb
- add_text_limit(:ci_instance_variables, :encrypted_value, 13_579, constraint_name: 'check_956afd70f1')
- add_text_limit(:ci_instance_variables, :encrypted_value_iv, 255)
- end
-
- def down
- drop_table :ci_instance_variables
- end
-end
diff --git a/db/ci_schema_migrations/20210617101848 b/db/ci_schema_migrations/20210617101848
deleted file mode 100644
index 2969c694fa2..00000000000
--- a/db/ci_schema_migrations/20210617101848
+++ /dev/null
@@ -1 +0,0 @@
-1b74312f59f6f8937cd0dd754d22dc72e9bdc7302e6254a2fda5762afebe303c \ No newline at end of file
diff --git a/db/ci_structure.sql b/db/ci_structure.sql
index 1b898012f46..b402facb598 100644..120000
--- a/db/ci_structure.sql
+++ b/db/ci_structure.sql
@@ -1,45 +1 @@
-CREATE TABLE ar_internal_metadata (
- key character varying NOT NULL,
- value character varying,
- created_at timestamp(6) without time zone NOT NULL,
- updated_at timestamp(6) without time zone NOT NULL
-);
-
-CREATE TABLE ci_instance_variables (
- id bigint NOT NULL,
- variable_type smallint DEFAULT 1 NOT NULL,
- masked boolean DEFAULT false,
- protected boolean DEFAULT false,
- key text NOT NULL,
- encrypted_value text,
- encrypted_value_iv text,
- CONSTRAINT check_07a45a5bcb CHECK ((char_length(encrypted_value_iv) <= 255)),
- CONSTRAINT check_5aede12208 CHECK ((char_length(key) <= 255)),
- CONSTRAINT check_956afd70f1 CHECK ((char_length(encrypted_value) <= 13579))
-);
-
-CREATE SEQUENCE ci_instance_variables_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE ci_instance_variables_id_seq OWNED BY ci_instance_variables.id;
-
-CREATE TABLE schema_migrations (
- version character varying NOT NULL
-);
-
-ALTER TABLE ONLY ci_instance_variables ALTER COLUMN id SET DEFAULT nextval('ci_instance_variables_id_seq'::regclass);
-
-ALTER TABLE ONLY ar_internal_metadata
- ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
-
-ALTER TABLE ONLY ci_instance_variables
- ADD CONSTRAINT ci_instance_variables_pkey PRIMARY KEY (id);
-
-ALTER TABLE ONLY schema_migrations
- ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
-
-CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON ci_instance_variables USING btree (key);
+structure.sql \ No newline at end of file
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb
index 826e703a443..95d956fb402 100644
--- a/db/fixtures/development/17_cycle_analytics.rb
+++ b/db/fixtures/development/17_cycle_analytics.rb
@@ -149,7 +149,7 @@ class Gitlab::Seeder::CycleAnalytics
email: "vsm-user-#{i}@#{suffix}.com"
)
- project.group.add_developer(user)
+ project.group&.add_developer(user)
project.add_developer(user)
@developers << user
diff --git a/db/fixtures/development/31_error_tracking.rb b/db/fixtures/development/31_error_tracking.rb
new file mode 100644
index 00000000000..60e288696f8
--- /dev/null
+++ b/db/fixtures/development/31_error_tracking.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+class Gitlab::Seeder::ErrorTrackingSeeder
+ attr_reader :project
+
+ def initialize(project)
+ @project = project
+ end
+
+ def seed
+ parsed_event = Gitlab::Json.parse(read_fixture_file('parsed_event.json'))
+
+ ErrorTracking::CollectErrorService
+ .new(project, nil, event: parsed_event)
+ .execute
+ end
+
+ private
+
+ def read_fixture_file(file)
+ File.read(fixture_path(file))
+ end
+
+ def fixture_path(file)
+ Rails.root.join('spec', 'fixtures', 'error_tracking', file)
+ end
+end
+
+
+Gitlab::Seeder.quiet do
+ admin_user = User.admins.first
+
+ Project.not_mass_generated.visible_to_user(admin_user).sample(1).each do |project|
+ puts "\nActivating integrated error tracking for the '#{project.full_path}' project"
+
+ unless Feature.enabled?(:integrated_error_tracking, project)
+ puts '- enabling feature flag'
+ Feature.enable(:integrated_error_tracking, project)
+ end
+
+ puts '- enabling in settings'
+ project.error_tracking_setting || project.create_error_tracking_setting
+ project.error_tracking_setting.update!(enabled: true, integrated: true)
+
+ puts '- seeding an error'
+ seeder = Gitlab::Seeder::ErrorTrackingSeeder.new(project)
+ seeder.seed
+ end
+end
diff --git a/db/migrate/20201203144655_add_allow_to_edit_commit_to_project_settings.rb b/db/migrate/20201203144655_add_allow_to_edit_commit_to_project_settings.rb
index efca683d748..fb2f7366955 100644
--- a/db/migrate/20201203144655_add_allow_to_edit_commit_to_project_settings.rb
+++ b/db/migrate/20201203144655_add_allow_to_edit_commit_to_project_settings.rb
@@ -6,14 +6,10 @@ class AddAllowToEditCommitToProjectSettings < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
- with_lock_retries do
- add_column :project_settings, :allow_editing_commit_messages, :boolean, default: false, null: false
- end
+ # no-op
end
def down
- with_lock_retries do
- remove_column :project_settings, :allow_editing_commit_messages
- end
+ # no-op
end
end
diff --git a/db/migrate/20210611082822_add_pages_file_entries_to_plan_limits.rb b/db/migrate/20210611082822_add_pages_file_entries_to_plan_limits.rb
new file mode 100644
index 00000000000..ef2177fa9ce
--- /dev/null
+++ b/db/migrate/20210611082822_add_pages_file_entries_to_plan_limits.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddPagesFileEntriesToPlanLimits < ActiveRecord::Migration[6.1]
+ def change
+ add_column(:plan_limits, :pages_file_entries, :integer, default: 200_000, null: false)
+ end
+end
diff --git a/db/migrate/20210628154900_create_detached_partitions_table.rb b/db/migrate/20210628154900_create_detached_partitions_table.rb
new file mode 100644
index 00000000000..05290f4dfb9
--- /dev/null
+++ b/db/migrate/20210628154900_create_detached_partitions_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateDetachedPartitionsTable < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def change
+ create_table_with_constraints :detached_partitions do |t|
+ t.timestamps_with_timezone null: false
+ t.datetime_with_timezone :drop_after, null: false
+ t.text :table_name, null: false
+
+ # Postgres identifier names can be up to 63 bytes
+ # See https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
+ t.text_limit :table_name, 63
+ end
+ end
+end
diff --git a/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb b/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb
new file mode 100644
index 00000000000..5db39334550
--- /dev/null
+++ b/db/migrate/20210629031900_associate_existing_dast_builds_with_variables.rb
@@ -0,0 +1,77 @@
+# frozen_string_literal: true
+
+class AssociateExistingDastBuildsWithVariables < ActiveRecord::Migration[6.1]
+ disable_ddl_transaction!
+
+ class Profile < ApplicationRecord
+ self.table_name = 'dast_profiles'
+ self.inheritance_column = :_type_disabled
+ end
+
+ class ProfilesPipeline < ApplicationRecord
+ include EachBatch
+
+ self.table_name = 'dast_profiles_pipelines'
+ self.inheritance_column = :_type_disabled
+
+ belongs_to :profile, foreign_key: :dast_profile_id
+ end
+
+ class Build < ApplicationRecord
+ self.table_name = 'ci_builds'
+ self.inheritance_column = :_type_disabled
+
+ default_scope { where(name: :dast, stage: :dast) } # rubocop:disable Cop/DefaultScope
+ end
+
+ class SiteProfilesBuild < ApplicationRecord
+ self.table_name = 'dast_site_profiles_builds'
+ self.inheritance_column = :_type_disabled
+ end
+
+ BATCH_SIZE = 300
+
+ def up
+ process_batch do |batch|
+ bulk_inserts = []
+
+ grouped_builds = fetch_builds(batch).group_by(&:commit_id)
+
+ batch.includes(:profile).each do |profile_pipeline|
+ builds = grouped_builds[profile_pipeline.ci_pipeline_id]
+
+ next if builds.blank?
+
+ builds.each do |build|
+ bulk_inserts.push(dast_site_profile_id: profile_pipeline.profile.dast_site_profile_id, ci_build_id: build.id)
+ end
+ end
+
+ SiteProfilesBuild.insert_all(bulk_inserts, unique_by: :ci_build_id)
+ end
+ end
+
+ def down
+ process_batch do |batch|
+ builds = fetch_builds(batch)
+
+ SiteProfilesBuild
+ .where(ci_build_id: builds)
+ .delete_all
+ end
+ end
+
+ private
+
+ def fetch_builds(batch)
+ # pluck necessary to support ci table decomposition
+ # https://gitlab.com/groups/gitlab-org/-/epics/6289
+ Build.where(commit_id: batch.pluck(:ci_pipeline_id))
+ end
+
+ def process_batch
+ ProfilesPipeline.each_batch(of: BATCH_SIZE, column: :ci_pipeline_id) do |batch|
+ yield(batch)
+ end
+ end
+end
diff --git a/db/migrate/20210630222522_add_customers_dot_jwt_signing_key_to_application_settings.rb b/db/migrate/20210630222522_add_customers_dot_jwt_signing_key_to_application_settings.rb
new file mode 100644
index 00000000000..5df0f84ab78
--- /dev/null
+++ b/db/migrate/20210630222522_add_customers_dot_jwt_signing_key_to_application_settings.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddCustomersDotJwtSigningKeyToApplicationSettings < ActiveRecord::Migration[6.1]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :encrypted_customers_dot_jwt_signing_key, :binary
+ add_column :application_settings, :encrypted_customers_dot_jwt_signing_key_iv, :binary
+ end
+end
diff --git a/db/migrate/20210630224625_generate_customers_dot_jwt_signing_key.rb b/db/migrate/20210630224625_generate_customers_dot_jwt_signing_key.rb
new file mode 100644
index 00000000000..703b2c7d0b8
--- /dev/null
+++ b/db/migrate/20210630224625_generate_customers_dot_jwt_signing_key.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class GenerateCustomersDotJwtSigningKey < ActiveRecord::Migration[6.1]
+ DOWNTIME = false
+
+ class ApplicationSetting < ActiveRecord::Base
+ self.table_name = 'application_settings'
+
+ attr_encrypted :customers_dot_jwt_signing_key, {
+ mode: :per_attribute_iv,
+ key: Gitlab::Utils.ensure_utf8_size(Rails.application.secrets.db_key_base, bytes: 32.bytes),
+ algorithm: 'aes-256-gcm',
+ encode: true
+ }
+ end
+
+ def up
+ ApplicationSetting.reset_column_information
+
+ ApplicationSetting.find_each do |application_setting|
+ application_setting.update(customers_dot_jwt_signing_key: OpenSSL::PKey::RSA.new(2048).to_pem)
+ end
+ end
+
+ def down
+ ApplicationSetting.reset_column_information
+
+ ApplicationSetting.find_each do |application_setting|
+ application_setting.update_columns(encrypted_customers_dot_jwt_signing_key: nil, encrypted_customers_dot_jwt_signing_key_iv: nil)
+ end
+ end
+end
diff --git a/db/migrate/20210706151154_add_remaining_ci_minutes_to_ci_pending_build.rb b/db/migrate/20210706151154_add_remaining_ci_minutes_to_ci_pending_build.rb
new file mode 100644
index 00000000000..866b16a6bb9
--- /dev/null
+++ b/db/migrate/20210706151154_add_remaining_ci_minutes_to_ci_pending_build.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddRemainingCiMinutesToCiPendingBuild < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column(:ci_pending_builds, :namespace_id, :bigint)
+ add_column(:ci_pending_builds, :minutes_exceeded, :boolean, null: false, default: false)
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column(:ci_pending_builds, :minutes_exceeded)
+ remove_column(:ci_pending_builds, :namespace_id)
+ end
+ end
+end
diff --git a/db/migrate/20210706151446_add_namespace_foreign_key_to_ci_pending_build.rb b/db/migrate/20210706151446_add_namespace_foreign_key_to_ci_pending_build.rb
new file mode 100644
index 00000000000..2a04850d905
--- /dev/null
+++ b/db/migrate/20210706151446_add_namespace_foreign_key_to_ci_pending_build.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddNamespaceForeignKeyToCiPendingBuild < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+ INDEX_NAME = 'index_ci_pending_builds_on_namespace_id'
+
+ def up
+ add_concurrent_index(:ci_pending_builds, :namespace_id, name: INDEX_NAME)
+ add_concurrent_foreign_key(:ci_pending_builds, :namespaces, column: :namespace_id, on_delete: :cascade)
+ end
+
+ def down
+ remove_foreign_key_if_exists(:ci_pending_builds, column: :namespace_id)
+ remove_concurrent_index_by_name(:ci_pending_builds, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20210708202548_add_scanners_column_to_approval_project_rules.rb b/db/migrate/20210708202548_add_scanners_column_to_approval_project_rules.rb
new file mode 100644
index 00000000000..a9175833dd7
--- /dev/null
+++ b/db/migrate/20210708202548_add_scanners_column_to_approval_project_rules.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddScannersColumnToApprovalProjectRules < ActiveRecord::Migration[6.1]
+ def up
+ add_column :approval_project_rules, :scanners, :text, array: true
+ end
+
+ def down
+ remove_column :approval_project_rules, :scanners
+ end
+end
diff --git a/db/migrate/20210709221051_create_work_item_types.rb b/db/migrate/20210709221051_create_work_item_types.rb
new file mode 100644
index 00000000000..749689811e0
--- /dev/null
+++ b/db/migrate/20210709221051_create_work_item_types.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class CreateWorkItemTypes < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ create_table_with_constraints :work_item_types do |t|
+ t.integer :base_type, limit: 2, default: 0, null: false
+ t.integer :cached_markdown_version
+ t.text :name, null: false
+ t.text :description # rubocop:disable Migration/AddLimitToTextColumns
+ t.text :description_html # rubocop:disable Migration/AddLimitToTextColumns
+ t.text :icon_name, null: true
+ t.references :namespace, foreign_key: { on_delete: :cascade }, index: false, null: true
+ t.timestamps_with_timezone null: false
+
+ t.text_limit :name, 255
+ t.text_limit :icon_name, 255
+ end
+
+ add_concurrent_index :work_item_types,
+ 'namespace_id, TRIM(BOTH FROM LOWER(name))',
+ unique: true,
+ name: :work_item_types_namespace_id_and_name_unique
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :work_item_types
+ end
+ end
+end
diff --git a/db/migrate/20210709221659_add_work_item_type_id_to_issue.rb b/db/migrate/20210709221659_add_work_item_type_id_to_issue.rb
new file mode 100644
index 00000000000..38292cd37c5
--- /dev/null
+++ b/db/migrate/20210709221659_add_work_item_type_id_to_issue.rb
@@ -0,0 +1,31 @@
+# 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 AddWorkItemTypeIdToIssue < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:issues, :work_item_type_id)
+ with_lock_retries do
+ add_column :issues, :work_item_type_id, :bigint
+ end
+ end
+
+ add_concurrent_index :issues, :work_item_type_id
+ add_concurrent_foreign_key :issues, :work_item_types, column: :work_item_type_id, on_delete: nil
+ end
+
+ def down
+ if foreign_key_exists?(:issues, :work_item_types)
+ remove_foreign_key :issues, column: :work_item_type_id
+ end
+
+ with_lock_retries do
+ remove_column :issues, :work_item_type_id
+ end
+ end
+end
diff --git a/db/migrate/20210712052519_add_label_applied_issuable_closed_to_issuable_sla.rb b/db/migrate/20210712052519_add_label_applied_issuable_closed_to_issuable_sla.rb
new file mode 100644
index 00000000000..216d43dd62d
--- /dev/null
+++ b/db/migrate/20210712052519_add_label_applied_issuable_closed_to_issuable_sla.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class AddLabelAppliedIssuableClosedToIssuableSla < ActiveRecord::Migration[6.1]
+ def change
+ add_column :issuable_slas, :label_applied, :boolean, default: false, null: false
+ add_column :issuable_slas, :issuable_closed, :boolean, default: false, null: false
+ end
+end
diff --git a/db/migrate/20210713123345_create_dast_profile_schedule.rb b/db/migrate/20210713123345_create_dast_profile_schedule.rb
new file mode 100644
index 00000000000..951aab63579
--- /dev/null
+++ b/db/migrate/20210713123345_create_dast_profile_schedule.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class CreateDastProfileSchedule < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = 'index_dast_profile_schedules_active_next_run_at'
+
+ def up
+ table_comment = {
+ owner: 'group::dynamic analysis', description: 'Scheduling for scans using DAST Profiles'
+ }
+
+ create_table_with_constraints :dast_profile_schedules, comment: table_comment.to_json do |t|
+ t.bigint :project_id, null: false
+ t.bigint :dast_profile_id, null: false
+ t.bigint :user_id
+
+ t.datetime_with_timezone :next_run_at, null: false
+ t.timestamps_with_timezone null: false
+ t.boolean :active, default: true, null: false
+ t.text :cron, null: false
+ t.text_limit :cron, 255
+
+ t.index %i[active next_run_at], name: INDEX_NAME
+ t.index %i[project_id dast_profile_id], unique: true
+ t.index :dast_profile_id
+ t.index :user_id
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :dast_profile_schedules
+ end
+ end
+end
diff --git a/db/migrate/20210713211008_create_banned_users.rb b/db/migrate/20210713211008_create_banned_users.rb
new file mode 100644
index 00000000000..7e5eb7f95b8
--- /dev/null
+++ b/db/migrate/20210713211008_create_banned_users.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class CreateBannedUsers < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ with_lock_retries do
+ create_table :banned_users, id: false do |t|
+ t.timestamps_with_timezone null: false
+ t.references :user, primary_key: true, default: nil, foreign_key: { on_delete: :cascade }, type: :bigint, index: false, null: false
+ end
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :banned_users
+ end
+ end
+end
diff --git a/db/migrate/20210713223941_remove_null_constraint_from_security_findings.rb b/db/migrate/20210713223941_remove_null_constraint_from_security_findings.rb
new file mode 100644
index 00000000000..f0b9addb5f2
--- /dev/null
+++ b/db/migrate/20210713223941_remove_null_constraint_from_security_findings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveNullConstraintFromSecurityFindings < ActiveRecord::Migration[6.1]
+ def up
+ change_column_null :security_findings, :project_fingerprint, true
+ end
+
+ def down
+ # no-op, it can not be reverted due to existing records that might not be valid
+ end
+end
diff --git a/db/migrate/20210714043818_add_index_for_label_applied_to_issuable_sla.rb b/db/migrate/20210714043818_add_index_for_label_applied_to_issuable_sla.rb
new file mode 100644
index 00000000000..5931941a95e
--- /dev/null
+++ b/db/migrate/20210714043818_add_index_for_label_applied_to_issuable_sla.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexForLabelAppliedToIssuableSla < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_issuable_slas_on_due_at_id_label_applied_issuable_closed'
+
+ def up
+ add_concurrent_index :issuable_slas, [:due_at, :id], name: INDEX_NAME, where: 'label_applied = FALSE AND issuable_closed = FALSE'
+ end
+
+ def down
+ remove_concurrent_index_by_name :issuable_slas, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210715074359_add_foreign_key_to_dast_profile_schedules_on_dast_profile.rb b/db/migrate/20210715074359_add_foreign_key_to_dast_profile_schedules_on_dast_profile.rb
new file mode 100644
index 00000000000..c042a875f57
--- /dev/null
+++ b/db/migrate/20210715074359_add_foreign_key_to_dast_profile_schedules_on_dast_profile.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToDastProfileSchedulesOnDastProfile < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :dast_profile_schedules, :dast_profiles, column: :dast_profile_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :dast_profile_schedules, column: :dast_profile_id
+ end
+ end
+end
diff --git a/db/migrate/20210715074933_add_foreign_key_to_dast_profile_schedules_on_user.rb b/db/migrate/20210715074933_add_foreign_key_to_dast_profile_schedules_on_user.rb
new file mode 100644
index 00000000000..576cee090ff
--- /dev/null
+++ b/db/migrate/20210715074933_add_foreign_key_to_dast_profile_schedules_on_user.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToDastProfileSchedulesOnUser < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :dast_profile_schedules, :users, column: :user_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :dast_profile_schedules, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20210715075203_add_foreign_key_to_dast_profile_schedules_on_project.rb b/db/migrate/20210715075203_add_foreign_key_to_dast_profile_schedules_on_project.rb
new file mode 100644
index 00000000000..cfc76c4a12c
--- /dev/null
+++ b/db/migrate/20210715075203_add_foreign_key_to_dast_profile_schedules_on_project.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToDastProfileSchedulesOnProject < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :dast_profile_schedules, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :dast_profile_schedules, column: :project_id
+ end
+ end
+end
diff --git a/db/migrate/20210719145532_add_foreign_keys_view.rb b/db/migrate/20210719145532_add_foreign_keys_view.rb
new file mode 100644
index 00000000000..2d31371e782
--- /dev/null
+++ b/db/migrate/20210719145532_add_foreign_keys_view.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class AddForeignKeysView < ActiveRecord::Migration[6.1]
+ def up
+ execute(<<~SQL)
+ CREATE OR REPLACE VIEW postgres_foreign_keys AS
+ SELECT
+ pg_constraint.oid AS oid,
+ pg_constraint.conname AS name,
+ constrained_namespace.nspname::text || '.'::text || constrained_table.relname::text AS constrained_table_identifier,
+ referenced_namespace.nspname::text || '.'::text || referenced_table.relname::text AS referenced_table_identifier
+ FROM pg_constraint
+ INNER JOIN pg_class constrained_table ON constrained_table.oid = pg_constraint.conrelid
+ INNER JOIN pg_class referenced_table ON referenced_table.oid = pg_constraint.confrelid
+ INNER JOIN pg_namespace constrained_namespace ON constrained_table.relnamespace = constrained_namespace.oid
+ INNER JOIN pg_namespace referenced_namespace ON referenced_table.relnamespace = referenced_namespace.oid
+ WHERE contype = 'f';
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ DROP VIEW IF EXISTS postgres_foreign_keys
+ SQL
+ end
+end
diff --git a/db/migrate/20210719182944_add_request_response_to_supporing_message.rb b/db/migrate/20210719182944_add_request_response_to_supporing_message.rb
new file mode 100644
index 00000000000..a374361e88d
--- /dev/null
+++ b/db/migrate/20210719182944_add_request_response_to_supporing_message.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddRequestResponseToSupporingMessage < ActiveRecord::Migration[6.1]
+ def change
+ change_column_null(:vulnerability_finding_evidence_requests, :vulnerability_finding_evidence_id, true)
+ change_column_null(:vulnerability_finding_evidence_responses, :vulnerability_finding_evidence_id, true)
+
+ # rubocop: disable Migration/AddReference
+ # Table is empty, so no need to use add_concurrent_foreign_key and add_concurrent_index
+ add_reference(:vulnerability_finding_evidence_requests,
+ :vulnerability_finding_evidence_supporting_message,
+ index: { name: 'finding_evidence_requests_on_supporting_evidence_id' },
+ foreign_key: { on_delete: :cascade })
+ add_reference(:vulnerability_finding_evidence_responses,
+ :vulnerability_finding_evidence_supporting_message,
+ index: { name: 'finding_evidence_responses_on_supporting_evidence_id' },
+ foreign_key: { on_delete: :cascade })
+ # rubocop:enable Migration/AddReference
+ end
+end
diff --git a/db/migrate/20210719192928_add_invite_email_success_to_member.rb b/db/migrate/20210719192928_add_invite_email_success_to_member.rb
new file mode 100644
index 00000000000..ad629483a82
--- /dev/null
+++ b/db/migrate/20210719192928_add_invite_email_success_to_member.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddInviteEmailSuccessToMember < ActiveRecord::Migration[6.1]
+ def up
+ # no-op
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20210720130006_create_error_tracking_client_keys.rb b/db/migrate/20210720130006_create_error_tracking_client_keys.rb
new file mode 100644
index 00000000000..caea4a3d65b
--- /dev/null
+++ b/db/migrate/20210720130006_create_error_tracking_client_keys.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreateErrorTrackingClientKeys < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ create_table_with_constraints :error_tracking_client_keys do |t|
+ t.references :project,
+ index: true,
+ null: false,
+ foreign_key: { on_delete: :cascade }
+
+ t.boolean :active, default: true, null: false
+ t.text :public_key, null: false
+ t.text_limit :public_key, 255
+
+ t.timestamps_with_timezone
+ end
+ end
+
+ def down
+ drop_table :error_tracking_client_keys
+ end
+end
diff --git a/db/migrate/20210720140841_create_postgres_async_indexes_table.rb b/db/migrate/20210720140841_create_postgres_async_indexes_table.rb
new file mode 100644
index 00000000000..707367e5f6c
--- /dev/null
+++ b/db/migrate/20210720140841_create_postgres_async_indexes_table.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CreatePostgresAsyncIndexesTable < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def change
+ create_table_with_constraints :postgres_async_indexes do |t|
+ t.timestamps_with_timezone null: false
+
+ t.text :name, null: false
+ t.text :definition, null: false
+ t.text :table_name, null: false
+
+ t.text_limit :name, 63
+ t.text_limit :definition, 2048
+ t.text_limit :table_name, 63
+
+ t.index :name, unique: true
+ end
+ end
+end
diff --git a/db/migrate/20210721125525_add_signed_file_to_packages_debian_project_distributions.rb b/db/migrate/20210721125525_add_signed_file_to_packages_debian_project_distributions.rb
new file mode 100644
index 00000000000..7e4a785cb54
--- /dev/null
+++ b/db/migrate/20210721125525_add_signed_file_to_packages_debian_project_distributions.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddSignedFileToPackagesDebianProjectDistributions < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files
+ def change
+ add_column :packages_debian_project_distributions, :signed_file, :text
+ add_column :packages_debian_project_distributions, :signed_file_store, :integer, limit: 2, default: 1, null: false
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20210721125545_add_signed_file_to_packages_debian_group_distributions.rb b/db/migrate/20210721125545_add_signed_file_to_packages_debian_group_distributions.rb
new file mode 100644
index 00000000000..f27c158bed2
--- /dev/null
+++ b/db/migrate/20210721125545_add_signed_file_to_packages_debian_group_distributions.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddSignedFileToPackagesDebianGroupDistributions < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files
+ def change
+ add_column :packages_debian_group_distributions, :signed_file, :text
+ add_column :packages_debian_group_distributions, :signed_file_store, :integer, limit: 2, default: 1, null: false
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files.rb b/db/migrate/20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files.rb
new file mode 100644
index 00000000000..77524a5b068
--- /dev/null
+++ b/db/migrate/20210721125620_add_text_limit_to_packages_debian_project_distributions_signed_files.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddTextLimitToPackagesDebianProjectDistributionsSignedFiles < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :packages_debian_project_distributions, :signed_file, 255
+ end
+
+ def down
+ remove_text_limit :packages_debian_project_distributions, :signed_file
+ end
+end
diff --git a/db/migrate/20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files.rb b/db/migrate/20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files.rb
new file mode 100644
index 00000000000..ef203cb2ff7
--- /dev/null
+++ b/db/migrate/20210721125637_add_text_limit_to_packages_debian_group_distributions_signed_files.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddTextLimitToPackagesDebianGroupDistributionsSignedFiles < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :packages_debian_group_distributions, :signed_file, 255
+ end
+
+ def down
+ remove_text_limit :packages_debian_group_distributions, :signed_file
+ end
+end
diff --git a/db/migrate/20210721134706_add_type_new_to_integrations.rb b/db/migrate/20210721134706_add_type_new_to_integrations.rb
new file mode 100644
index 00000000000..b43fb73436c
--- /dev/null
+++ b/db/migrate/20210721134706_add_type_new_to_integrations.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddTypeNewToIntegrations < ActiveRecord::Migration[6.1]
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20210721134707_add_text_limit_to_integrations_type_new
+ def change
+ add_column :integrations, :type_new, :text
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+end
diff --git a/db/migrate/20210721134707_add_text_limit_to_integrations_type_new.rb b/db/migrate/20210721134707_add_text_limit_to_integrations_type_new.rb
new file mode 100644
index 00000000000..8fb98abad8c
--- /dev/null
+++ b/db/migrate/20210721134707_add_text_limit_to_integrations_type_new.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddTextLimitToIntegrationsTypeNew < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :integrations, :type_new, 255
+ end
+
+ def down
+ remove_text_limit :integrations, :type_new
+ end
+end
diff --git a/db/migrate/20210721135638_add_triggers_to_integrations_type_new.rb b/db/migrate/20210721135638_add_triggers_to_integrations_type_new.rb
new file mode 100644
index 00000000000..6b1f2aeba18
--- /dev/null
+++ b/db/migrate/20210721135638_add_triggers_to_integrations_type_new.rb
@@ -0,0 +1,79 @@
+# frozen_string_literal: true
+
+class AddTriggersToIntegrationsTypeNew < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::SchemaHelpers
+
+ FUNCTION_NAME = 'integrations_set_type_new'
+ TRIGGER_ON_INSERT_NAME = 'trigger_type_new_on_insert'
+
+ def up
+ create_trigger_function(FUNCTION_NAME, replace: true) do
+ # This list matches `Gitlab::Integrations::StiType::NAMESPACED_INTEGRATIONS`.
+ #
+ # If we add new integrations after this migration we can directly use the
+ # correct class name in `type`, and don't need to add it to `NAMESPACED_INTEGRATIONS`.
+ <<~SQL
+ WITH mapping(old_type, new_type) AS (VALUES
+ ('AsanaService', 'Integrations::Asana'),
+ ('AssemblaService', 'Integrations::Assembla'),
+ ('BambooService', 'Integrations::Bamboo'),
+ ('BugzillaService', 'Integrations::Bugzilla'),
+ ('BuildkiteService', 'Integrations::Buildkite'),
+ ('CampfireService', 'Integrations::Campfire'),
+ ('ConfluenceService', 'Integrations::Confluence'),
+ ('CustomIssueTrackerService', 'Integrations::CustomIssueTracker'),
+ ('DatadogService', 'Integrations::Datadog'),
+ ('DiscordService', 'Integrations::Discord'),
+ ('DroneCiService', 'Integrations::DroneCi'),
+ ('EmailsOnPushService', 'Integrations::EmailsOnPush'),
+ ('EwmService', 'Integrations::Ewm'),
+ ('ExternalWikiService', 'Integrations::ExternalWiki'),
+ ('FlowdockService', 'Integrations::Flowdock'),
+ ('HangoutsChatService', 'Integrations::HangoutsChat'),
+ ('IrkerService', 'Integrations::Irker'),
+ ('JenkinsService', 'Integrations::Jenkins'),
+ ('JiraService', 'Integrations::Jira'),
+ ('MattermostService', 'Integrations::Mattermost'),
+ ('MattermostSlashCommandsService', 'Integrations::MattermostSlashCommands'),
+ ('MicrosoftTeamsService', 'Integrations::MicrosoftTeams'),
+ ('MockCiService', 'Integrations::MockCi'),
+ ('MockMonitoringService', 'Integrations::MockMonitoring'),
+ ('PackagistService', 'Integrations::Packagist'),
+ ('PipelinesEmailService', 'Integrations::PipelinesEmail'),
+ ('PivotaltrackerService', 'Integrations::Pivotaltracker'),
+ ('PrometheusService', 'Integrations::Prometheus'),
+ ('PushoverService', 'Integrations::Pushover'),
+ ('RedmineService', 'Integrations::Redmine'),
+ ('SlackService', 'Integrations::Slack'),
+ ('SlackSlashCommandsService', 'Integrations::SlackSlashCommands'),
+ ('TeamcityService', 'Integrations::Teamcity'),
+ ('UnifyCircuitService', 'Integrations::UnifyCircuit'),
+ ('YoutrackService', 'Integrations::Youtrack'),
+ ('WebexTeamsService', 'Integrations::WebexTeams'),
+
+ -- EE-only integrations
+ ('GithubService', 'Integrations::Github'),
+ ('GitlabSlackApplicationService', 'Integrations::GitlabSlackApplication')
+ )
+
+ UPDATE integrations SET type_new = mapping.new_type
+ FROM mapping
+ WHERE integrations.id = NEW.id
+ AND mapping.old_type = NEW.type;
+ RETURN NULL;
+ SQL
+ end
+
+ execute(<<~SQL)
+ CREATE TRIGGER #{TRIGGER_ON_INSERT_NAME}
+ AFTER INSERT ON integrations
+ FOR EACH ROW
+ EXECUTE FUNCTION #{FUNCTION_NAME}();
+ SQL
+ end
+
+ def down
+ drop_trigger(:integrations, TRIGGER_ON_INSERT_NAME)
+ drop_function(FUNCTION_NAME)
+ end
+end
diff --git a/db/migrate/20210721145029_add_state_to_members.rb b/db/migrate/20210721145029_add_state_to_members.rb
new file mode 100644
index 00000000000..d727c858374
--- /dev/null
+++ b/db/migrate/20210721145029_add_state_to_members.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddStateToMembers < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ # no-op
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20210721174411_add_is_removed_to_escalation_rules.rb b/db/migrate/20210721174411_add_is_removed_to_escalation_rules.rb
new file mode 100644
index 00000000000..00af9414ab7
--- /dev/null
+++ b/db/migrate/20210721174411_add_is_removed_to_escalation_rules.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddIsRemovedToEscalationRules < ActiveRecord::Migration[6.1]
+ def change
+ add_column :incident_management_escalation_rules, :is_removed, :boolean, null: false, default: false
+ end
+end
diff --git a/db/migrate/20210721174441_update_escalation_rule_fk_for_pending_alert_escalations.rb b/db/migrate/20210721174441_update_escalation_rule_fk_for_pending_alert_escalations.rb
new file mode 100644
index 00000000000..cf52a43435f
--- /dev/null
+++ b/db/migrate/20210721174441_update_escalation_rule_fk_for_pending_alert_escalations.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class UpdateEscalationRuleFkForPendingAlertEscalations < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+ include Gitlab::Database::PartitioningMigrationHelpers
+
+ disable_ddl_transaction!
+
+ OLD_FOREIGN_KEY_CONSTRAINT = 'fk_rails_057c1e3d87'
+
+ # Swap foreign key contrainst from ON DELETE SET NULL to ON DELETE CASCADE
+ def up
+ remove_foreign_key_if_exists :incident_management_pending_alert_escalations, :incident_management_escalation_rules, name: OLD_FOREIGN_KEY_CONSTRAINT
+
+ add_concurrent_partitioned_foreign_key :incident_management_pending_alert_escalations,
+ :incident_management_escalation_rules,
+ column: :rule_id
+ end
+
+ def down
+ remove_foreign_key_if_exists :incident_management_pending_alert_escalations, :incident_management_escalation_rules, column: :rule_id
+
+ add_concurrent_partitioned_foreign_key :incident_management_pending_alert_escalations,
+ :incident_management_escalation_rules,
+ column: :rule_id,
+ on_delete: :nullify,
+ name: OLD_FOREIGN_KEY_CONSTRAINT
+ end
+end
diff --git a/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb b/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb
new file mode 100644
index 00000000000..89adaf89693
--- /dev/null
+++ b/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class RemoveScheduleAndStatusNullConstraintsFromPendingEscalationsAlert < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ # In preparation of removal of these columns in 14.3.
+ def up
+ with_lock_retries do
+ change_column_null :incident_management_pending_alert_escalations, :status, true
+ change_column_null :incident_management_pending_alert_escalations, :schedule_id, true
+ end
+ end
+
+ def down
+ backfill_from_rules_and_disallow_column_null :status, value: :status
+ backfill_from_rules_and_disallow_column_null :schedule_id, value: :oncall_schedule_id
+ end
+
+ private
+
+ def backfill_from_rules_and_disallow_column_null(column, value:)
+ with_lock_retries do
+ execute <<~SQL
+ UPDATE incident_management_pending_alert_escalations AS escalations
+ SET #{column} = rules.#{value}
+ FROM incident_management_escalation_rules AS rules
+ WHERE rule_id = rules.id
+ AND escalations.#{column} IS NULL
+ SQL
+
+ change_column_null :incident_management_pending_alert_escalations, column, false
+ end
+ end
+end
diff --git a/db/migrate/20210721211602_add_vulnerability_amount_column_into_approval_project_rules.rb b/db/migrate/20210721211602_add_vulnerability_amount_column_into_approval_project_rules.rb
new file mode 100644
index 00000000000..3c0fa35d9c3
--- /dev/null
+++ b/db/migrate/20210721211602_add_vulnerability_amount_column_into_approval_project_rules.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddVulnerabilityAmountColumnIntoApprovalProjectRules < ActiveRecord::Migration[6.1]
+ def up
+ add_column :approval_project_rules, :vulnerabilities_allowed, :integer, limit: 2
+ end
+
+ def down
+ remove_column :approval_project_rules, :vulnerabilities_allowed
+ end
+end
diff --git a/db/migrate/20210722074220_remove_null_constraint_on_schedule_from_escalation_rules.rb b/db/migrate/20210722074220_remove_null_constraint_on_schedule_from_escalation_rules.rb
new file mode 100644
index 00000000000..7146c6c9537
--- /dev/null
+++ b/db/migrate/20210722074220_remove_null_constraint_on_schedule_from_escalation_rules.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RemoveNullConstraintOnScheduleFromEscalationRules < ActiveRecord::Migration[6.1]
+ def up
+ change_column_null :incident_management_escalation_rules, :oncall_schedule_id, true
+ end
+
+ def down
+ exec_query 'DELETE FROM incident_management_escalation_rules WHERE oncall_schedule_id IS NULL'
+
+ change_column_null :incident_management_escalation_rules, :oncall_schedule_id, false
+ end
+end
diff --git a/db/migrate/20210722074242_add_user_to_escalation_rules.rb b/db/migrate/20210722074242_add_user_to_escalation_rules.rb
new file mode 100644
index 00000000000..061dd6194f7
--- /dev/null
+++ b/db/migrate/20210722074242_add_user_to_escalation_rules.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddUserToEscalationRules < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ with_lock_retries do
+ add_column :incident_management_escalation_rules, :user_id, :bigint, null: true
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :incident_management_escalation_rules, :user_id
+ end
+ end
+end
diff --git a/db/migrate/20210722074256_add_user_index_to_escalation_rules.rb b/db/migrate/20210722074256_add_user_index_to_escalation_rules.rb
new file mode 100644
index 00000000000..047149d6e7c
--- /dev/null
+++ b/db/migrate/20210722074256_add_user_index_to_escalation_rules.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class AddUserIndexToEscalationRules < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ USER_INDEX_NAME = 'index_escalation_rules_on_user'
+ OLD_UNIQUE_INDEX_NAME = 'index_on_policy_schedule_status_elapsed_time_escalation_rules'
+ NEW_UNIQUE_INDEX_NAME = 'index_escalation_rules_on_all_attributes'
+
+ def up
+ remove_concurrent_index_by_name :incident_management_escalation_rules, OLD_UNIQUE_INDEX_NAME
+
+ add_concurrent_index :incident_management_escalation_rules, :user_id, name: USER_INDEX_NAME
+ add_concurrent_index :incident_management_escalation_rules,
+ [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds, :user_id],
+ unique: true,
+ name: NEW_UNIQUE_INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :incident_management_escalation_rules, USER_INDEX_NAME
+ remove_concurrent_index_by_name :incident_management_escalation_rules, NEW_UNIQUE_INDEX_NAME
+
+ exec_query 'DELETE FROM incident_management_escalation_rules WHERE oncall_schedule_id IS NULL'
+
+ add_concurrent_index :incident_management_escalation_rules,
+ [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds],
+ unique: true,
+ name: OLD_UNIQUE_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210722074309_add_user_fk_to_escalation_rules.rb b/db/migrate/20210722074309_add_user_fk_to_escalation_rules.rb
new file mode 100644
index 00000000000..acdfc1ed835
--- /dev/null
+++ b/db/migrate/20210722074309_add_user_fk_to_escalation_rules.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddUserFkToEscalationRules < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :incident_management_escalation_rules, :users, column: :user_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :incident_management_escalation_rules, column: :user_id
+ end
+ end
+end
diff --git a/db/migrate/20210722074339_add_xor_check_constraint_for_escalation_rules.rb b/db/migrate/20210722074339_add_xor_check_constraint_for_escalation_rules.rb
new file mode 100644
index 00000000000..bd140e1da56
--- /dev/null
+++ b/db/migrate/20210722074339_add_xor_check_constraint_for_escalation_rules.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddXorCheckConstraintForEscalationRules < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = 'escalation_rules_one_of_oncall_schedule_or_user'
+
+ def up
+ add_check_constraint :incident_management_escalation_rules, 'num_nonnulls(oncall_schedule_id, user_id) = 1', CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :incident_management_escalation_rules, CONSTRAINT_NAME
+ end
+end
diff --git a/db/migrate/20210722132844_devops_adoption_drop_redundant_indexes.rb b/db/migrate/20210722132844_devops_adoption_drop_redundant_indexes.rb
new file mode 100644
index 00000000000..3f74f72454d
--- /dev/null
+++ b/db/migrate/20210722132844_devops_adoption_drop_redundant_indexes.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class DevopsAdoptionDropRedundantIndexes < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ INDEX_SAST = 'index_ci_job_artifacts_sast_for_devops_adoption'
+ INDEX_DAST = 'index_ci_job_artifacts_dast_for_devops_adoption'
+
+ def up
+ remove_concurrent_index_by_name :ci_job_artifacts, INDEX_SAST
+ remove_concurrent_index_by_name :ci_job_artifacts, INDEX_DAST
+ end
+
+ def down
+ add_concurrent_index :ci_job_artifacts, [:project_id, :created_at], where: "file_type = 5", name: INDEX_SAST
+ add_concurrent_index :ci_job_artifacts, [:project_id, :created_at], where: "file_type = 8", name: INDEX_DAST
+ end
+end
diff --git a/db/migrate/20210722150102_operations_feature_flags_correct_flexible_rollout_values.rb b/db/migrate/20210722150102_operations_feature_flags_correct_flexible_rollout_values.rb
new file mode 100644
index 00000000000..974559239d7
--- /dev/null
+++ b/db/migrate/20210722150102_operations_feature_flags_correct_flexible_rollout_values.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class OperationsFeatureFlagsCorrectFlexibleRolloutValues < ActiveRecord::Migration[6.1]
+ STICKINESS = { "USERID" => "userId", "RANDOM" => "random", "SESSIONID" => "sessionId", "DEFAULT" => "default" }.freeze
+
+ def up
+ STICKINESS.each do |before, after|
+ update_statement = <<-SQL
+ UPDATE operations_strategies
+ SET parameters = parameters || jsonb_build_object('stickiness', '#{quote_string(after)}')
+ WHERE name = 'flexibleRollout' AND parameters->>'stickiness' = '#{quote_string(before)}'
+ SQL
+
+ execute(update_statement)
+ end
+ end
+
+ def down
+ STICKINESS.each do |before, after|
+ update_statement = <<-SQL
+ UPDATE operations_strategies
+ SET parameters = parameters || jsonb_build_object('stickiness', '#{quote_string(before)}')
+ WHERE name = 'flexibleRollout' AND parameters->>'stickiness' = '#{quote_string(after)}'
+ SQL
+
+ execute(update_statement)
+ end
+ end
+end
diff --git a/db/migrate/20210722151951_add_columns_to_security_scans.rb b/db/migrate/20210722151951_add_columns_to_security_scans.rb
new file mode 100644
index 00000000000..341cef057ce
--- /dev/null
+++ b/db/migrate/20210722151951_add_columns_to_security_scans.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddColumnsToSecurityScans < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_column :security_scans, :project_id, :bigint
+ add_column :security_scans, :pipeline_id, :bigint
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :security_scans, :project_id, :bigint
+ remove_column :security_scans, :pipeline_id, :bigint
+ end
+ end
+end
diff --git a/db/migrate/20210722210041_add_overridden_uuid_to_security_findings.rb b/db/migrate/20210722210041_add_overridden_uuid_to_security_findings.rb
new file mode 100644
index 00000000000..4678aba2cff
--- /dev/null
+++ b/db/migrate/20210722210041_add_overridden_uuid_to_security_findings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddOverriddenUuidToSecurityFindings < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ with_lock_retries do
+ add_column :security_findings, :overridden_uuid, :uuid, null: true
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :security_findings, :overridden_uuid
+ end
+ end
+end
diff --git a/db/migrate/20210723173132_create_index_on_environments_auto_delete_at.rb b/db/migrate/20210723173132_create_index_on_environments_auto_delete_at.rb
new file mode 100644
index 00000000000..cfaff4d0304
--- /dev/null
+++ b/db/migrate/20210723173132_create_index_on_environments_auto_delete_at.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class CreateIndexOnEnvironmentsAutoDeleteAt < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_environments_on_state_and_auto_delete_at'
+
+ def up
+ add_concurrent_index :environments,
+ %i[auto_delete_at],
+ where: "auto_delete_at IS NOT NULL AND state = 'stopped'",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :environments, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210726134950_add_integrated_to_error_tracking_setting.rb b/db/migrate/20210726134950_add_integrated_to_error_tracking_setting.rb
new file mode 100644
index 00000000000..5fd558e0c1b
--- /dev/null
+++ b/db/migrate/20210726134950_add_integrated_to_error_tracking_setting.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddIntegratedToErrorTrackingSetting < ActiveRecord::Migration[6.1]
+ def up
+ add_column :project_error_tracking_settings, :integrated, :boolean, null: false, default: false
+ end
+
+ def down
+ remove_column :project_error_tracking_settings, :integrated
+ end
+end
diff --git a/db/migrate/20210726202748_add_vulnerability_severities_into_approval_project_rules.rb b/db/migrate/20210726202748_add_vulnerability_severities_into_approval_project_rules.rb
new file mode 100644
index 00000000000..bd17a9df5df
--- /dev/null
+++ b/db/migrate/20210726202748_add_vulnerability_severities_into_approval_project_rules.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddVulnerabilitySeveritiesIntoApprovalProjectRules < ActiveRecord::Migration[6.1]
+ def up
+ add_column :approval_project_rules, :severity_levels, :text, array: true, null: false, default: []
+ end
+
+ def down
+ remove_column :approval_project_rules, :severity_levels
+ end
+end
diff --git a/db/migrate/20210728110654_add_status_to_error_tracking_error.rb b/db/migrate/20210728110654_add_status_to_error_tracking_error.rb
new file mode 100644
index 00000000000..035f97dc963
--- /dev/null
+++ b/db/migrate/20210728110654_add_status_to_error_tracking_error.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddStatusToErrorTrackingError < ActiveRecord::Migration[6.1]
+ def up
+ add_column :error_tracking_errors, :status, :integer, null: false, default: 0, limit: 2
+ end
+
+ def down
+ remove_column :error_tracking_errors, :status
+ end
+end
diff --git a/db/migrate/20210728174349_add_fk_to_security_scans_columns.rb b/db/migrate/20210728174349_add_fk_to_security_scans_columns.rb
new file mode 100644
index 00000000000..418097b92e5
--- /dev/null
+++ b/db/migrate/20210728174349_add_fk_to_security_scans_columns.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddFkToSecurityScansColumns < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :security_scans, :project_id
+ add_concurrent_foreign_key :security_scans, :projects, column: :project_id, on_delete: :cascade
+
+ add_concurrent_index :security_scans, :pipeline_id
+ end
+
+ def down
+ remove_foreign_key :security_scans, column: :project_id
+ remove_concurrent_index_by_name :security_scans, name: 'index_security_scans_on_project_id'
+
+ remove_concurrent_index_by_name :security_scans, name: 'index_security_scans_on_pipeline_id'
+ end
+end
diff --git a/db/migrate/20210729061526_add_pronunciation_to_user_details.rb b/db/migrate/20210729061526_add_pronunciation_to_user_details.rb
new file mode 100644
index 00000000000..6e0c8f1e808
--- /dev/null
+++ b/db/migrate/20210729061526_add_pronunciation_to_user_details.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddPronunciationToUserDetails < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ # rubocop:disable Migration/AddLimitToTextColumns
+ # limit is added in 20210729061556_add_text_limit_to_user_details_pronunciation.rb
+ with_lock_retries do
+ add_column :user_details, :pronunciation, :text, null: true
+ end
+ # rubocop:enable Migration/AddLimitToTextColumns
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :user_details, :pronunciation
+ end
+ end
+end
diff --git a/db/migrate/20210729061556_add_text_limit_to_user_details_pronunciation.rb b/db/migrate/20210729061556_add_text_limit_to_user_details_pronunciation.rb
new file mode 100644
index 00000000000..5466ee7bafa
--- /dev/null
+++ b/db/migrate/20210729061556_add_text_limit_to_user_details_pronunciation.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddTextLimitToUserDetailsPronunciation < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_text_limit :user_details, :pronunciation, 255
+ end
+
+ def down
+ remove_text_limit :user_details, :pronunciation
+ end
+end
diff --git a/db/migrate/20210729123101_confirm_security_bot.rb b/db/migrate/20210729123101_confirm_security_bot.rb
new file mode 100644
index 00000000000..2184cc4e193
--- /dev/null
+++ b/db/migrate/20210729123101_confirm_security_bot.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class ConfirmSecurityBot < ActiveRecord::Migration[6.0]
+ class User < ActiveRecord::Base
+ self.table_name = 'users'
+ SECURITY_BOT_TYPE = 8
+ end
+
+ def up
+ User.where(user_type: User::SECURITY_BOT_TYPE, confirmed_at: nil)
+ .update_all(confirmed_at: Time.current)
+ end
+
+ # no-op
+ # Security Bot should be always confirmed
+ def down
+ end
+end
diff --git a/db/migrate/20210729161242_remove_foreign_keys_from_ci_test_case_failures.rb b/db/migrate/20210729161242_remove_foreign_keys_from_ci_test_case_failures.rb
new file mode 100644
index 00000000000..2193a698272
--- /dev/null
+++ b/db/migrate/20210729161242_remove_foreign_keys_from_ci_test_case_failures.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class RemoveForeignKeysFromCiTestCaseFailures < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ TABLE_NAME = :ci_test_case_failures
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(TABLE_NAME, column: :build_id)
+ end
+
+ with_lock_retries do
+ remove_foreign_key_if_exists(TABLE_NAME, column: :test_case_id)
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key(TABLE_NAME, :ci_builds, column: :build_id, on_delete: :cascade)
+ add_concurrent_foreign_key(TABLE_NAME, :ci_test_cases, column: :test_case_id, on_delete: :cascade)
+ end
+end
diff --git a/db/migrate/20210729192148_remove_foreign_keys_from_ci_test_cases.rb b/db/migrate/20210729192148_remove_foreign_keys_from_ci_test_cases.rb
new file mode 100644
index 00000000000..1d0a5f4fd64
--- /dev/null
+++ b/db/migrate/20210729192148_remove_foreign_keys_from_ci_test_cases.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RemoveForeignKeysFromCiTestCases < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ TABLE_NAME = :ci_test_cases
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(TABLE_NAME, column: :project_id)
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key(TABLE_NAME, :projects, column: :project_id, on_delete: :cascade)
+ end
+end
diff --git a/db/migrate/20210729202143_create_incident_management_issuable_escalation_statuses.rb b/db/migrate/20210729202143_create_incident_management_issuable_escalation_statuses.rb
new file mode 100644
index 00000000000..b16904a3b47
--- /dev/null
+++ b/db/migrate/20210729202143_create_incident_management_issuable_escalation_statuses.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class CreateIncidentManagementIssuableEscalationStatuses < ActiveRecord::Migration[6.1]
+ ISSUE_IDX = 'index_uniq_im_issuable_escalation_statuses_on_issue_id'
+ POLICY_IDX = 'index_im_issuable_escalation_statuses_on_policy_id'
+
+ def change
+ create_table :incident_management_issuable_escalation_statuses do |t|
+ t.timestamps_with_timezone
+
+ t.references :issue, foreign_key: { on_delete: :cascade }, index: { unique: true, name: ISSUE_IDX }, null: false
+ t.references :policy, foreign_key: { to_table: :incident_management_escalation_policies, on_delete: :nullify }, index: { name: POLICY_IDX }
+
+ t.datetime_with_timezone :escalations_started_at
+ t.datetime_with_timezone :resolved_at
+
+ t.integer :status, default: 0, null: false, limit: 2
+ end
+ end
+end
diff --git a/db/migrate/20210730101609_create_analytics_cycle_analytics_stage_event_hashes.rb b/db/migrate/20210730101609_create_analytics_cycle_analytics_stage_event_hashes.rb
new file mode 100644
index 00000000000..ad517fbbff0
--- /dev/null
+++ b/db/migrate/20210730101609_create_analytics_cycle_analytics_stage_event_hashes.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class CreateAnalyticsCycleAnalyticsStageEventHashes < ActiveRecord::Migration[6.1]
+ def change
+ create_table :analytics_cycle_analytics_stage_event_hashes do |t|
+ t.binary :hash_sha256
+ t.index :hash_sha256, unique: true, name: 'index_cycle_analytics_stage_event_hashes_on_hash_sha_256'
+ end
+ end
+end
diff --git a/db/migrate/20210730102952_add_stage_hash_fk_to_project_stages.rb b/db/migrate/20210730102952_add_stage_hash_fk_to_project_stages.rb
new file mode 100644
index 00000000000..2909df78a6a
--- /dev/null
+++ b/db/migrate/20210730102952_add_stage_hash_fk_to_project_stages.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddStageHashFkToProjectStages < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:analytics_cycle_analytics_project_stages, :stage_event_hash_id)
+ add_column :analytics_cycle_analytics_project_stages, :stage_event_hash_id, :bigint
+ end
+
+ add_concurrent_index :analytics_cycle_analytics_project_stages, :stage_event_hash_id, name: 'index_project_stages_on_stage_event_hash_id'
+ add_concurrent_foreign_key :analytics_cycle_analytics_project_stages, :analytics_cycle_analytics_stage_event_hashes, column: :stage_event_hash_id, on_delete: :cascade
+ end
+
+ def down
+ remove_column :analytics_cycle_analytics_project_stages, :stage_event_hash_id
+ end
+end
diff --git a/db/migrate/20210730103808_add_stage_hash_fk_to_group_stages.rb b/db/migrate/20210730103808_add_stage_hash_fk_to_group_stages.rb
new file mode 100644
index 00000000000..3cd53f2bb50
--- /dev/null
+++ b/db/migrate/20210730103808_add_stage_hash_fk_to_group_stages.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddStageHashFkToGroupStages < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:analytics_cycle_analytics_group_stages, :stage_event_hash_id)
+ add_column :analytics_cycle_analytics_group_stages, :stage_event_hash_id, :bigint
+ end
+
+ add_concurrent_index :analytics_cycle_analytics_group_stages, :stage_event_hash_id, name: 'index_group_stages_on_stage_event_hash_id'
+ add_concurrent_foreign_key :analytics_cycle_analytics_group_stages, :analytics_cycle_analytics_stage_event_hashes, column: :stage_event_hash_id, on_delete: :cascade
+ end
+
+ def down
+ remove_column :analytics_cycle_analytics_group_stages, :stage_event_hash_id
+ end
+end
diff --git a/db/migrate/20210803110920_add_unique_index_to_vulnerability_flags_table.rb b/db/migrate/20210803110920_add_unique_index_to_vulnerability_flags_table.rb
new file mode 100644
index 00000000000..38d72496484
--- /dev/null
+++ b/db/migrate/20210803110920_add_unique_index_to_vulnerability_flags_table.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexToVulnerabilityFlagsTable < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = 'index_vulnerability_flags_on_unique_columns'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerability_flags, [:vulnerability_occurrence_id, :flag_type, :origin], name: INDEX_NAME, unique: true
+ end
+
+ def down
+ remove_concurrent_index_by_name :vulnerability_flags, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210804150320_create_base_work_item_types.rb b/db/migrate/20210804150320_create_base_work_item_types.rb
new file mode 100644
index 00000000000..b7a44eaabe0
--- /dev/null
+++ b/db/migrate/20210804150320_create_base_work_item_types.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class CreateBaseWorkItemTypes < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ module WorkItem
+ class Type < ActiveRecord::Base
+ self.table_name = 'work_item_types'
+
+ enum base_type: {
+ issue: 0,
+ incident: 1,
+ test_case: 2,
+ requirement: 3
+ }
+
+ validates :name, uniqueness: { case_sensitive: false, scope: [:namespace_id] }
+ end
+ end
+
+ def up
+ # create default types
+ WorkItem::Type.create(name: 'Issue', namespace_id: nil, base_type: :issue, icon_name: 'issue-type-issue')
+ WorkItem::Type.create(name: 'Incident', namespace_id: nil, base_type: :incident, icon_name: 'issue-type-incident')
+ WorkItem::Type.create(name: 'Test Case', namespace_id: nil, base_type: :test_case, icon_name: 'issue-type-test-case')
+ WorkItem::Type.create(name: 'Requirement', namespace_id: nil, base_type: :requirement, icon_name: 'issue-type-requirements')
+ end
+
+ def down
+ # We expect this table to be empty at the point of the up migration,
+ # however there is a remote possibility that issues could already be
+ # using one of these types, with a tight foreign constraint.
+ # Therefore we will not attempt to remove any data.
+ end
+end
diff --git a/db/migrate/20210804200114_create_customer_relations_organizations.rb b/db/migrate/20210804200114_create_customer_relations_organizations.rb
new file mode 100644
index 00000000000..9936e97b9bf
--- /dev/null
+++ b/db/migrate/20210804200114_create_customer_relations_organizations.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class CreateCustomerRelationsOrganizations < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ create_table_with_constraints :customer_relations_organizations do |t|
+ t.references :group, index: false, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }
+ t.timestamps_with_timezone null: false
+ t.integer :state, limit: 1, default: 1, null: false
+ t.decimal :default_rate, precision: 18, scale: 2
+ t.text :name, null: false
+ t.text :description
+
+ t.text_limit :name, 255
+ t.text_limit :description, 1024
+
+ t.index 'group_id, LOWER(name)', unique: true, name: :index_customer_relations_organizations_on_unique_name_per_group
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :customer_relations_organizations
+ end
+ end
+end
diff --git a/db/migrate/20210804202057_add_tmp_index_approval_project_rules_scanners.rb b/db/migrate/20210804202057_add_tmp_index_approval_project_rules_scanners.rb
new file mode 100644
index 00000000000..66fcf485b2f
--- /dev/null
+++ b/db/migrate/20210804202057_add_tmp_index_approval_project_rules_scanners.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddTmpIndexApprovalProjectRulesScanners < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = 'tmp_index_approval_project_rules_scanners'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :approval_project_rules, :scanners, name: INDEX_NAME, using: :gin, where: "scanners @> '{cluster_image_scanning}'"
+ end
+
+ def down
+ remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210805085706_add_rule_index_to_security_orchestration_policy_rule_schedules.rb b/db/migrate/20210805085706_add_rule_index_to_security_orchestration_policy_rule_schedules.rb
new file mode 100644
index 00000000000..ea77e29d365
--- /dev/null
+++ b/db/migrate/20210805085706_add_rule_index_to_security_orchestration_policy_rule_schedules.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddRuleIndexToSecurityOrchestrationPolicyRuleSchedules < ActiveRecord::Migration[6.1]
+ def change
+ add_column :security_orchestration_policy_rule_schedules, :rule_index, :integer, null: false, default: 0
+ end
+end
diff --git a/db/migrate/20210806152104_add_pypi_package_requests_forwarding_to_application_settings.rb b/db/migrate/20210806152104_add_pypi_package_requests_forwarding_to_application_settings.rb
new file mode 100644
index 00000000000..34f8ec43a8f
--- /dev/null
+++ b/db/migrate/20210806152104_add_pypi_package_requests_forwarding_to_application_settings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddPypiPackageRequestsForwardingToApplicationSettings < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ with_lock_retries do
+ add_column(:application_settings, :pypi_package_requests_forwarding, :boolean, default: true, null: false)
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column(:application_settings, :pypi_package_requests_forwarding)
+ end
+ end
+end
diff --git a/db/migrate/20210809194250_rename_tables_ci_build_trace_section.rb b/db/migrate/20210809194250_rename_tables_ci_build_trace_section.rb
new file mode 100644
index 00000000000..76308e2ea8e
--- /dev/null
+++ b/db/migrate/20210809194250_rename_tables_ci_build_trace_section.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RenameTablesCiBuildTraceSection < ActiveRecord::Migration[6.1]
+ DOWNTIME = false
+
+ def change
+ # Shorten deprecated to dep to avoid 'Index name..too long'
+ rename_table(:ci_build_trace_sections, :dep_ci_build_trace_sections)
+ rename_table(:ci_build_trace_section_names, :dep_ci_build_trace_section_names)
+ end
+end
diff --git a/db/migrate/20210812171704_create_project_ci_feature_usages.rb b/db/migrate/20210812171704_create_project_ci_feature_usages.rb
new file mode 100644
index 00000000000..376512bcb44
--- /dev/null
+++ b/db/migrate/20210812171704_create_project_ci_feature_usages.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateProjectCiFeatureUsages < ActiveRecord::Migration[6.1]
+ def change
+ create_table :project_ci_feature_usages do |t|
+ t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
+ t.integer :feature, null: false, limit: 2
+ t.boolean :default_branch, default: false, null: false
+ t.index [:project_id, :feature, :default_branch], unique: true, name: 'index_project_ci_feature_usages_unique_columns'
+ end
+ end
+end
diff --git a/db/migrate/20210813101742_create_zentao_tracker_data.rb b/db/migrate/20210813101742_create_zentao_tracker_data.rb
new file mode 100644
index 00000000000..93d9cde3371
--- /dev/null
+++ b/db/migrate/20210813101742_create_zentao_tracker_data.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateZentaoTrackerData < ActiveRecord::Migration[6.1]
+ def change
+ create_table :zentao_tracker_data do |t|
+ t.references :integration, foreign_key: { on_delete: :cascade }, type: :bigint, index: true, null: false
+ t.timestamps_with_timezone
+ t.binary :encrypted_url
+ t.binary :encrypted_url_iv
+ t.binary :encrypted_api_url
+ t.binary :encrypted_api_url_iv
+ t.binary :encrypted_zentao_product_xid
+ t.binary :encrypted_zentao_product_xid_iv
+ t.binary :encrypted_api_token
+ t.binary :encrypted_api_token_iv
+ end
+ end
+end
diff --git a/db/migrate/20210813111909_create_ci_build_trace_metadata.rb b/db/migrate/20210813111909_create_ci_build_trace_metadata.rb
new file mode 100644
index 00000000000..d8b7fd656e0
--- /dev/null
+++ b/db/migrate/20210813111909_create_ci_build_trace_metadata.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class CreateCiBuildTraceMetadata < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ with_lock_retries do
+ create_table :ci_build_trace_metadata, id: false, if_not_exists: true do |t|
+ t.references :build,
+ index: false,
+ primary_key: true,
+ default: nil,
+ foreign_key: { to_table: :ci_builds, on_delete: :cascade },
+ type: :bigint,
+ null: false
+
+ t.bigint :trace_artifact_id
+ t.integer :archival_attempts, default: 0, null: false, limit: 2
+ t.binary :checksum
+ t.binary :remote_checksum
+
+ t.index :trace_artifact_id
+ end
+ end
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :ci_build_trace_metadata, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20210816161107_remove_index_containing_faulty_regex.rb b/db/migrate/20210816161107_remove_index_containing_faulty_regex.rb
new file mode 100644
index 00000000000..d625ae6d13d
--- /dev/null
+++ b/db/migrate/20210816161107_remove_index_containing_faulty_regex.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveIndexContainingFaultyRegex < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = "tmp_index_merge_requests_draft_and_status"
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :merge_requests, INDEX_NAME
+ end
+
+ def down
+ # noop
+ #
+ end
+end
diff --git a/db/migrate/20210817084338_add_foreign_key_from_ci_build_metadata_to_ci_job_artifacts.rb b/db/migrate/20210817084338_add_foreign_key_from_ci_build_metadata_to_ci_job_artifacts.rb
new file mode 100644
index 00000000000..032b15234d8
--- /dev/null
+++ b/db/migrate/20210817084338_add_foreign_key_from_ci_build_metadata_to_ci_job_artifacts.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddForeignKeyFromCiBuildMetadataToCiJobArtifacts < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ci_build_trace_metadata,
+ :ci_job_artifacts,
+ column: :trace_artifact_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :ci_build_trace_metadata, column: :trace_artifact_id
+ end
+ end
+end
diff --git a/db/migrate/20210818034001_index_historical_data_on_recorded_at.rb b/db/migrate/20210818034001_index_historical_data_on_recorded_at.rb
new file mode 100644
index 00000000000..791c5b60e54
--- /dev/null
+++ b/db/migrate/20210818034001_index_historical_data_on_recorded_at.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class IndexHistoricalDataOnRecordedAt < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = 'index_historical_data_on_recorded_at'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :historical_data, :recorded_at, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :historical_data, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20210818055357_add_unique_commit_design_user_mention_indexes.rb b/db/migrate/20210818055357_add_unique_commit_design_user_mention_indexes.rb
new file mode 100644
index 00000000000..d9d05f2b737
--- /dev/null
+++ b/db/migrate/20210818055357_add_unique_commit_design_user_mention_indexes.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddUniqueCommitDesignUserMentionIndexes < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ COMMIT_INDEX_NAME = 'commit_id_and_note_id_index'
+ DESIGN_INDEX_NAME = 'design_user_mentions_on_design_id_and_note_id_index'
+
+ COMMIT_UNIQUE_INDEX_NAME = 'commit_user_mentions_on_commit_id_and_note_id_unique_index'
+ DESIGN_UNIQUE_INDEX_NAME = 'design_user_mentions_on_design_id_and_note_id_unique_index'
+
+ def up
+ add_concurrent_index :commit_user_mentions, [:commit_id, :note_id], unique: true, name: COMMIT_UNIQUE_INDEX_NAME
+ add_concurrent_index :design_user_mentions, [:design_id, :note_id], unique: true, name: DESIGN_UNIQUE_INDEX_NAME
+
+ remove_concurrent_index_by_name :commit_user_mentions, COMMIT_INDEX_NAME
+ remove_concurrent_index_by_name :design_user_mentions, DESIGN_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :design_user_mentions, [:design_id, :note_id], name: DESIGN_INDEX_NAME
+ add_concurrent_index :commit_user_mentions, [:commit_id, :note_id], name: COMMIT_INDEX_NAME
+
+ remove_concurrent_index_by_name :design_user_mentions, DESIGN_UNIQUE_INDEX_NAME
+ remove_concurrent_index_by_name :commit_user_mentions, COMMIT_UNIQUE_INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20190517153211_migrate_k8s_service_integration.rb b/db/post_migrate/20190517153211_migrate_k8s_service_integration.rb
index 4bd04edb239..0b409cd2866 100644
--- a/db/post_migrate/20190517153211_migrate_k8s_service_integration.rb
+++ b/db/post_migrate/20190517153211_migrate_k8s_service_integration.rb
@@ -70,7 +70,7 @@ class MigrateK8sServiceIntegration < ActiveRecord::Migration[5.1]
private
def parsed_properties
- @parsed_properties ||= JSON.parse(self.properties)
+ @parsed_properties ||= JSON.parse(self.properties) # rubocop:disable Gitlab/Json
end
end
diff --git a/db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb b/db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb
index b41c55ce622..570eec53be3 100644
--- a/db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb
+++ b/db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb
@@ -20,7 +20,7 @@ class MigrateSamlIdentitiesToScimIdentities < ActiveRecord::Migration[6.0]
record.attributes.extract!("extern_uid", "user_id", "group_id", "active", "created_at", "updated_at")
end
- Gitlab::Database.bulk_insert(:scim_identities, data_to_insert, on_conflict: :do_nothing) # rubocop:disable Gitlab/BulkInsert
+ Gitlab::Database.main.bulk_insert(:scim_identities, data_to_insert, on_conflict: :do_nothing) # rubocop:disable Gitlab/BulkInsert
end
end
diff --git a/db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb b/db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb
index 72c4168af50..ed9a64c84ab 100644
--- a/db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb
+++ b/db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb
@@ -1,32 +1,13 @@
# frozen_string_literal: true
class ScheduleBackfillDraftStatusOnMergeRequests < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- INDEX_NAME = "tmp_index_merge_requests_draft_and_status"
- MIGRATION = 'BackfillDraftStatusOnMergeRequests'
- DELAY_INTERVAL = 2.minutes
- BATCH_SIZE = 100
-
- disable_ddl_transaction!
-
def up
- add_concurrent_index :merge_requests, :id,
- where: "draft = false AND state_id = 1 AND ((title)::text ~* '^\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP'::text)",
- name: INDEX_NAME
-
- eligible_mrs = Gitlab::BackgroundMigration::BackfillDraftStatusOnMergeRequests::MergeRequest.eligible
-
- queue_background_migration_jobs_by_range_at_intervals(
- eligible_mrs,
- MIGRATION,
- DELAY_INTERVAL,
- track_jobs: true,
- batch_size: BATCH_SIZE
- )
+ # noop
+ #
end
def down
- remove_concurrent_index_by_name :merge_requests, INDEX_NAME
+ # noop
+ #
end
end
diff --git a/db/post_migrate/20210622141148_schedule_delete_orphaned_deployments.rb b/db/post_migrate/20210622141148_schedule_delete_orphaned_deployments.rb
index cbd0d0ea3a2..a38cb68ff08 100644
--- a/db/post_migrate/20210622141148_schedule_delete_orphaned_deployments.rb
+++ b/db/post_migrate/20210622141148_schedule_delete_orphaned_deployments.rb
@@ -11,13 +11,12 @@ class ScheduleDeleteOrphanedDeployments < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def up
- queue_background_migration_jobs_by_range_at_intervals(
- define_batchable_model('deployments'),
- MIGRATION,
- DELAY_INTERVAL,
- batch_size: BATCH_SIZE,
- track_jobs: true
- )
+ # no-op.
+ # This background migration is rescheduled in 20210722010101_cleanup_delete_orphaned_deployments_background_migration.rb
+ # with a smaller batch size, because the initial attempt caused
+ # 80 failures out of 1639 batches (faiulre rate is 4.88%) due to statement timeouts,
+ # that takes approx. 1 hour to perform a cleanup/sync migration.
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/335071#note_618380503 for more information.
end
def down
diff --git a/db/post_migrate/20210701033622_finalize_ci_builds_needs_bigint_conversion.rb b/db/post_migrate/20210701033622_finalize_ci_builds_needs_bigint_conversion.rb
new file mode 100644
index 00000000000..baee9fb3848
--- /dev/null
+++ b/db/post_migrate/20210701033622_finalize_ci_builds_needs_bigint_conversion.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+class FinalizeCiBuildsNeedsBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_build_needs'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [['build_id'], ['build_id_convert_to_bigint']]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ private
+
+ def swap
+ # This is to replace the existing "index_ci_build_needs_on_build_id_and_name" UNIQUE, btree (build_id, name)
+ add_concurrent_index TABLE_NAME, [:build_id_convert_to_bigint, :name], unique: true, name: 'index_ci_build_needs_on_build_id_convert_to_bigint_and_name'
+
+ # Add a foreign key on `build_id_convert_to_bigint` before we swap the columns and drop the old FK (fk_rails_3cf221d4ed)
+ add_concurrent_foreign_key TABLE_NAME, :ci_builds,
+ column: :build_id_convert_to_bigint, on_delete: :cascade,
+ name: 'fk_rails_3cf221d4ed_tmp', reverse_lock_order: true
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # We'll need ACCESS EXCLUSIVE lock on the related tables,
+ # lets make sure it can be acquired from the start
+ execute "LOCK TABLE ci_builds, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
+
+ # Swap column names
+ temp_name = 'build_id_tmp'
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:build_id)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:build_id_convert_to_bigint)} TO #{quote_column_name(:build_id)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(:build_id_convert_to_bigint)}"
+
+ # We need to update the trigger function in order to make PostgreSQL to
+ # regenerate the execution plan for it. This is to avoid type mismatch errors like
+ # "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(:build_id, :build_id_convert_to_bigint)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ change_column_default TABLE_NAME, :build_id, nil
+ change_column_default TABLE_NAME, :build_id_convert_to_bigint, 0
+
+ # Rename the index on the `bigint` column to match the new column name
+ # (we already hold an exclusive lock, so no need to use DROP INDEX CONCURRENTLY here)
+ execute 'DROP INDEX index_ci_build_needs_on_build_id_and_name'
+ rename_index TABLE_NAME, 'index_ci_build_needs_on_build_id_convert_to_bigint_and_name', 'index_ci_build_needs_on_build_id_and_name'
+
+ # Drop original FK on the old int4 `build_id` (fk_rails_3cf221d4ed)
+ remove_foreign_key TABLE_NAME, name: 'fk_rails_3cf221d4ed'
+ # We swapped the columns but the FK for buil_id is still using the temporary name for the buil_id_convert_to_bigint column
+ # So we have to also swap the FK name now that we dropped the other one with the same
+ rename_constraint(TABLE_NAME, 'fk_rails_3cf221d4ed_tmp', 'fk_rails_3cf221d4ed')
+ end
+ end
+end
diff --git a/db/post_migrate/20210706142819_re_schedule_latest_pipeline_id_population.rb b/db/post_migrate/20210706142819_re_schedule_latest_pipeline_id_population.rb
index 709e0be8b79..255b64f9bc7 100644
--- a/db/post_migrate/20210706142819_re_schedule_latest_pipeline_id_population.rb
+++ b/db/post_migrate/20210706142819_re_schedule_latest_pipeline_id_population.rb
@@ -1,28 +1,9 @@
# frozen_string_literal: true
class ReScheduleLatestPipelineIdPopulation < ActiveRecord::Migration[6.1]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
- DELAY_INTERVAL = 2.minutes.to_i
- BATCH_SIZE = 100
- MIGRATION = 'PopulateLatestPipelineIds'
-
- disable_ddl_transaction!
-
- def up
- return unless Gitlab.ee?
-
- queue_background_migration_jobs_by_range_at_intervals(
- Gitlab::BackgroundMigration::PopulateLatestPipelineIds::ProjectSetting.has_vulnerabilities_without_latest_pipeline_set,
- MIGRATION,
- DELAY_INTERVAL,
- batch_size: BATCH_SIZE,
- primary_column_name: 'project_id'
- )
- end
-
- def down
- # no-op
+ def change
+ # no-op: This migration has been marked as no-op and replaced by
+ # `ReScheduleLatestPipelineIdPopulationWithLogging` as we've found some problems.
+ # For more information: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66050
end
end
diff --git a/db/post_migrate/20210706212710_finalize_ci_job_artifacts_bigint_conversion.rb b/db/post_migrate/20210706212710_finalize_ci_job_artifacts_bigint_conversion.rb
new file mode 100644
index 00000000000..40977277bd1
--- /dev/null
+++ b/db/post_migrate/20210706212710_finalize_ci_job_artifacts_bigint_conversion.rb
@@ -0,0 +1,84 @@
+# 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 FinalizeCiJobArtifactsBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_job_artifacts'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ private
+
+ def swap
+ add_concurrent_index TABLE_NAME, :id_convert_to_bigint, unique: true, name: 'index_ci_job_artifact_on_id_convert_to_bigint'
+ # This is to replace the existing "index_ci_job_artifacts_for_terraform_reports" btree (project_id, id) where (file_type = 18)
+ add_concurrent_index TABLE_NAME, [:project_id, :id_convert_to_bigint], name: 'index_ci_job_artifacts_for_terraform_reports_bigint', where: "file_type = 18"
+ # This is to replace the existing "index_ci_job_artifacts_id_for_terraform_reports" btree (id) where (file_type = 18)
+ add_concurrent_index TABLE_NAME, [:id_convert_to_bigint], name: 'index_ci_job_artifacts_id_for_terraform_reports_bigint', where: "file_type = 18"
+
+ # Add a FK on `project_pages_metadata(artifacts_archive_id)` to `id_convert_to_bigint`, the old FK (fk_69366a119e)
+ # will be removed when ci_job_artifacts_pkey constraint is droppped.
+ fk_artifacts_archive_id = concurrent_foreign_key_name(:project_pages_metadata, :artifacts_archive_id)
+ fk_artifacts_archive_id_tmp = "#{fk_artifacts_archive_id}_tmp"
+ add_concurrent_foreign_key :project_pages_metadata, TABLE_NAME,
+ column: :artifacts_archive_id, target_column: :id_convert_to_bigint,
+ name: fk_artifacts_archive_id_tmp,
+ on_delete: :nullify,
+ reverse_lock_order: true
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # We'll need ACCESS EXCLUSIVE lock on the related tables,
+ # lets make sure it can be acquired from the start
+ execute "LOCK TABLE #{TABLE_NAME}, project_pages_metadata IN ACCESS EXCLUSIVE MODE"
+
+ # Swap column names
+ temp_name = 'id_tmp'
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:id)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:id_convert_to_bigint)} TO #{quote_column_name(:id)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(:id_convert_to_bigint)}"
+
+ # We need to update the trigger function in order to make PostgreSQL to
+ # regenerate the execution plan for it. This is to avoid type mismatch errors like
+ # "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name([:id, :job_id], [:id_convert_to_bigint, :job_id_convert_to_bigint])
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ execute "ALTER SEQUENCE ci_job_artifacts_id_seq OWNED BY #{TABLE_NAME}.id"
+ change_column_default TABLE_NAME, :id, -> { "nextval('ci_job_artifacts_id_seq'::regclass)" }
+ change_column_default TABLE_NAME, :id_convert_to_bigint, 0
+
+ # Swap PK constraint
+ execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT ci_job_artifacts_pkey CASCADE" # this will drop ci_job_artifacts_pkey primary key
+ rename_index TABLE_NAME, 'index_ci_job_artifact_on_id_convert_to_bigint', 'ci_job_artifacts_pkey'
+ execute "ALTER TABLE #{TABLE_NAME} ADD CONSTRAINT ci_job_artifacts_pkey PRIMARY KEY USING INDEX ci_job_artifacts_pkey"
+
+ # Rename the rest of the indexes (we already hold an exclusive lock, so no need to use DROP INDEX CONCURRENTLY here
+ execute 'DROP INDEX index_ci_job_artifacts_for_terraform_reports'
+ rename_index TABLE_NAME, 'index_ci_job_artifacts_for_terraform_reports_bigint', 'index_ci_job_artifacts_for_terraform_reports'
+ execute 'DROP INDEX index_ci_job_artifacts_id_for_terraform_reports'
+ rename_index TABLE_NAME, 'index_ci_job_artifacts_id_for_terraform_reports_bigint', 'index_ci_job_artifacts_id_for_terraform_reports'
+
+ # Change the name of the temporary FK for project_pages_metadata(artifacts_archive_id) -> id
+ rename_constraint(:project_pages_metadata, fk_artifacts_archive_id_tmp, fk_artifacts_archive_id)
+ end
+ end
+end
diff --git a/db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb b/db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb
new file mode 100644
index 00000000000..2e294a0b2e3
--- /dev/null
+++ b/db/post_migrate/20210707210916_finalize_ci_stages_bigint_conversion.rb
@@ -0,0 +1,77 @@
+# 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 FinalizeCiStagesBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_stages'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [['id'], ['id_convert_to_bigint']]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ def swap
+ # This will replace the existing ci_stages_pkey index for the primary key
+ add_concurrent_index TABLE_NAME, :id_convert_to_bigint, unique: true, name: 'index_ci_stages_on_id_convert_to_bigint'
+
+ # This will replace the existing ci_stages_on_pipeline_id_and_id index
+ add_concurrent_index TABLE_NAME, [:pipeline_id, :id_convert_to_bigint],
+ name: 'index_ci_stages_on_pipeline_id_and_id_convert_to_bigint',
+ where: 'status in (0, 1, 2, 8, 9, 10)'
+
+ # Add a foreign key on ci_builds(stage_id_convert_to_bigint), which we'll rename later. Give it the correct final name
+ fk_stage_id = concurrent_foreign_key_name(:ci_builds, :stage_id)
+ fk_stage_id_tmp = "#{fk_stage_id}_tmp"
+ add_concurrent_foreign_key :ci_builds, :ci_stages, column: :stage_id,
+ target_column: :id_convert_to_bigint,
+ name: fk_stage_id_tmp,
+ on_delete: :cascade,
+ reverse_lock_order: true
+
+ # Now it's time to do things in a transaction
+ with_lock_retries(raise_on_exhaustion: true) do
+ execute "LOCK TABLE #{TABLE_NAME}, ci_builds IN ACCESS EXCLUSIVE MODE"
+
+ temp_name = quote_column_name('id_tmp')
+ id_name = quote_column_name(:id)
+ id_convert_to_bigint_name = quote_column_name(:id_convert_to_bigint)
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{id_name} TO #{temp_name}"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{id_convert_to_bigint_name} TO #{id_name}"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{temp_name} TO #{id_convert_to_bigint_name}"
+
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(:id, :id_convert_to_bigint)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ execute "ALTER SEQUENCE ci_stages_id_seq OWNED BY #{TABLE_NAME}.id"
+ change_column_default TABLE_NAME, :id, -> { "nextval('ci_stages_id_seq'::regclass)"}
+ change_column_default TABLE_NAME, :id_convert_to_bigint, 0
+
+ # Swap pkey constraint
+ # This will drop fk_3a9eaa254d (ci_builds(stage_id) references ci_stages(id))
+ execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT ci_stages_pkey CASCADE"
+ rename_index TABLE_NAME, 'index_ci_stages_on_id_convert_to_bigint', 'ci_stages_pkey'
+ execute "ALTER TABLE #{TABLE_NAME} ADD CONSTRAINT ci_stages_pkey PRIMARY KEY USING INDEX ci_stages_pkey"
+
+ # Rename the other indexes
+ execute "DROP INDEX index_ci_stages_on_pipeline_id_and_id"
+ rename_index TABLE_NAME, 'index_ci_stages_on_pipeline_id_and_id_convert_to_bigint', 'index_ci_stages_on_pipeline_id_and_id'
+
+ rename_constraint(:ci_builds, fk_stage_id_tmp, fk_stage_id)
+ end
+ end
+end
diff --git a/db/post_migrate/20210709024048_finalize_push_event_payloads_bigint_conversion_2.rb b/db/post_migrate/20210709024048_finalize_push_event_payloads_bigint_conversion_2.rb
new file mode 100644
index 00000000000..aa812151164
--- /dev/null
+++ b/db/post_migrate/20210709024048_finalize_push_event_payloads_bigint_conversion_2.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class FinalizePushEventPayloadsBigintConversion2 < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ # no-op due to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/5256
+ end
+
+ def down
+ # no-op due to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/5256
+ end
+end
diff --git a/db/post_migrate/20210713042153_finalize_ci_sources_pipelines_bigint_conversion.rb b/db/post_migrate/20210713042153_finalize_ci_sources_pipelines_bigint_conversion.rb
new file mode 100644
index 00000000000..938c8c172a3
--- /dev/null
+++ b/db/post_migrate/20210713042153_finalize_ci_sources_pipelines_bigint_conversion.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+class FinalizeCiSourcesPipelinesBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_sources_pipelines'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [['source_job_id'], ['source_job_id_convert_to_bigint']]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ private
+
+ def swap
+ # This is to replace the existing "index_ci_sources_pipelines_on_source_job_id" btree (source_job_id)
+ add_concurrent_index TABLE_NAME, :source_job_id_convert_to_bigint, name: 'index_ci_sources_pipelines_on_source_job_id_convert_to_bigint'
+
+ # Add a foreign key on `source_job_id_convert_to_bigint` before we swap the columns and drop the old FK (fk_be5624bf37)
+ add_concurrent_foreign_key TABLE_NAME, :ci_builds,
+ column: :source_job_id_convert_to_bigint, on_delete: :cascade,
+ name: 'fk_be5624bf37_tmp', reverse_lock_order: true
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # We'll need ACCESS EXCLUSIVE lock on the related tables,
+ # lets make sure it can be acquired from the start
+ execute "LOCK TABLE ci_builds, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
+
+ # Swap column names
+ temp_name = 'source_job_id_tmp'
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:source_job_id)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:source_job_id_convert_to_bigint)} TO #{quote_column_name(:source_job_id)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(:source_job_id_convert_to_bigint)}"
+
+ # We need to update the trigger function in order to make PostgreSQL to
+ # regenerate the execution plan for it. This is to avoid type mismatch errors like
+ # "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(:source_job_id, :source_job_id_convert_to_bigint)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # No need to swap defaults, both columns have no default value
+
+ # Rename the index on the `bigint` column to match the new column name
+ # (we already hold an exclusive lock, so no need to use DROP INDEX CONCURRENTLY here)
+ execute 'DROP INDEX index_ci_sources_pipelines_on_source_job_id'
+ rename_index TABLE_NAME, 'index_ci_sources_pipelines_on_source_job_id_convert_to_bigint', 'index_ci_sources_pipelines_on_source_job_id'
+
+ # Drop original FK on the old int4 `source_job_id` (fk_be5624bf37)
+ remove_foreign_key TABLE_NAME, name: 'fk_be5624bf37'
+ # We swapped the columns but the FK is still using the temporary name
+ # So we have to also swap the FK name now that we dropped the other one
+ rename_constraint(TABLE_NAME, 'fk_be5624bf37_tmp', 'fk_be5624bf37')
+ end
+ end
+end
diff --git a/db/post_migrate/20210713075117_re_schedule_latest_pipeline_id_population_with_logging.rb b/db/post_migrate/20210713075117_re_schedule_latest_pipeline_id_population_with_logging.rb
new file mode 100644
index 00000000000..457e7826f38
--- /dev/null
+++ b/db/post_migrate/20210713075117_re_schedule_latest_pipeline_id_population_with_logging.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class ReScheduleLatestPipelineIdPopulationWithLogging < ActiveRecord::Migration[6.1]
+ def up
+ # no-op: The content of the migration has been moved to
+ # `ReScheduleLatestPipelineIdPopulationWithAllSecurityRelatedArtifactTypes`.
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20210714015537_finalize_ci_build_trace_chunks_bigint_conversion.rb b/db/post_migrate/20210714015537_finalize_ci_build_trace_chunks_bigint_conversion.rb
new file mode 100644
index 00000000000..9195b662776
--- /dev/null
+++ b/db/post_migrate/20210714015537_finalize_ci_build_trace_chunks_bigint_conversion.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+class FinalizeCiBuildTraceChunksBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_build_trace_chunks'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [['build_id'], ['build_id_convert_to_bigint']]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ private
+
+ def swap
+ # This is to replace the existing "index_ci_build_trace_chunks_on_build_id_and_chunk_index" UNIQUE, btree (build_id, chunk_index)
+ add_concurrent_index TABLE_NAME, [:build_id_convert_to_bigint, :chunk_index], unique: true, name: 'i_ci_build_trace_chunks_build_id_convert_to_bigint_chunk_index'
+
+ # Add a foreign key on `build_id_convert_to_bigint` before we swap the columns and drop the old FK ()
+ add_concurrent_foreign_key TABLE_NAME, :ci_builds, column: :build_id_convert_to_bigint, on_delete: :cascade, name: 'fk_rails_1013b761f2_tmp'
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # We'll need ACCESS EXCLUSIVE lock on the related tables,
+ # lets make sure it can be acquired from the start
+ execute "LOCK TABLE #{TABLE_NAME}, ci_builds IN ACCESS EXCLUSIVE MODE"
+
+ # Swap column names
+ temp_name = 'build_id_tmp'
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:build_id)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:build_id_convert_to_bigint)} TO #{quote_column_name(:build_id)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(:build_id_convert_to_bigint)}"
+
+ # We need to update the trigger function in order to make PostgreSQL to
+ # regenerate the execution plan for it. This is to avoid type mismatch errors like
+ # "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(:build_id, :build_id_convert_to_bigint)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ change_column_default TABLE_NAME, :build_id, nil
+ change_column_default TABLE_NAME, :build_id_convert_to_bigint, 0
+
+ # Rename the index on the `bigint` column to match the new column name
+ # (we already hold an exclusive lock, so no need to use DROP INDEX CONCURRENTLY here)
+ execute 'DROP INDEX index_ci_build_trace_chunks_on_build_id_and_chunk_index'
+ rename_index TABLE_NAME, 'i_ci_build_trace_chunks_build_id_convert_to_bigint_chunk_index', 'index_ci_build_trace_chunks_on_build_id_and_chunk_index'
+
+ # Drop original FK on the old int4 `build_id` (fk_rails_1013b761f2)
+ remove_foreign_key TABLE_NAME, name: 'fk_rails_1013b761f2'
+ # We swapped the columns but the FK for buil_id is still using the temporary name for the build_id_convert_to_bigint column
+ # So we have to also swap the FK name now that we dropped the other one with the same
+ rename_constraint(TABLE_NAME, 'fk_rails_1013b761f2_tmp', 'fk_rails_1013b761f2')
+ end
+ end
+end
diff --git a/db/post_migrate/20210721125804_remove_signing_keys_from_packages_debian_project_distributions.rb b/db/post_migrate/20210721125804_remove_signing_keys_from_packages_debian_project_distributions.rb
new file mode 100644
index 00000000000..076a238381e
--- /dev/null
+++ b/db/post_migrate/20210721125804_remove_signing_keys_from_packages_debian_project_distributions.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class RemoveSigningKeysFromPackagesDebianProjectDistributions < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def change
+ remove_column :packages_debian_project_distributions, :encrypted_signing_keys, :text
+ remove_column :packages_debian_project_distributions, :encrypted_signing_keys_iv, :text
+ end
+end
diff --git a/db/post_migrate/20210721125820_remove_signing_keys_from_packages_debian_group_distributions.rb b/db/post_migrate/20210721125820_remove_signing_keys_from_packages_debian_group_distributions.rb
new file mode 100644
index 00000000000..4b751c06972
--- /dev/null
+++ b/db/post_migrate/20210721125820_remove_signing_keys_from_packages_debian_group_distributions.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class RemoveSigningKeysFromPackagesDebianGroupDistributions < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def change
+ remove_column :packages_debian_group_distributions, :encrypted_signing_keys, :text
+ remove_column :packages_debian_group_distributions, :encrypted_signing_keys_iv, :text
+ end
+end
diff --git a/db/post_migrate/20210721174521_add_non_null_constraint_for_escalation_rule_on_pending_alert_escalations.rb b/db/post_migrate/20210721174521_add_non_null_constraint_for_escalation_rule_on_pending_alert_escalations.rb
new file mode 100644
index 00000000000..5d42fd4896d
--- /dev/null
+++ b/db/post_migrate/20210721174521_add_non_null_constraint_for_escalation_rule_on_pending_alert_escalations.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+class AddNonNullConstraintForEscalationRuleOnPendingAlertEscalations < ActiveRecord::Migration[6.1]
+ ELAPSED_WHOLE_MINUTES_IN_SECONDS = <<~SQL
+ ABS(ROUND(
+ EXTRACT(EPOCH FROM (escalations.process_at - escalations.created_at))/60*60
+ ))
+ SQL
+
+ INSERT_RULES_FOR_ESCALATIONS_WITHOUT_RULES = <<~SQL
+ INSERT INTO incident_management_escalation_rules (policy_id, oncall_schedule_id, status, elapsed_time_seconds, is_removed)
+ SELECT
+ policies.id,
+ schedule_id,
+ status,
+ #{ELAPSED_WHOLE_MINUTES_IN_SECONDS} AS elapsed_time_seconds,
+ TRUE
+ FROM incident_management_pending_alert_escalations AS escalations
+ INNER JOIN incident_management_oncall_schedules AS schedules ON schedules.id = schedule_id
+ INNER JOIN incident_management_escalation_policies AS policies ON policies.project_id = schedules.project_id
+ WHERE rule_id IS NULL
+ GROUP BY policies.id, schedule_id, status, elapsed_time_seconds
+ ON CONFLICT DO NOTHING;
+ SQL
+
+ UPDATE_EMPTY_RULE_IDS = <<~SQL
+ UPDATE incident_management_pending_alert_escalations AS escalations
+ SET rule_id = rules.id
+ FROM incident_management_pending_alert_escalations AS through_escalations
+ INNER JOIN incident_management_oncall_schedules AS schedules ON schedules.id = through_escalations.schedule_id
+ INNER JOIN incident_management_escalation_policies AS policies ON policies.project_id = schedules.project_id
+ INNER JOIN incident_management_escalation_rules AS rules ON rules.policy_id = policies.id
+ WHERE escalations.rule_id IS NULL
+ AND rules.status = escalations.status
+ AND rules.oncall_schedule_id = escalations.schedule_id
+ AND rules.elapsed_time_seconds = #{ELAPSED_WHOLE_MINUTES_IN_SECONDS};
+ SQL
+
+ DELETE_LEFTOVER_ESCALATIONS_WITHOUT_RULES = 'DELETE FROM incident_management_pending_alert_escalations WHERE rule_id IS NULL;'
+
+ # For each alert which has a pending escalation without a corresponding rule,
+ # create a rule with the expected attributes for the project's policy.
+ #
+ # Deletes all escalations without rules/policy & adds non-null constraint for rule_id.
+ def up
+ exec_query INSERT_RULES_FOR_ESCALATIONS_WITHOUT_RULES
+ exec_query UPDATE_EMPTY_RULE_IDS
+ exec_query DELETE_LEFTOVER_ESCALATIONS_WITHOUT_RULES
+
+ change_column_null :incident_management_pending_alert_escalations, :rule_id, false
+ end
+
+ def down
+ change_column_null :incident_management_pending_alert_escalations, :rule_id, true
+ end
+end
diff --git a/db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb b/db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb
new file mode 100644
index 00000000000..b0608f15ce1
--- /dev/null
+++ b/db/post_migrate/20210722010101_reschedule_delete_orphaned_deployments.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class RescheduleDeleteOrphanedDeployments < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ MIGRATION = 'DeleteOrphanedDeployments'
+ BATCH_SIZE = 10_000
+ DELAY_INTERVAL = 2.minutes
+
+ disable_ddl_transaction!
+
+ def up
+ Gitlab::BackgroundMigration.steal(MIGRATION)
+ Gitlab::Database::BackgroundMigrationJob.for_migration_class(MIGRATION).delete_all
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('deployments'),
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ track_jobs: true
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20210722042939_update_issuable_slas_where_issue_closed.rb b/db/post_migrate/20210722042939_update_issuable_slas_where_issue_closed.rb
new file mode 100644
index 00000000000..b611b51e3ff
--- /dev/null
+++ b/db/post_migrate/20210722042939_update_issuable_slas_where_issue_closed.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class UpdateIssuableSlasWhereIssueClosed < ActiveRecord::Migration[6.1]
+ ISSUE_CLOSED_STATUS = 2
+
+ class IssuableSla < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'issuable_slas'
+
+ belongs_to :issue, class_name: 'Issue'
+ end
+
+ class Issue < ActiveRecord::Base
+ self.table_name = 'issues'
+
+ has_one :issuable_sla, class_name: 'IssuableSla'
+ end
+
+ def up
+ IssuableSla.each_batch(of: 50) do |relation|
+ relation.joins(:issue)
+ .where(issues: { state_id: ISSUE_CLOSED_STATUS } )
+ .update_all(issuable_closed: true)
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20210722055217_add_updated_at_index_on_merge_requests.rb b/db/post_migrate/20210722055217_add_updated_at_index_on_merge_requests.rb
new file mode 100644
index 00000000000..c66c14d1900
--- /dev/null
+++ b/db/post_migrate/20210722055217_add_updated_at_index_on_merge_requests.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddUpdatedAtIndexOnMergeRequests < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ INDEX_NAME = 'index_merge_requests_on_target_project_id_and_updated_at_and_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_requests, [:target_project_id, :updated_at, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :merge_requests, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20210722155635_finalize_convert_geo_job_artifact_deleted_events_bigint.rb b/db/post_migrate/20210722155635_finalize_convert_geo_job_artifact_deleted_events_bigint.rb
new file mode 100644
index 00000000000..7d3809a9dbe
--- /dev/null
+++ b/db/post_migrate/20210722155635_finalize_convert_geo_job_artifact_deleted_events_bigint.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+class FinalizeConvertGeoJobArtifactDeletedEventsBigint < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'geo_job_artifact_deleted_events'
+ COLUMN_NAME = 'job_artifact_id'
+ COLUMN_NAME_CONVERTED = "#{COLUMN_NAME}_convert_to_bigint"
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [[COLUMN_NAME], [COLUMN_NAME_CONVERTED]]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ def swap
+ old_index_name = 'index_geo_job_artifact_deleted_events_on_job_artifact_id'
+
+ bigint_index_name = 'index_geo_job_artifact_deleted_events_on_job_artifact_id_bigint'
+ add_concurrent_index TABLE_NAME, COLUMN_NAME_CONVERTED, name: bigint_index_name
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ execute("LOCK TABLE #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE")
+
+ temp_name = quote_column_name("#{COLUMN_NAME}_tmp")
+ old_column_name = quote_column_name(COLUMN_NAME)
+ new_column_name = quote_column_name(COLUMN_NAME_CONVERTED)
+
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{old_column_name} TO #{temp_name}"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{new_column_name} TO #{old_column_name}"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{temp_name} TO #{new_column_name}"
+
+ change_column_default TABLE_NAME, COLUMN_NAME, nil
+ change_column_default TABLE_NAME, COLUMN_NAME_CONVERTED, 0
+
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(COLUMN_NAME, COLUMN_NAME_CONVERTED)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ execute "DROP INDEX #{old_index_name}"
+
+ rename_index TABLE_NAME, bigint_index_name, old_index_name
+ end
+ end
+end
diff --git a/db/post_migrate/20210727113447_backfill_integrations_type_new.rb b/db/post_migrate/20210727113447_backfill_integrations_type_new.rb
new file mode 100644
index 00000000000..8544c236fd7
--- /dev/null
+++ b/db/post_migrate/20210727113447_backfill_integrations_type_new.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class BackfillIntegrationsTypeNew < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ MIGRATION = 'BackfillIntegrationsTypeNew'
+ INTERVAL = 2.minutes
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :integrations,
+ :id,
+ job_interval: INTERVAL
+ )
+ end
+
+ def down
+ Gitlab::Database::BackgroundMigration::BatchedMigration
+ .for_configuration(MIGRATION, :integrations, :id, [])
+ .delete_all
+ end
+end
diff --git a/db/post_migrate/20210727175201_remove_unused_columns_from_elastic_reindexing_tasks.rb b/db/post_migrate/20210727175201_remove_unused_columns_from_elastic_reindexing_tasks.rb
new file mode 100644
index 00000000000..d4ce1e7024f
--- /dev/null
+++ b/db/post_migrate/20210727175201_remove_unused_columns_from_elastic_reindexing_tasks.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class RemoveUnusedColumnsFromElasticReindexingTasks < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ remove_column :elastic_reindexing_tasks, :documents_count, :integer
+ remove_column :elastic_reindexing_tasks, :index_name_from, :text
+ remove_column :elastic_reindexing_tasks, :index_name_to, :text
+ remove_column :elastic_reindexing_tasks, :elastic_task, :text
+ remove_column :elastic_reindexing_tasks, :documents_count_target, :integer
+ end
+
+ def down
+ add_column :elastic_reindexing_tasks, :documents_count, :integer
+ add_column :elastic_reindexing_tasks, :index_name_from, :text
+ add_column :elastic_reindexing_tasks, :index_name_to, :text
+ add_column :elastic_reindexing_tasks, :elastic_task, :text
+ add_column :elastic_reindexing_tasks, :documents_count_target, :integer
+
+ add_text_limit :elastic_reindexing_tasks, :index_name_from, 255
+ add_text_limit :elastic_reindexing_tasks, :index_name_to, 255
+ add_text_limit :elastic_reindexing_tasks, :elastic_task, 255
+ end
+end
diff --git a/db/post_migrate/20210729163312_re_schedule_latest_pipeline_id_population_with_all_security_related_artifact_types.rb b/db/post_migrate/20210729163312_re_schedule_latest_pipeline_id_population_with_all_security_related_artifact_types.rb
new file mode 100644
index 00000000000..8ec608453a0
--- /dev/null
+++ b/db/post_migrate/20210729163312_re_schedule_latest_pipeline_id_population_with_all_security_related_artifact_types.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class ReScheduleLatestPipelineIdPopulationWithAllSecurityRelatedArtifactTypes < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ DELAY_INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 100
+ MIGRATION = 'PopulateLatestPipelineIds'
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.ee?
+
+ Gitlab::BackgroundMigration.steal(MIGRATION)
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ Gitlab::BackgroundMigration::PopulateLatestPipelineIds::ProjectSetting.has_vulnerabilities_without_latest_pipeline_set,
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE,
+ primary_column_name: 'project_id'
+ )
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20210729192959_drop_ci_test_case_failures_table.rb b/db/post_migrate/20210729192959_drop_ci_test_case_failures_table.rb
new file mode 100644
index 00000000000..ad6676a1704
--- /dev/null
+++ b/db/post_migrate/20210729192959_drop_ci_test_case_failures_table.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class DropCiTestCaseFailuresTable < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ drop_table :ci_test_case_failures
+ end
+
+ def down
+ create_table :ci_test_case_failures do |t|
+ t.datetime_with_timezone :failed_at
+ t.bigint :test_case_id, null: false
+ t.bigint :build_id, null: false
+
+ t.index [:test_case_id, :failed_at, :build_id], name: 'index_test_case_failures_unique_columns', unique: true, order: { failed_at: :desc }
+ t.index :build_id
+ end
+ end
+end
diff --git a/db/post_migrate/20210729193056_drop_ci_test_cases_table.rb b/db/post_migrate/20210729193056_drop_ci_test_cases_table.rb
new file mode 100644
index 00000000000..2de1749721d
--- /dev/null
+++ b/db/post_migrate/20210729193056_drop_ci_test_cases_table.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class DropCiTestCasesTable < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ drop_table :ci_test_cases
+ end
+
+ def down
+ create_table_with_constraints :ci_test_cases do |t|
+ t.bigint :project_id, null: false
+ t.text :key_hash, null: false
+ t.text_limit :key_hash, 64
+
+ t.index [:project_id, :key_hash], unique: true
+ end
+ end
+end
diff --git a/db/post_migrate/20210730170823_schedule_security_setting_creation.rb b/db/post_migrate/20210730170823_schedule_security_setting_creation.rb
new file mode 100644
index 00000000000..cea7b976bf9
--- /dev/null
+++ b/db/post_migrate/20210730170823_schedule_security_setting_creation.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class ScheduleSecuritySettingCreation < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ MIGRATION = 'CreateSecuritySetting'
+ BATCH_SIZE = 1000
+ INTERVAL = 5.minutes.to_i
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.ee? # Security Settings available only in EE version
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ define_batchable_model('projects'),
+ MIGRATION,
+ INTERVAL,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ # We're adding data so no need for rollback
+ def down
+ end
+end
diff --git a/db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb b/db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb
new file mode 100644
index 00000000000..4b825ae72ba
--- /dev/null
+++ b/db/post_migrate/20210802043253_finalize_push_event_payloads_bigint_conversion_3.rb
@@ -0,0 +1,87 @@
+# frozen_string_literal: true
+
+class FinalizePushEventPayloadsBigintConversion3 < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'push_event_payloads'
+ INDEX_NAME = 'index_push_event_payloads_on_event_id_convert_to_bigint'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'event_id',
+ job_arguments: [["event_id"], ["event_id_convert_to_bigint"]]
+ )
+
+ return if already_swapped?
+
+ swap_columns
+ end
+
+ def down
+ swap_columns
+ end
+
+ private
+
+ def already_swapped?
+ push_event_payloads_columns = columns(TABLE_NAME)
+ event_id = push_event_payloads_columns.find {|c| c.name == 'event_id'}
+ event_id_convert_to_bigint = push_event_payloads_columns.find {|c| c.name == 'event_id_convert_to_bigint'}
+
+ event_id.sql_type == 'bigint' && event_id_convert_to_bigint.sql_type == 'integer'
+ end
+
+ def swap_columns
+ add_concurrent_index TABLE_NAME, :event_id_convert_to_bigint, unique: true, name: INDEX_NAME
+
+ # Add a foreign key on `event_id_convert_to_bigint` before we swap the columns and drop the old FK (fk_36c74129da)
+ add_concurrent_foreign_key TABLE_NAME, :events, column: :event_id_convert_to_bigint,
+ on_delete: :cascade, reverse_lock_order: true
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # We'll need ACCESS EXCLUSIVE lock on the related tables,
+ # lets make sure it can be acquired from the start.
+ # Lock order should be
+ # 1. events
+ # 2. push_event_payloads
+ # in order to match the order in EventCreateService#create_push_event,
+ # and avoid deadlocks.
+ execute "LOCK TABLE events, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
+
+ # Swap column names
+ temp_name = 'event_id_tmp'
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:event_id)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:event_id_convert_to_bigint)} TO #{quote_column_name(:event_id)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(:event_id_convert_to_bigint)}"
+
+ # We need to update the trigger function in order to make PostgreSQL to
+ # regenerate the execution plan for it. This is to avoid type mismatch errors like
+ # "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(:event_id, :event_id_convert_to_bigint)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ change_column_default TABLE_NAME, :event_id, nil
+ change_column_default TABLE_NAME, :event_id_convert_to_bigint, 0
+
+ # Swap PK constraint
+ execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT push_event_payloads_pkey"
+ rename_index TABLE_NAME, INDEX_NAME, 'push_event_payloads_pkey'
+ execute "ALTER TABLE #{TABLE_NAME} ADD CONSTRAINT push_event_payloads_pkey PRIMARY KEY USING INDEX push_event_payloads_pkey"
+
+ # Drop original FK on the old int4 `event_id` (fk_36c74129da)
+ remove_foreign_key TABLE_NAME, name: concurrent_foreign_key_name(TABLE_NAME, :event_id)
+ # We swapped the columns but the FK for event_id is still using the old name for the event_id_convert_to_bigint column
+ # So we have to also swap the FK name now that we dropped the other one with the same
+ rename_constraint(
+ TABLE_NAME,
+ concurrent_foreign_key_name(TABLE_NAME, :event_id_convert_to_bigint),
+ concurrent_foreign_key_name(TABLE_NAME, :event_id)
+ )
+ end
+ end
+end
diff --git a/db/post_migrate/20210802112233_add_index_issues_on_project_id_and_state_id_and_created_at_and_id.rb b/db/post_migrate/20210802112233_add_index_issues_on_project_id_and_state_id_and_created_at_and_id.rb
new file mode 100644
index 00000000000..318d9e8a218
--- /dev/null
+++ b/db/post_migrate/20210802112233_add_index_issues_on_project_id_and_state_id_and_created_at_and_id.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexIssuesOnProjectIdAndStateIdAndCreatedAtAndId < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_issues_on_project_id_and_state_id_and_created_at_and_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :issues, [:project_id, :state_id, :created_at, :id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20210802131812_finalize_convert_deployments_bigint.rb b/db/post_migrate/20210802131812_finalize_convert_deployments_bigint.rb
new file mode 100644
index 00000000000..31afb7e0a29
--- /dev/null
+++ b/db/post_migrate/20210802131812_finalize_convert_deployments_bigint.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+class FinalizeConvertDeploymentsBigint < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'deployments'
+ COLUMN_NAME = 'deployable_id'
+ COLUMN_NAME_BIGINT = "#{COLUMN_NAME}_convert_to_bigint"
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [[COLUMN_NAME], [COLUMN_NAME_BIGINT]]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ def swap
+ old_index_name = 'index_deployments_on_deployable_type_and_deployable_id'
+ bigint_index_name = 'index_deployments_on_deployable_type_and_deployable_id_bigint'
+ add_concurrent_index TABLE_NAME, ['deployable_type', COLUMN_NAME_BIGINT], name: bigint_index_name
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # Swap columns
+ temp_name = "#{COLUMN_NAME}_tmp"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{quote_column_name(COLUMN_NAME)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{quote_column_name(COLUMN_NAME_BIGINT)} TO #{quote_column_name(COLUMN_NAME)}"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(COLUMN_NAME_BIGINT)}"
+
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(COLUMN_NAME, COLUMN_NAME_BIGINT)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ execute "DROP INDEX #{old_index_name}"
+ rename_index TABLE_NAME, bigint_index_name, old_index_name
+ end
+ end
+end
diff --git a/db/post_migrate/20210804150624_remove_cluster_image_scanning_from_approval_project_rules.rb b/db/post_migrate/20210804150624_remove_cluster_image_scanning_from_approval_project_rules.rb
new file mode 100644
index 00000000000..a2736a563c7
--- /dev/null
+++ b/db/post_migrate/20210804150624_remove_cluster_image_scanning_from_approval_project_rules.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveClusterImageScanningFromApprovalProjectRules < ActiveRecord::Migration[6.1]
+ def up
+ execute("update approval_project_rules set scanners = array_remove(scanners, 'cluster_image_scanning') where scanners @> '{cluster_image_scanning}'")
+ end
+
+ def down
+ # nothing to do here
+ end
+end
diff --git a/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb b/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb
new file mode 100644
index 00000000000..8115465e311
--- /dev/null
+++ b/db/post_migrate/20210804151444_prepare_indexes_for_ci_job_artifact_bigint_conversion.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class PrepareIndexesForCiJobArtifactBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ prepare_async_index :ci_job_artifacts, :id_convert_to_bigint, unique: true,
+ name: :index_ci_job_artifact_on_id_convert_to_bigint
+
+ prepare_async_index :ci_job_artifacts, [:project_id, :id_convert_to_bigint], where: 'file_type = 18',
+ name: :index_ci_job_artifacts_for_terraform_reports_bigint
+
+ prepare_async_index :ci_job_artifacts, :id_convert_to_bigint, where: 'file_type = 18',
+ name: :index_ci_job_artifacts_id_for_terraform_reports_bigint
+
+ prepare_async_index :ci_job_artifacts, [:expire_at, :job_id_convert_to_bigint],
+ name: :index_ci_job_artifacts_on_expire_at_and_job_id_bigint
+
+ prepare_async_index :ci_job_artifacts, [:job_id_convert_to_bigint, :file_type], unique: true,
+ name: :index_ci_job_artifacts_on_job_id_and_file_type_bigint
+ end
+
+ def down
+ unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_on_job_id_and_file_type_bigint
+
+ unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_on_expire_at_and_job_id_bigint
+
+ unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_id_for_terraform_reports_bigint
+
+ unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_for_terraform_reports_bigint
+
+ unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifact_on_id_convert_to_bigint
+ end
+end
diff --git a/db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb b/db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb
new file mode 100644
index 00000000000..98f90bafce3
--- /dev/null
+++ b/db/post_migrate/20210804153307_prepare_indexes_for_tagging_bigint_conversion.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class PrepareIndexesForTaggingBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ prepare_async_index :taggings, :id_convert_to_bigint, unique: true,
+ name: :index_taggings_on_id_convert_to_bigint
+
+ prepare_async_index :taggings, [:taggable_id_convert_to_bigint, :taggable_type],
+ name: :i_taggings_on_taggable_id_convert_to_bigint_and_taggable_type
+
+ prepare_async_index :taggings, [:taggable_id_convert_to_bigint, :taggable_type, :context],
+ name: :i_taggings_on_taggable_bigint_and_taggable_type_and_context
+
+ prepare_async_index :taggings, [:tag_id, :taggable_id_convert_to_bigint, :taggable_type, :context, :tagger_id, :tagger_type],
+ unique: true, name: :taggings_idx_tmp
+ end
+
+ def down
+ unprepare_async_index_by_name :taggings, :taggings_idx_tmp
+
+ unprepare_async_index_by_name :taggings, :i_taggings_on_taggable_bigint_and_taggable_type_and_context
+
+ unprepare_async_index_by_name :taggings, :i_taggings_on_taggable_id_convert_to_bigint_and_taggable_type
+
+ unprepare_async_index_by_name :taggings, :index_taggings_on_id_convert_to_bigint
+ end
+end
diff --git a/db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb b/db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb
new file mode 100644
index 00000000000..82af595b2d3
--- /dev/null
+++ b/db/post_migrate/20210804154407_prepare_indexes_for_ci_stage_bigint_conversion.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class PrepareIndexesForCiStageBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ prepare_async_index :ci_stages, :id_convert_to_bigint, unique: true,
+ name: :index_ci_stages_on_id_convert_to_bigint
+
+ prepare_async_index :ci_stages, [:pipeline_id, :id_convert_to_bigint], where: 'status in (0, 1, 2, 8, 9, 10)',
+ name: :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
+ end
+
+ def down
+ unprepare_async_index_by_name :ci_stages, :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
+
+ unprepare_async_index_by_name :ci_stages, :index_ci_stages_on_id_convert_to_bigint
+ end
+end
diff --git a/db/post_migrate/20210805131510_finalize_ci_builds_runner_session_bigint_conversion.rb b/db/post_migrate/20210805131510_finalize_ci_builds_runner_session_bigint_conversion.rb
new file mode 100644
index 00000000000..9706f0036f3
--- /dev/null
+++ b/db/post_migrate/20210805131510_finalize_ci_builds_runner_session_bigint_conversion.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+class FinalizeCiBuildsRunnerSessionBigintConversion < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_builds_runner_session'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [['build_id'], ['build_id_convert_to_bigint']]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ private
+
+ def swap
+ add_concurrent_index TABLE_NAME, :build_id_convert_to_bigint, unique: true, name: 'index_ci_builds_runner_session_on_build_id_convert_to_bigint'
+
+ # Add a foreign key on `build_id_convert_to_bigint` before we swap the columns and drop the old FK ()
+ add_concurrent_foreign_key TABLE_NAME, :ci_builds, column: :build_id_convert_to_bigint, on_delete: :cascade, name: 'fk_rails_70707857d3_tmp', reverse_lock_order: true
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # We'll need ACCESS EXCLUSIVE lock on the related tables,
+ # lets make sure it can be acquired from the start
+ execute "LOCK TABLE ci_builds, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
+
+ # Swap column names
+ temp_name = 'build_id_tmp'
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:build_id)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:build_id_convert_to_bigint)} TO #{quote_column_name(:build_id)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(:build_id_convert_to_bigint)}"
+
+ # We need to update the trigger function in order to make PostgreSQL to
+ # regenerate the execution plan for it. This is to avoid type mismatch errors like
+ # "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name(:build_id, :build_id_convert_to_bigint)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ change_column_default TABLE_NAME, :build_id, nil
+ change_column_default TABLE_NAME, :build_id_convert_to_bigint, 0
+
+ # Rename the index on the `bigint` column to match the new column name
+ # (we already hold an exclusive lock, so no need to use DROP INDEX CONCURRENTLY here)
+ execute 'DROP INDEX index_ci_builds_runner_session_on_build_id'
+ rename_index TABLE_NAME, 'index_ci_builds_runner_session_on_build_id_convert_to_bigint', 'index_ci_builds_runner_session_on_build_id'
+
+ # Drop original FK on the old int4 `build_id` (fk_rails_70707857d3)
+ remove_foreign_key TABLE_NAME, name: 'fk_rails_70707857d3'
+
+ # We swapped the columns but the FK for buil_id is still using the temporary name for the build_id_convert_to_bigint column
+ # So we have to also swap the FK name now that we dropped the other one with the same
+ rename_constraint(TABLE_NAME, 'fk_rails_70707857d3_tmp', 'fk_rails_70707857d3')
+ end
+ end
+end
diff --git a/db/post_migrate/20210805192450_update_trial_plans_ci_daily_pipeline_schedule_triggers.rb b/db/post_migrate/20210805192450_update_trial_plans_ci_daily_pipeline_schedule_triggers.rb
new file mode 100644
index 00000000000..9552058dd73
--- /dev/null
+++ b/db/post_migrate/20210805192450_update_trial_plans_ci_daily_pipeline_schedule_triggers.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+class UpdateTrialPlansCiDailyPipelineScheduleTriggers < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ PREMIUM_TRIAL = 'premium_trial'
+ ULTIMATE_TRIAL = 'ultimate_trial'
+ EVERY_5_MINUTES = (1.day.in_minutes / 5).to_i
+
+ class Plan < ActiveRecord::Base
+ self.table_name = 'plans'
+ self.inheritance_column = :_type_disabled
+
+ has_one :limits, class_name: 'PlanLimits'
+ end
+
+ class PlanLimits < ActiveRecord::Base
+ self.table_name = 'plan_limits'
+ self.inheritance_column = :_type_disabled
+
+ belongs_to :plan
+ end
+
+ def plan_limits_present?
+ premium_trial_plan = Plan.find_by(name: PREMIUM_TRIAL)
+ ultimate_trial_plan = Plan.find_by(name: ULTIMATE_TRIAL)
+
+ premium_trial_plan && premium_trial_plan.limits && ultimate_trial_plan && ultimate_trial_plan.limits
+ end
+
+ def up
+ return unless Gitlab.dev_env_or_com?
+
+ if plan_limits_present?
+ create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', PREMIUM_TRIAL, EVERY_5_MINUTES)
+ create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', ULTIMATE_TRIAL, EVERY_5_MINUTES)
+ end
+ end
+
+ def down
+ return unless Gitlab.dev_env_or_com?
+
+ if plan_limits_present?
+ create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', PREMIUM_TRIAL, 0)
+ create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', ULTIMATE_TRIAL, 0)
+ end
+ end
+end
diff --git a/db/post_migrate/20210806011811_schedule_backfill_draft_column_on_merge_requests_rerun.rb b/db/post_migrate/20210806011811_schedule_backfill_draft_column_on_merge_requests_rerun.rb
new file mode 100644
index 00000000000..90bca79624d
--- /dev/null
+++ b/db/post_migrate/20210806011811_schedule_backfill_draft_column_on_merge_requests_rerun.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ScheduleBackfillDraftColumnOnMergeRequestsRerun < ActiveRecord::Migration[6.1]
+ def up
+ # noop
+ #
+ end
+
+ def down
+ # noop
+ #
+ end
+end
diff --git a/db/post_migrate/20210809123658_orphaned_invite_tokens_cleanup.rb b/db/post_migrate/20210809123658_orphaned_invite_tokens_cleanup.rb
new file mode 100644
index 00000000000..f774db73eaa
--- /dev/null
+++ b/db/post_migrate/20210809123658_orphaned_invite_tokens_cleanup.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class OrphanedInviteTokensCleanup < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TMP_INDEX_NAME = 'tmp_idx_orphaned_invite_tokens'
+ QUERY_CONDITION = "invite_token IS NOT NULL and invite_accepted_at IS NOT NULL and invite_accepted_at < created_at"
+
+ def up
+ membership = define_batchable_model('members')
+
+ add_concurrent_index('members', :id, where: QUERY_CONDITION, name: TMP_INDEX_NAME)
+
+ membership.where(QUERY_CONDITION).pluck(:id).each_slice(10) do |group|
+ membership.where(id: group).where(QUERY_CONDITION).update_all(invite_token: nil)
+ end
+
+ remove_concurrent_index_by_name('members', TMP_INDEX_NAME)
+ end
+
+ def down
+ remove_concurrent_index_by_name('members', TMP_INDEX_NAME) if index_exists_by_name?('members', TMP_INDEX_NAME)
+
+ # This migration is irreversible
+ end
+end
diff --git a/db/post_migrate/20210809143931_finalize_job_id_conversion_to_bigint_for_ci_job_artifacts.rb b/db/post_migrate/20210809143931_finalize_job_id_conversion_to_bigint_for_ci_job_artifacts.rb
new file mode 100644
index 00000000000..bb12045b1de
--- /dev/null
+++ b/db/post_migrate/20210809143931_finalize_job_id_conversion_to_bigint_for_ci_job_artifacts.rb
@@ -0,0 +1,79 @@
+# frozen_string_literal: true
+
+class FinalizeJobIdConversionToBigintForCiJobArtifacts < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_job_artifacts'
+
+ def up
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: TABLE_NAME,
+ column_name: 'id',
+ job_arguments: [%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]]
+ )
+
+ swap
+ end
+
+ def down
+ swap
+ end
+
+ private
+
+ def swap
+ # This is to replace the existing "index_ci_job_artifacts_on_expire_at_and_job_id" btree (expire_at, job_id)
+ add_concurrent_index TABLE_NAME, [:expire_at, :job_id_convert_to_bigint], name: 'index_ci_job_artifacts_on_expire_at_and_job_id_bigint'
+ # This is to replace the existing "index_ci_job_artifacts_on_job_id_and_file_type" btree (job_id, file_type)
+ add_concurrent_index TABLE_NAME, [:job_id_convert_to_bigint, :file_type], name: 'index_ci_job_artifacts_on_job_id_and_file_type_bigint', unique: true
+
+ # # Add a FK on `job_id_convert_to_bigint` to `ci_builds(id)`, the old FK (fk_rails_c5137cb2c1)
+ # # is removed below since it won't be dropped automatically.
+ fk_ci_builds_job_id = concurrent_foreign_key_name(TABLE_NAME, :job_id, prefix: 'fk_rails_')
+ fk_ci_builds_job_id_tmp = "#{fk_ci_builds_job_id}_tmp"
+
+ add_concurrent_foreign_key TABLE_NAME, :ci_builds,
+ column: :job_id_convert_to_bigint,
+ name: fk_ci_builds_job_id_tmp,
+ on_delete: :cascade,
+ reverse_lock_order: true
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ # We'll need ACCESS EXCLUSIVE lock on the related tables,
+ # lets make sure it can be acquired from the start
+
+ execute "LOCK TABLE ci_builds, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
+
+ temp_name = 'job_id_tmp'
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:job_id)} TO #{quote_column_name(temp_name)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(:job_id_convert_to_bigint)} TO #{quote_column_name(:job_id)}"
+ execute "ALTER TABLE #{quote_table_name(TABLE_NAME)} RENAME COLUMN #{quote_column_name(temp_name)} TO #{quote_column_name(:job_id_convert_to_bigint)}"
+
+ # We need to update the trigger function in order to make PostgreSQL to
+ # regenerate the execution plan for it. This is to avoid type mismatch errors like
+ # "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger.on_table(TABLE_NAME).name([:id, :job_id], [:id_convert_to_bigint, :job_id_convert_to_bigint])
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ change_column_default TABLE_NAME, :job_id, nil
+ change_column_default TABLE_NAME, :job_id_convert_to_bigint, 0
+
+ # Rename the rest of the indexes (we already hold an exclusive lock, so no need to use DROP INDEX CONCURRENTLY here
+ execute 'DROP INDEX index_ci_job_artifacts_on_expire_at_and_job_id'
+ rename_index TABLE_NAME, 'index_ci_job_artifacts_on_expire_at_and_job_id_bigint', 'index_ci_job_artifacts_on_expire_at_and_job_id'
+ execute 'DROP INDEX index_ci_job_artifacts_on_job_id_and_file_type'
+ rename_index TABLE_NAME, 'index_ci_job_artifacts_on_job_id_and_file_type_bigint', 'index_ci_job_artifacts_on_job_id_and_file_type'
+
+ # Drop original FK on the old int4 `job_id` (fk_rails_c5137cb2c1)
+ remove_foreign_key TABLE_NAME, name: fk_ci_builds_job_id
+
+ # We swapped the columns but the FK for job_id is still using the temporary name for the job_id_convert_to_bigint column
+ # So we have to also swap the FK name now that we dropped the other one with the same
+ rename_constraint(TABLE_NAME, fk_ci_builds_job_id_tmp, fk_ci_builds_job_id)
+ end
+ end
+end
diff --git a/db/post_migrate/20210811214811_schedule_copy_ci_builds_columns_to_security_scans.rb b/db/post_migrate/20210811214811_schedule_copy_ci_builds_columns_to_security_scans.rb
new file mode 100644
index 00000000000..106d1430dca
--- /dev/null
+++ b/db/post_migrate/20210811214811_schedule_copy_ci_builds_columns_to_security_scans.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ScheduleCopyCiBuildsColumnsToSecurityScans < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ # no-op as we found an issue with bg migration, we fixed it and rescheduling it again.
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20210812145010_reset_job_token_scope_enabled_again.rb b/db/post_migrate/20210812145010_reset_job_token_scope_enabled_again.rb
new file mode 100644
index 00000000000..6b4c69efa2b
--- /dev/null
+++ b/db/post_migrate/20210812145010_reset_job_token_scope_enabled_again.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ResetJobTokenScopeEnabledAgain < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ def up
+ with_lock_retries do
+ remove_column :project_ci_cd_settings, :job_token_scope_enabled
+ add_column :project_ci_cd_settings, :job_token_scope_enabled, :boolean, default: false, null: false
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20210813195518_schedule_recalculate_uuid_on_vulnerabilities_occurrences3.rb b/db/post_migrate/20210813195518_schedule_recalculate_uuid_on_vulnerabilities_occurrences3.rb
new file mode 100644
index 00000000000..c59c71708ca
--- /dev/null
+++ b/db/post_migrate/20210813195518_schedule_recalculate_uuid_on_vulnerabilities_occurrences3.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class ScheduleRecalculateUuidOnVulnerabilitiesOccurrences3 < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ MIGRATION = 'RecalculateVulnerabilitiesOccurrencesUuid'
+ DELAY_INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 2_500
+
+ disable_ddl_transaction!
+
+ def up
+ # Make sure that RemoveDuplicateVulnerabilitiesFindings has finished running
+ # so that we don't run into duplicate UUID issues
+ Gitlab::BackgroundMigration.steal('RemoveDuplicateVulnerabilitiesFindings')
+
+ say "Scheduling #{MIGRATION} jobs"
+ 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/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb b/db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb
new file mode 100644
index 00000000000..b8f843fdd50
--- /dev/null
+++ b/db/post_migrate/20210816183304_schedule_copy_ci_builds_columns_to_security_scans2.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class ScheduleCopyCiBuildsColumnsToSecurityScans2 < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ INTERVAL = 2.minutes.to_i
+ BATCH_SIZE = 5_000
+ MIGRATION = 'CopyCiBuildsColumnsToSecurityScans'
+
+ disable_ddl_transaction!
+
+ class SecurityScan < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'security_scans'
+ end
+
+ def up
+ SecurityScan.reset_column_information
+
+ delete_job_tracking(MIGRATION, status: %w[pending succeeded])
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ SecurityScan,
+ MIGRATION,
+ INTERVAL,
+ batch_size: BATCH_SIZE,
+ track_jobs: true
+ )
+ end
+
+ def down
+ # noop
+ end
+end
diff --git a/db/schema_migrations/20210611082822 b/db/schema_migrations/20210611082822
new file mode 100644
index 00000000000..474adb00646
--- /dev/null
+++ b/db/schema_migrations/20210611082822
@@ -0,0 +1 @@
+28b31b6e8aba1b8feec2b9a29b5f91f7145431be5d8b9875bddb8183f89700f7 \ No newline at end of file
diff --git a/db/schema_migrations/20210628154900 b/db/schema_migrations/20210628154900
new file mode 100644
index 00000000000..5c0b60872b5
--- /dev/null
+++ b/db/schema_migrations/20210628154900
@@ -0,0 +1 @@
+136a375fbd7e1faf25e7f53e0677b8525811bd917892efa1430d204453bf2a1d \ No newline at end of file
diff --git a/db/schema_migrations/20210629031900 b/db/schema_migrations/20210629031900
new file mode 100644
index 00000000000..5f4949c36de
--- /dev/null
+++ b/db/schema_migrations/20210629031900
@@ -0,0 +1 @@
+4f20581b0d16157fbe984383417f0463d7e52252569480796aa3c73abf19c95f \ No newline at end of file
diff --git a/db/schema_migrations/20210630222522 b/db/schema_migrations/20210630222522
new file mode 100644
index 00000000000..737034eb132
--- /dev/null
+++ b/db/schema_migrations/20210630222522
@@ -0,0 +1 @@
+6cd7654e53bb3dd75118dd399473c98e9953cbb28eaed7a4e3a232de38ca72d1 \ No newline at end of file
diff --git a/db/schema_migrations/20210630224625 b/db/schema_migrations/20210630224625
new file mode 100644
index 00000000000..f6c7fccc41f
--- /dev/null
+++ b/db/schema_migrations/20210630224625
@@ -0,0 +1 @@
+570edf634eba17e5c7d388fdf7103acb857e477374763205535e280f72050f71 \ No newline at end of file
diff --git a/db/schema_migrations/20210701033622 b/db/schema_migrations/20210701033622
new file mode 100644
index 00000000000..40dcc68d424
--- /dev/null
+++ b/db/schema_migrations/20210701033622
@@ -0,0 +1 @@
+e38d73441ddd7f6238a66ee86009c445ad6056f3e6872e7a6c72abe051294d7e \ No newline at end of file
diff --git a/db/schema_migrations/20210706151154 b/db/schema_migrations/20210706151154
new file mode 100644
index 00000000000..32534755d69
--- /dev/null
+++ b/db/schema_migrations/20210706151154
@@ -0,0 +1 @@
+fc330cf9875a423db87748e84c574f2208e164945b56361a563f2085d324f610 \ No newline at end of file
diff --git a/db/schema_migrations/20210706151446 b/db/schema_migrations/20210706151446
new file mode 100644
index 00000000000..3d5d381b2a5
--- /dev/null
+++ b/db/schema_migrations/20210706151446
@@ -0,0 +1 @@
+4400cd95cf149a7abc759ca412b0d87c81bc405719999ce60502869d21d17aaa \ No newline at end of file
diff --git a/db/schema_migrations/20210706212710 b/db/schema_migrations/20210706212710
new file mode 100644
index 00000000000..7a4e6df37a4
--- /dev/null
+++ b/db/schema_migrations/20210706212710
@@ -0,0 +1 @@
+33162af4ef99c32d3c5b38479e407d4911a8d3dce53407dbee6e5745c8e945ae \ No newline at end of file
diff --git a/db/schema_migrations/20210707210916 b/db/schema_migrations/20210707210916
new file mode 100644
index 00000000000..e3c0f8fe783
--- /dev/null
+++ b/db/schema_migrations/20210707210916
@@ -0,0 +1 @@
+0681e068672621fbaa513cadd86e6137709413bb370ae9d416fc562b19f11ff6 \ No newline at end of file
diff --git a/db/schema_migrations/20210708202548 b/db/schema_migrations/20210708202548
new file mode 100644
index 00000000000..286bcb07786
--- /dev/null
+++ b/db/schema_migrations/20210708202548
@@ -0,0 +1 @@
+e2d7e54330f586bf31d953455b2ebac1fc9b6b24058a1cc7b277bc819ebf232a \ No newline at end of file
diff --git a/db/schema_migrations/20210709024048 b/db/schema_migrations/20210709024048
new file mode 100644
index 00000000000..52e089cd5a7
--- /dev/null
+++ b/db/schema_migrations/20210709024048
@@ -0,0 +1 @@
+d35079b6d6ed38ce8f212a09e684988f7499d456d28f70b6178914b1b17eee5b \ No newline at end of file
diff --git a/db/schema_migrations/20210709221051 b/db/schema_migrations/20210709221051
new file mode 100644
index 00000000000..1c2f47e20ad
--- /dev/null
+++ b/db/schema_migrations/20210709221051
@@ -0,0 +1 @@
+7847339fb7b143845e2715b15505016dc8e6de3fbd2c5cb4bae55da4f25a5a5f \ No newline at end of file
diff --git a/db/schema_migrations/20210709221659 b/db/schema_migrations/20210709221659
new file mode 100644
index 00000000000..f6626986920
--- /dev/null
+++ b/db/schema_migrations/20210709221659
@@ -0,0 +1 @@
+5bec34d517f3f2bbb9735f73fb5641512c9f5286ee5d7a59b17c976dd1459347 \ No newline at end of file
diff --git a/db/schema_migrations/20210712052519 b/db/schema_migrations/20210712052519
new file mode 100644
index 00000000000..3c0874b338f
--- /dev/null
+++ b/db/schema_migrations/20210712052519
@@ -0,0 +1 @@
+f3959b7a6f7ac95019f2f85c6383ddd11294562e94936ef3b5704bd4de7c5910 \ No newline at end of file
diff --git a/db/schema_migrations/20210713042153 b/db/schema_migrations/20210713042153
new file mode 100644
index 00000000000..fca0fe62d73
--- /dev/null
+++ b/db/schema_migrations/20210713042153
@@ -0,0 +1 @@
+95aa786acfbd53f1e819e49c6c6ec703d609396f2cc04a5791d1ffc77800dc72 \ No newline at end of file
diff --git a/db/schema_migrations/20210713075117 b/db/schema_migrations/20210713075117
new file mode 100644
index 00000000000..2525886b176
--- /dev/null
+++ b/db/schema_migrations/20210713075117
@@ -0,0 +1 @@
+9a8cbcf6ddbdd4379320ed747faed9beb0c2104eb89e61b349432b1f0346a4b5 \ No newline at end of file
diff --git a/db/schema_migrations/20210713123345 b/db/schema_migrations/20210713123345
new file mode 100644
index 00000000000..f145ecc3d6b
--- /dev/null
+++ b/db/schema_migrations/20210713123345
@@ -0,0 +1 @@
+d1226fdefe839aae4c7425924058e1944f883824c43a299b154bb6873d6c3855 \ No newline at end of file
diff --git a/db/schema_migrations/20210713211008 b/db/schema_migrations/20210713211008
new file mode 100644
index 00000000000..75ccad3e348
--- /dev/null
+++ b/db/schema_migrations/20210713211008
@@ -0,0 +1 @@
+f66d8f3bc32996fe7743cc98cfb96fedd86784d38c8debb5143b7adabdfebd18 \ No newline at end of file
diff --git a/db/schema_migrations/20210713223941 b/db/schema_migrations/20210713223941
new file mode 100644
index 00000000000..6b0ebf6de5d
--- /dev/null
+++ b/db/schema_migrations/20210713223941
@@ -0,0 +1 @@
+a97ac46a042b7f049f27db4f4916b8b0dbf527ba3c34fc9cc577da7807a88d32 \ No newline at end of file
diff --git a/db/schema_migrations/20210714015537 b/db/schema_migrations/20210714015537
new file mode 100644
index 00000000000..eb1c88e29a0
--- /dev/null
+++ b/db/schema_migrations/20210714015537
@@ -0,0 +1 @@
+2f6441a5d5e3c4aad6b88c3944436dab213b7eeb2f35453657ffac8c0733efc1 \ No newline at end of file
diff --git a/db/schema_migrations/20210714043818 b/db/schema_migrations/20210714043818
new file mode 100644
index 00000000000..21c46a2608f
--- /dev/null
+++ b/db/schema_migrations/20210714043818
@@ -0,0 +1 @@
+344736284dc18b5f7516ec2062bef99b2444ae31720691e56b4e8687d5566b31 \ No newline at end of file
diff --git a/db/schema_migrations/20210715074359 b/db/schema_migrations/20210715074359
new file mode 100644
index 00000000000..35cbbf55463
--- /dev/null
+++ b/db/schema_migrations/20210715074359
@@ -0,0 +1 @@
+7bc0654a97f85100df93b9dbbbdab374873f6d3d379a4393f718bad923b064ba \ No newline at end of file
diff --git a/db/schema_migrations/20210715074933 b/db/schema_migrations/20210715074933
new file mode 100644
index 00000000000..721e9d8d32c
--- /dev/null
+++ b/db/schema_migrations/20210715074933
@@ -0,0 +1 @@
+e29240947b2e0e6fa7c91643c5d1a2efa02ec062b5ccdffdf382dff993ab6225 \ No newline at end of file
diff --git a/db/schema_migrations/20210715075203 b/db/schema_migrations/20210715075203
new file mode 100644
index 00000000000..d123de45c42
--- /dev/null
+++ b/db/schema_migrations/20210715075203
@@ -0,0 +1 @@
+9d29f4d776031e90cb42122146f65bb13e8778d223467a83dc311f4adab31565 \ No newline at end of file
diff --git a/db/schema_migrations/20210719145532 b/db/schema_migrations/20210719145532
new file mode 100644
index 00000000000..a9afd7a18ed
--- /dev/null
+++ b/db/schema_migrations/20210719145532
@@ -0,0 +1 @@
+5e088e5109b50d8f4fadd37a0382d7dc4ce856a851ec2b97f8d5d868c3cb19fd \ No newline at end of file
diff --git a/db/schema_migrations/20210719182944 b/db/schema_migrations/20210719182944
new file mode 100644
index 00000000000..37213ace8d9
--- /dev/null
+++ b/db/schema_migrations/20210719182944
@@ -0,0 +1 @@
+9320dcd2a5bed122310aefd630f9c406a25b22767dba3bf118a30df044c2d6a7 \ No newline at end of file
diff --git a/db/schema_migrations/20210719192928 b/db/schema_migrations/20210719192928
new file mode 100644
index 00000000000..b15de2220ed
--- /dev/null
+++ b/db/schema_migrations/20210719192928
@@ -0,0 +1 @@
+eed403573697ac7f454ce47d6e4ab3561a10a62177caaaea40d5d70953068175 \ No newline at end of file
diff --git a/db/schema_migrations/20210720130006 b/db/schema_migrations/20210720130006
new file mode 100644
index 00000000000..c55eb9a283e
--- /dev/null
+++ b/db/schema_migrations/20210720130006
@@ -0,0 +1 @@
+03d86d635c54b53bd540443f0a911d4f0ae59ec3494be23952490c5df70dd28c \ No newline at end of file
diff --git a/db/schema_migrations/20210720140841 b/db/schema_migrations/20210720140841
new file mode 100644
index 00000000000..ecb20e55d1c
--- /dev/null
+++ b/db/schema_migrations/20210720140841
@@ -0,0 +1 @@
+1ef66bdf4a1c61d9a1e0e632d8728f86769ac727d43971e897284272e9f53581 \ No newline at end of file
diff --git a/db/schema_migrations/20210721125525 b/db/schema_migrations/20210721125525
new file mode 100644
index 00000000000..fa11899d7b4
--- /dev/null
+++ b/db/schema_migrations/20210721125525
@@ -0,0 +1 @@
+8ffb00b1a86fb1f9574b3811f88a65a1478f64cf59dc99a3324e04c4f4f0c7dd \ No newline at end of file
diff --git a/db/schema_migrations/20210721125545 b/db/schema_migrations/20210721125545
new file mode 100644
index 00000000000..372de21e151
--- /dev/null
+++ b/db/schema_migrations/20210721125545
@@ -0,0 +1 @@
+8b43136ea6df74ad379537e28392c43770ecd8586eff8e830c52e65976f6978a \ No newline at end of file
diff --git a/db/schema_migrations/20210721125620 b/db/schema_migrations/20210721125620
new file mode 100644
index 00000000000..4b72ac24379
--- /dev/null
+++ b/db/schema_migrations/20210721125620
@@ -0,0 +1 @@
+fa27f8e932f47946a67b2e739a978573e5f375ac0b1058ee79353e22d514755d \ No newline at end of file
diff --git a/db/schema_migrations/20210721125637 b/db/schema_migrations/20210721125637
new file mode 100644
index 00000000000..dd4b29fdf1c
--- /dev/null
+++ b/db/schema_migrations/20210721125637
@@ -0,0 +1 @@
+40f99f3c05290fe967cac6c1b90d913decacb491e1253fb166d4dd06363dd38b \ No newline at end of file
diff --git a/db/schema_migrations/20210721125804 b/db/schema_migrations/20210721125804
new file mode 100644
index 00000000000..41756d62a7f
--- /dev/null
+++ b/db/schema_migrations/20210721125804
@@ -0,0 +1 @@
+5c6cc14f49d8fa9d0f0610eab731f93f874d6e9b5e3d49d5a127830241528488 \ No newline at end of file
diff --git a/db/schema_migrations/20210721125820 b/db/schema_migrations/20210721125820
new file mode 100644
index 00000000000..0c281f8587a
--- /dev/null
+++ b/db/schema_migrations/20210721125820
@@ -0,0 +1 @@
+7cba2fedb94fb5dc7fa5b796c6a93d2c5c8b57aee64b294e0c20dde07bf5253a \ No newline at end of file
diff --git a/db/schema_migrations/20210721134706 b/db/schema_migrations/20210721134706
new file mode 100644
index 00000000000..c250f5661a9
--- /dev/null
+++ b/db/schema_migrations/20210721134706
@@ -0,0 +1 @@
+e6c8fd913f591fed24072e9b0032b47dbb1165f2c1cf50ed01cfcd5f7da32cba \ No newline at end of file
diff --git a/db/schema_migrations/20210721134707 b/db/schema_migrations/20210721134707
new file mode 100644
index 00000000000..4c25899474c
--- /dev/null
+++ b/db/schema_migrations/20210721134707
@@ -0,0 +1 @@
+a795dad532a5ed2a645e49e586c6fb73167e9ae38843cf5cbcf37cf8661b765a \ No newline at end of file
diff --git a/db/schema_migrations/20210721135638 b/db/schema_migrations/20210721135638
new file mode 100644
index 00000000000..3ca020593d2
--- /dev/null
+++ b/db/schema_migrations/20210721135638
@@ -0,0 +1 @@
+a4219ce93f790ec372991adca4b1cc5c0410d57e92817082344b11758ca5ae93 \ No newline at end of file
diff --git a/db/schema_migrations/20210721145029 b/db/schema_migrations/20210721145029
new file mode 100644
index 00000000000..2c28570b609
--- /dev/null
+++ b/db/schema_migrations/20210721145029
@@ -0,0 +1 @@
+1585d2912058ce3a9225233c23707a3679a3f8df2078c71b5cc48f28b7bb9392 \ No newline at end of file
diff --git a/db/schema_migrations/20210721174411 b/db/schema_migrations/20210721174411
new file mode 100644
index 00000000000..eae69e34afc
--- /dev/null
+++ b/db/schema_migrations/20210721174411
@@ -0,0 +1 @@
+ac95292b2ab05f17ed13cb8e95ace0660e6dc82e33d6ef1cccd02890abf6c739 \ No newline at end of file
diff --git a/db/schema_migrations/20210721174441 b/db/schema_migrations/20210721174441
new file mode 100644
index 00000000000..473e3b4c55a
--- /dev/null
+++ b/db/schema_migrations/20210721174441
@@ -0,0 +1 @@
+9f3a39b11f250f64e4e6b8623279604c1dba14330f45c26840f6e0b46f7d48a7 \ No newline at end of file
diff --git a/db/schema_migrations/20210721174453 b/db/schema_migrations/20210721174453
new file mode 100644
index 00000000000..3fe95971491
--- /dev/null
+++ b/db/schema_migrations/20210721174453
@@ -0,0 +1 @@
+7b20c623b58982ba5d228902c6da6d10245edf3874ece9b02d58e8560d2d5d96 \ No newline at end of file
diff --git a/db/schema_migrations/20210721174521 b/db/schema_migrations/20210721174521
new file mode 100644
index 00000000000..03887b9c738
--- /dev/null
+++ b/db/schema_migrations/20210721174521
@@ -0,0 +1 @@
+f16b563bbfa15b97143e82d2a1e78e9d9805d13e02e3a0845369d4ce3204b3cc \ No newline at end of file
diff --git a/db/schema_migrations/20210721211602 b/db/schema_migrations/20210721211602
new file mode 100644
index 00000000000..bf96fc31ea5
--- /dev/null
+++ b/db/schema_migrations/20210721211602
@@ -0,0 +1 @@
+ee3e6377478302f41aa06f2278f38a9dde2f325318b4f2eba1007abb1dd1099c \ No newline at end of file
diff --git a/db/schema_migrations/20210722010101 b/db/schema_migrations/20210722010101
new file mode 100644
index 00000000000..ed0b98e6d1a
--- /dev/null
+++ b/db/schema_migrations/20210722010101
@@ -0,0 +1 @@
+bbd39849499d16f92a5129506a87a6b253f209200bcb3a63c2432862c4b78aae \ No newline at end of file
diff --git a/db/schema_migrations/20210722042939 b/db/schema_migrations/20210722042939
new file mode 100644
index 00000000000..fe5a3820bf9
--- /dev/null
+++ b/db/schema_migrations/20210722042939
@@ -0,0 +1 @@
+dd3b35b87c2f015895d807ede2521c9672fb41ec7a3b0b1a2f7abdc009950b6e \ No newline at end of file
diff --git a/db/schema_migrations/20210722055217 b/db/schema_migrations/20210722055217
new file mode 100644
index 00000000000..45d62ce852c
--- /dev/null
+++ b/db/schema_migrations/20210722055217
@@ -0,0 +1 @@
+bd934c20443d5a044caa9e92389018291ffb2bf60b8ca54d9baca4a0e70caf28 \ No newline at end of file
diff --git a/db/schema_migrations/20210722074220 b/db/schema_migrations/20210722074220
new file mode 100644
index 00000000000..d0bc4133883
--- /dev/null
+++ b/db/schema_migrations/20210722074220
@@ -0,0 +1 @@
+cf276b9aa97fc7857499e1b103a8e09eda329a4db92d0e653cc6f7128987be39 \ No newline at end of file
diff --git a/db/schema_migrations/20210722074242 b/db/schema_migrations/20210722074242
new file mode 100644
index 00000000000..2fc61b36ed2
--- /dev/null
+++ b/db/schema_migrations/20210722074242
@@ -0,0 +1 @@
+5c6aff5b43a1e81e84a42f008a8a1ab90c77ee450884aa1ecc86bce551424f43 \ No newline at end of file
diff --git a/db/schema_migrations/20210722074256 b/db/schema_migrations/20210722074256
new file mode 100644
index 00000000000..cedf6a7419b
--- /dev/null
+++ b/db/schema_migrations/20210722074256
@@ -0,0 +1 @@
+d49b1f48c2fa1cac8d7793f8bb025792f4bb85eed787ba3abdbaa4647523b70a \ No newline at end of file
diff --git a/db/schema_migrations/20210722074309 b/db/schema_migrations/20210722074309
new file mode 100644
index 00000000000..27b1bb9e493
--- /dev/null
+++ b/db/schema_migrations/20210722074309
@@ -0,0 +1 @@
+eab0f8488b0122ec6c5625c66ebcbd221579bdd9cc2cf670d1f26181709f23b7 \ No newline at end of file
diff --git a/db/schema_migrations/20210722074339 b/db/schema_migrations/20210722074339
new file mode 100644
index 00000000000..dc269e54868
--- /dev/null
+++ b/db/schema_migrations/20210722074339
@@ -0,0 +1 @@
+a7a6697d86b71d59104af35a9d7d6f3caebf4ee1252e4f3e52133afb3f642e48 \ No newline at end of file
diff --git a/db/schema_migrations/20210722132844 b/db/schema_migrations/20210722132844
new file mode 100644
index 00000000000..7367cb1c13e
--- /dev/null
+++ b/db/schema_migrations/20210722132844
@@ -0,0 +1 @@
+b4dfa045ec38a15d46288acc271a3ae93fed85b8605ab11640d9bbcfbd5b94cf \ No newline at end of file
diff --git a/db/schema_migrations/20210722150102 b/db/schema_migrations/20210722150102
new file mode 100644
index 00000000000..42f6cfb3b7e
--- /dev/null
+++ b/db/schema_migrations/20210722150102
@@ -0,0 +1 @@
+cea8e51f6917be9ad43280fba9f8e7d9b9db1f508e249d9f5df792e43c0b8313 \ No newline at end of file
diff --git a/db/schema_migrations/20210722151951 b/db/schema_migrations/20210722151951
new file mode 100644
index 00000000000..a5e6a8c0963
--- /dev/null
+++ b/db/schema_migrations/20210722151951
@@ -0,0 +1 @@
+7289fb2a65c1210a352991fae7fac0c8e1129a33c166d0dad6f2aed98cb672a6 \ No newline at end of file
diff --git a/db/schema_migrations/20210722155635 b/db/schema_migrations/20210722155635
new file mode 100644
index 00000000000..d131ff9016e
--- /dev/null
+++ b/db/schema_migrations/20210722155635
@@ -0,0 +1 @@
+d98c54e5ec60fc0ee1c008160118f6f0c45eb801932d4d3abcd26aba33ebdea6 \ No newline at end of file
diff --git a/db/schema_migrations/20210722210041 b/db/schema_migrations/20210722210041
new file mode 100644
index 00000000000..09dbff3b4c2
--- /dev/null
+++ b/db/schema_migrations/20210722210041
@@ -0,0 +1 @@
+253a3520f05e252b6e6bbb3ef5f8af6c374c897ffa736c89fbea3089fdfa8fc4 \ No newline at end of file
diff --git a/db/schema_migrations/20210723173132 b/db/schema_migrations/20210723173132
new file mode 100644
index 00000000000..3199fb547d5
--- /dev/null
+++ b/db/schema_migrations/20210723173132
@@ -0,0 +1 @@
+b64ba2a9ee42497aa9f60ca76f4925076cb77e73fd79bb9b10362cd48d11252b \ No newline at end of file
diff --git a/db/schema_migrations/20210726134950 b/db/schema_migrations/20210726134950
new file mode 100644
index 00000000000..73f298e04a7
--- /dev/null
+++ b/db/schema_migrations/20210726134950
@@ -0,0 +1 @@
+d989534193566d90f1d4d61a0a588f3204670b67e049e875011a06b32ffd941a \ No newline at end of file
diff --git a/db/schema_migrations/20210726202748 b/db/schema_migrations/20210726202748
new file mode 100644
index 00000000000..390847c8a07
--- /dev/null
+++ b/db/schema_migrations/20210726202748
@@ -0,0 +1 @@
+378e12c3c7c49e294ab4ab792151af8e3829cc6f38295d5faa0995ad16f3f934 \ No newline at end of file
diff --git a/db/schema_migrations/20210727113447 b/db/schema_migrations/20210727113447
new file mode 100644
index 00000000000..236022f5af3
--- /dev/null
+++ b/db/schema_migrations/20210727113447
@@ -0,0 +1 @@
+19e23131949e6056ea9837231fac6a2307fb52a8287eb34cc6e89eed11d52849 \ No newline at end of file
diff --git a/db/schema_migrations/20210727175201 b/db/schema_migrations/20210727175201
new file mode 100644
index 00000000000..78dae022e6b
--- /dev/null
+++ b/db/schema_migrations/20210727175201
@@ -0,0 +1 @@
+c7ae79084b802723a24064cb700b6cdc9a23011d3fed45457799c1ae7aa19ce6 \ No newline at end of file
diff --git a/db/schema_migrations/20210728110654 b/db/schema_migrations/20210728110654
new file mode 100644
index 00000000000..3dd51a29bb7
--- /dev/null
+++ b/db/schema_migrations/20210728110654
@@ -0,0 +1 @@
+8c317e202b9fb5fc3733325fd2447f65283c3752fcb314033f5d3b2b28484f71 \ No newline at end of file
diff --git a/db/schema_migrations/20210728174349 b/db/schema_migrations/20210728174349
new file mode 100644
index 00000000000..59035edce30
--- /dev/null
+++ b/db/schema_migrations/20210728174349
@@ -0,0 +1 @@
+3a56c903333f13e9e3d39e5b65a3b70fdcfbf967cdac8bff348dfb71c0fde520 \ No newline at end of file
diff --git a/db/schema_migrations/20210729061526 b/db/schema_migrations/20210729061526
new file mode 100644
index 00000000000..a56a4b4b245
--- /dev/null
+++ b/db/schema_migrations/20210729061526
@@ -0,0 +1 @@
+5c71f4176ecf8f422e948c2c2ecb1e6662494def11e06d7d0071d73f379770f0 \ No newline at end of file
diff --git a/db/schema_migrations/20210729061556 b/db/schema_migrations/20210729061556
new file mode 100644
index 00000000000..3b39a351328
--- /dev/null
+++ b/db/schema_migrations/20210729061556
@@ -0,0 +1 @@
+75be4e92b482c9003485658c42ba1e94a2d5c6a5a0653c8a27c5983fafd1d6a7 \ No newline at end of file
diff --git a/db/schema_migrations/20210729123101 b/db/schema_migrations/20210729123101
new file mode 100644
index 00000000000..77f5bfba94e
--- /dev/null
+++ b/db/schema_migrations/20210729123101
@@ -0,0 +1 @@
+8522eaf951d87de04aea82fe8e1a9577e6665c8d08245282239476e49b02bc7d \ No newline at end of file
diff --git a/db/schema_migrations/20210729161242 b/db/schema_migrations/20210729161242
new file mode 100644
index 00000000000..38769ac4ff0
--- /dev/null
+++ b/db/schema_migrations/20210729161242
@@ -0,0 +1 @@
+22a64ce9a8cbebd2024908cc74cc92a50fb6ccaa1580ebea3be60d3659c48fa0 \ No newline at end of file
diff --git a/db/schema_migrations/20210729163312 b/db/schema_migrations/20210729163312
new file mode 100644
index 00000000000..2c888f6786f
--- /dev/null
+++ b/db/schema_migrations/20210729163312
@@ -0,0 +1 @@
+94978b93b1590cb2cfd9536a44a8817aa485a35d5372dfed31041261f5e12406 \ No newline at end of file
diff --git a/db/schema_migrations/20210729192148 b/db/schema_migrations/20210729192148
new file mode 100644
index 00000000000..8cf650a223a
--- /dev/null
+++ b/db/schema_migrations/20210729192148
@@ -0,0 +1 @@
+6ed7827f6f911dbb40637ac056298877b709fb7356bc9ee3a366cceb48268646 \ No newline at end of file
diff --git a/db/schema_migrations/20210729192959 b/db/schema_migrations/20210729192959
new file mode 100644
index 00000000000..df4f4ed2c71
--- /dev/null
+++ b/db/schema_migrations/20210729192959
@@ -0,0 +1 @@
+3cb0c88fddfec66c0d89c4c1f34d0538be88a44f2039e6c542c5282b293ce019 \ No newline at end of file
diff --git a/db/schema_migrations/20210729193056 b/db/schema_migrations/20210729193056
new file mode 100644
index 00000000000..fea83eb2750
--- /dev/null
+++ b/db/schema_migrations/20210729193056
@@ -0,0 +1 @@
+d983a765482b368bd7a238b3b75fc9b0a45310f295953ea053ee4c42785e8684 \ No newline at end of file
diff --git a/db/schema_migrations/20210729202143 b/db/schema_migrations/20210729202143
new file mode 100644
index 00000000000..c817508eb5f
--- /dev/null
+++ b/db/schema_migrations/20210729202143
@@ -0,0 +1 @@
+ce20c699d6e6d6baf812c926dde08485764faa2fdeb8af14808670bf692aab00 \ No newline at end of file
diff --git a/db/schema_migrations/20210730101609 b/db/schema_migrations/20210730101609
new file mode 100644
index 00000000000..f3522b194b2
--- /dev/null
+++ b/db/schema_migrations/20210730101609
@@ -0,0 +1 @@
+f819eaed7e387f18f066180cbf9d0849b3e38db95bbf3e8487d3bc58d9b489ae \ No newline at end of file
diff --git a/db/schema_migrations/20210730102952 b/db/schema_migrations/20210730102952
new file mode 100644
index 00000000000..a21008671c2
--- /dev/null
+++ b/db/schema_migrations/20210730102952
@@ -0,0 +1 @@
+cb97b869bfb0b76dd0684aca1f40c86e7c1c9c9a0d52684830115288088e8066 \ No newline at end of file
diff --git a/db/schema_migrations/20210730103808 b/db/schema_migrations/20210730103808
new file mode 100644
index 00000000000..6467a981cbb
--- /dev/null
+++ b/db/schema_migrations/20210730103808
@@ -0,0 +1 @@
+5c104ffdb64943aa4828a9b961c8f9141dfd2ae861cea7116722d2b0d4598957 \ No newline at end of file
diff --git a/db/schema_migrations/20210730170823 b/db/schema_migrations/20210730170823
new file mode 100644
index 00000000000..d1822fde24b
--- /dev/null
+++ b/db/schema_migrations/20210730170823
@@ -0,0 +1 @@
+33b260626d65347a80240ffdce5f9e2abfc578e8151ed41f1ca9b16ef2654853 \ No newline at end of file
diff --git a/db/schema_migrations/20210802043253 b/db/schema_migrations/20210802043253
new file mode 100644
index 00000000000..a8017b11b8a
--- /dev/null
+++ b/db/schema_migrations/20210802043253
@@ -0,0 +1 @@
+b844c7c56019fc984c2604ae11f6ee9eb587806b5c78e4beea4dda93e384f9b2 \ No newline at end of file
diff --git a/db/schema_migrations/20210802112233 b/db/schema_migrations/20210802112233
new file mode 100644
index 00000000000..68626f9398b
--- /dev/null
+++ b/db/schema_migrations/20210802112233
@@ -0,0 +1 @@
+1b55c50a9ba085ae7a0552da4985755c67eafb74e76b06590179803b4b215f81 \ No newline at end of file
diff --git a/db/schema_migrations/20210802131812 b/db/schema_migrations/20210802131812
new file mode 100644
index 00000000000..ef533ba9abd
--- /dev/null
+++ b/db/schema_migrations/20210802131812
@@ -0,0 +1 @@
+a686e5df8b1528fa4d8d1c7b65b234837443d0cc249d08a38694f83263bb0532 \ No newline at end of file
diff --git a/db/schema_migrations/20210803110920 b/db/schema_migrations/20210803110920
new file mode 100644
index 00000000000..69ba671ea7b
--- /dev/null
+++ b/db/schema_migrations/20210803110920
@@ -0,0 +1 @@
+529cf86e09b5aa9015b604e73827cb21e92ced401f30dfb281115a506596bd4e \ No newline at end of file
diff --git a/db/schema_migrations/20210804150320 b/db/schema_migrations/20210804150320
new file mode 100644
index 00000000000..336fec35970
--- /dev/null
+++ b/db/schema_migrations/20210804150320
@@ -0,0 +1 @@
+53d4f6ca18602b25af631a25dee7b0ebf9cb98e7a4f8cd87830f939bc13bb893 \ No newline at end of file
diff --git a/db/schema_migrations/20210804150624 b/db/schema_migrations/20210804150624
new file mode 100644
index 00000000000..135519b6b93
--- /dev/null
+++ b/db/schema_migrations/20210804150624
@@ -0,0 +1 @@
+52e71aa3ec92473006b37e9319797133356f7747b91c32b09a746e183501655f \ No newline at end of file
diff --git a/db/schema_migrations/20210804151444 b/db/schema_migrations/20210804151444
new file mode 100644
index 00000000000..0d633c3da36
--- /dev/null
+++ b/db/schema_migrations/20210804151444
@@ -0,0 +1 @@
+4a6676e9185a99070751c91c71a7a9e6a845426d68567abf80a2e414251e5805 \ No newline at end of file
diff --git a/db/schema_migrations/20210804153307 b/db/schema_migrations/20210804153307
new file mode 100644
index 00000000000..ae7baaa4cf4
--- /dev/null
+++ b/db/schema_migrations/20210804153307
@@ -0,0 +1 @@
+d73756410c7f37662c50bb05c372e6ac32ba81f232c07debcd42d1f679eb74ef \ No newline at end of file
diff --git a/db/schema_migrations/20210804154407 b/db/schema_migrations/20210804154407
new file mode 100644
index 00000000000..dc0e40c7117
--- /dev/null
+++ b/db/schema_migrations/20210804154407
@@ -0,0 +1 @@
+ab7ee98704e844de4a3ba3ae14ea64dd46539e63d49c7c7e0d67ed03ebc3bbd4 \ No newline at end of file
diff --git a/db/schema_migrations/20210804200114 b/db/schema_migrations/20210804200114
new file mode 100644
index 00000000000..b4ac42657ba
--- /dev/null
+++ b/db/schema_migrations/20210804200114
@@ -0,0 +1 @@
+db62fb6413db4be5e1013bccf16b0c3a66c9aaf9f3d646f42442be16c511af5f \ No newline at end of file
diff --git a/db/schema_migrations/20210804202057 b/db/schema_migrations/20210804202057
new file mode 100644
index 00000000000..dd592038d11
--- /dev/null
+++ b/db/schema_migrations/20210804202057
@@ -0,0 +1 @@
+48f140728fede7cf38469c8dfcb5480b4f2b8e29af4b1edd5d38024548493c2d \ No newline at end of file
diff --git a/db/schema_migrations/20210805085706 b/db/schema_migrations/20210805085706
new file mode 100644
index 00000000000..b41a68968ec
--- /dev/null
+++ b/db/schema_migrations/20210805085706
@@ -0,0 +1 @@
+ec968f1f9fcc5a3551664e74726e1c65b327128e2388e1357ae6d0cf6f05fb95 \ No newline at end of file
diff --git a/db/schema_migrations/20210805131510 b/db/schema_migrations/20210805131510
new file mode 100644
index 00000000000..a80524552b9
--- /dev/null
+++ b/db/schema_migrations/20210805131510
@@ -0,0 +1 @@
+ee6dc82719ecfbdf58d2c76589f328bed9e1a4455f4c593ae45ae7b2afc62602 \ No newline at end of file
diff --git a/db/schema_migrations/20210805192450 b/db/schema_migrations/20210805192450
new file mode 100644
index 00000000000..1b9ae3880e0
--- /dev/null
+++ b/db/schema_migrations/20210805192450
@@ -0,0 +1 @@
+a63f878d89269eb8a2a3cc3b0c81d700861031a079a4a69b56d45d73c4c7946e \ No newline at end of file
diff --git a/db/schema_migrations/20210806011811 b/db/schema_migrations/20210806011811
new file mode 100644
index 00000000000..7b8317bec10
--- /dev/null
+++ b/db/schema_migrations/20210806011811
@@ -0,0 +1 @@
+e4f4f3c91cdb8ce8b1fa6c2bd0bb1fb1a8c0dedbb78c20bbaef6e36bfa9551c4 \ No newline at end of file
diff --git a/db/schema_migrations/20210806152104 b/db/schema_migrations/20210806152104
new file mode 100644
index 00000000000..a8bdc0615d5
--- /dev/null
+++ b/db/schema_migrations/20210806152104
@@ -0,0 +1 @@
+1bdbcc6ef5ccf7a2bfb1f9571885e218e230a81b632a2d993302bd87432963f3 \ No newline at end of file
diff --git a/db/schema_migrations/20210809123658 b/db/schema_migrations/20210809123658
new file mode 100644
index 00000000000..0db44d3c8f5
--- /dev/null
+++ b/db/schema_migrations/20210809123658
@@ -0,0 +1 @@
+f4a1963c8f21b8c767766c3a18037bae223efce8452c87f570cf9789d6f666d6 \ No newline at end of file
diff --git a/db/schema_migrations/20210809143931 b/db/schema_migrations/20210809143931
new file mode 100644
index 00000000000..294c62d54d8
--- /dev/null
+++ b/db/schema_migrations/20210809143931
@@ -0,0 +1 @@
+37cac2c3c5c5c22a34e0a77733c5330a32101090ac47b46260123c3362a9e36f \ No newline at end of file
diff --git a/db/schema_migrations/20210809194250 b/db/schema_migrations/20210809194250
new file mode 100644
index 00000000000..c70e543e20e
--- /dev/null
+++ b/db/schema_migrations/20210809194250
@@ -0,0 +1 @@
+35475ad862d713055a90af508dba393834ce8aa60eb1abf46b8f9698c2d42276 \ No newline at end of file
diff --git a/db/schema_migrations/20210811214811 b/db/schema_migrations/20210811214811
new file mode 100644
index 00000000000..b34641b6b44
--- /dev/null
+++ b/db/schema_migrations/20210811214811
@@ -0,0 +1 @@
+9e66aa8fc5e2a32ce0857f7ef77e906424bdf86c49643dfc71ed1a2e353b2095 \ No newline at end of file
diff --git a/db/schema_migrations/20210812145010 b/db/schema_migrations/20210812145010
new file mode 100644
index 00000000000..0a00afc3c70
--- /dev/null
+++ b/db/schema_migrations/20210812145010
@@ -0,0 +1 @@
+24c49a12b6624c8e215e8a0c16b1bc9acc1875e68d3727fc3904b9e2eee1d319 \ No newline at end of file
diff --git a/db/schema_migrations/20210812171704 b/db/schema_migrations/20210812171704
new file mode 100644
index 00000000000..2471f7cdd38
--- /dev/null
+++ b/db/schema_migrations/20210812171704
@@ -0,0 +1 @@
+7c62c47ebad110a343c1f9834ae34bd0fa2bad763025da06f911e127a7380542 \ No newline at end of file
diff --git a/db/schema_migrations/20210813101742 b/db/schema_migrations/20210813101742
new file mode 100644
index 00000000000..f711612a8dc
--- /dev/null
+++ b/db/schema_migrations/20210813101742
@@ -0,0 +1 @@
+4401423fc602a6d5df95857282bb84851fa99ddeb6c3d1ce4614f12c1dc4ec87 \ No newline at end of file
diff --git a/db/schema_migrations/20210813111909 b/db/schema_migrations/20210813111909
new file mode 100644
index 00000000000..c6073d273da
--- /dev/null
+++ b/db/schema_migrations/20210813111909
@@ -0,0 +1 @@
+78ea79c2157acb8a0b29afb4d2f3de6965fb0ea885b5d5f939f22ccda1d53b1e \ No newline at end of file
diff --git a/db/schema_migrations/20210813195518 b/db/schema_migrations/20210813195518
new file mode 100644
index 00000000000..d64dd04d05b
--- /dev/null
+++ b/db/schema_migrations/20210813195518
@@ -0,0 +1 @@
+848e0201709b3608e76308e9d610e2a4e48ab665c7d8b52f3d23f0a215df58ff \ No newline at end of file
diff --git a/db/schema_migrations/20210816161107 b/db/schema_migrations/20210816161107
new file mode 100644
index 00000000000..1b8ab5265b7
--- /dev/null
+++ b/db/schema_migrations/20210816161107
@@ -0,0 +1 @@
+1e4d0b062c8e43b1af37c6cf869f9c173248d7bf5451b4aa5468d48c1004b97c \ No newline at end of file
diff --git a/db/schema_migrations/20210816183304 b/db/schema_migrations/20210816183304
new file mode 100644
index 00000000000..eebc52f99d7
--- /dev/null
+++ b/db/schema_migrations/20210816183304
@@ -0,0 +1 @@
+08fed4e3269629304c5036361c237f4c9b860c26212b155869773296a79df01a \ No newline at end of file
diff --git a/db/schema_migrations/20210817084338 b/db/schema_migrations/20210817084338
new file mode 100644
index 00000000000..ca7219b7ea6
--- /dev/null
+++ b/db/schema_migrations/20210817084338
@@ -0,0 +1 @@
+e301e1be82c96e62bba0f958c54dda4633b28553246d4c576d6de33cd33e0a50 \ No newline at end of file
diff --git a/db/schema_migrations/20210818034001 b/db/schema_migrations/20210818034001
new file mode 100644
index 00000000000..e20a891b5f1
--- /dev/null
+++ b/db/schema_migrations/20210818034001
@@ -0,0 +1 @@
+ebf0c2a7b0563dafa562136a0758baf631db92c0ce33f7200da24092f1eb2930 \ No newline at end of file
diff --git a/db/schema_migrations/20210818055357 b/db/schema_migrations/20210818055357
new file mode 100644
index 00000000000..1557aa0ac3e
--- /dev/null
+++ b/db/schema_migrations/20210818055357
@@ -0,0 +1 @@
+1092a16d742b08ef2ef5f74bdaa92bb5f9cedbdb1161ab71abe501c39b164689 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 3a11a1fc7ab..eee73636eb1 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -10,6 +10,62 @@ CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
+CREATE FUNCTION integrations_set_type_new() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+WITH mapping(old_type, new_type) AS (VALUES
+ ('AsanaService', 'Integrations::Asana'),
+ ('AssemblaService', 'Integrations::Assembla'),
+ ('BambooService', 'Integrations::Bamboo'),
+ ('BugzillaService', 'Integrations::Bugzilla'),
+ ('BuildkiteService', 'Integrations::Buildkite'),
+ ('CampfireService', 'Integrations::Campfire'),
+ ('ConfluenceService', 'Integrations::Confluence'),
+ ('CustomIssueTrackerService', 'Integrations::CustomIssueTracker'),
+ ('DatadogService', 'Integrations::Datadog'),
+ ('DiscordService', 'Integrations::Discord'),
+ ('DroneCiService', 'Integrations::DroneCi'),
+ ('EmailsOnPushService', 'Integrations::EmailsOnPush'),
+ ('EwmService', 'Integrations::Ewm'),
+ ('ExternalWikiService', 'Integrations::ExternalWiki'),
+ ('FlowdockService', 'Integrations::Flowdock'),
+ ('HangoutsChatService', 'Integrations::HangoutsChat'),
+ ('IrkerService', 'Integrations::Irker'),
+ ('JenkinsService', 'Integrations::Jenkins'),
+ ('JiraService', 'Integrations::Jira'),
+ ('MattermostService', 'Integrations::Mattermost'),
+ ('MattermostSlashCommandsService', 'Integrations::MattermostSlashCommands'),
+ ('MicrosoftTeamsService', 'Integrations::MicrosoftTeams'),
+ ('MockCiService', 'Integrations::MockCi'),
+ ('MockMonitoringService', 'Integrations::MockMonitoring'),
+ ('PackagistService', 'Integrations::Packagist'),
+ ('PipelinesEmailService', 'Integrations::PipelinesEmail'),
+ ('PivotaltrackerService', 'Integrations::Pivotaltracker'),
+ ('PrometheusService', 'Integrations::Prometheus'),
+ ('PushoverService', 'Integrations::Pushover'),
+ ('RedmineService', 'Integrations::Redmine'),
+ ('SlackService', 'Integrations::Slack'),
+ ('SlackSlashCommandsService', 'Integrations::SlackSlashCommands'),
+ ('TeamcityService', 'Integrations::Teamcity'),
+ ('UnifyCircuitService', 'Integrations::UnifyCircuit'),
+ ('YoutrackService', 'Integrations::Youtrack'),
+ ('WebexTeamsService', 'Integrations::WebexTeams'),
+
+ -- EE-only integrations
+ ('GithubService', 'Integrations::Github'),
+ ('GitlabSlackApplicationService', 'Integrations::GitlabSlackApplication')
+)
+
+UPDATE integrations SET type_new = mapping.new_type
+FROM mapping
+WHERE integrations.id = NEW.id
+ AND mapping.old_type = NEW.type;
+RETURN NULL;
+
+END
+$$;
+
CREATE FUNCTION set_has_external_issue_tracker() RETURNS trigger
LANGUAGE plpgsql
AS $$
@@ -201,13 +257,13 @@ PARTITION BY RANGE (created_at);
CREATE TABLE incident_management_pending_alert_escalations (
id bigint NOT NULL,
- rule_id bigint,
+ rule_id bigint NOT NULL,
alert_id bigint NOT NULL,
- schedule_id bigint NOT NULL,
+ schedule_id bigint,
process_at timestamp with time zone NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
- status smallint NOT NULL
+ status smallint
)
PARTITION BY RANGE (process_at);
@@ -9029,7 +9085,8 @@ CREATE TABLE analytics_cycle_analytics_group_stages (
hidden boolean DEFAULT false NOT NULL,
custom boolean DEFAULT true NOT NULL,
name character varying(255) NOT NULL,
- group_value_stream_id bigint NOT NULL
+ group_value_stream_id bigint NOT NULL,
+ stage_event_hash_id bigint
);
CREATE SEQUENCE analytics_cycle_analytics_group_stages_id_seq
@@ -9072,7 +9129,8 @@ CREATE TABLE analytics_cycle_analytics_project_stages (
hidden boolean DEFAULT false NOT NULL,
custom boolean DEFAULT true NOT NULL,
name character varying(255) NOT NULL,
- project_value_stream_id bigint NOT NULL
+ project_value_stream_id bigint NOT NULL,
+ stage_event_hash_id bigint
);
CREATE SEQUENCE analytics_cycle_analytics_project_stages_id_seq
@@ -9102,6 +9160,20 @@ CREATE SEQUENCE analytics_cycle_analytics_project_value_streams_id_seq
ALTER SEQUENCE analytics_cycle_analytics_project_value_streams_id_seq OWNED BY analytics_cycle_analytics_project_value_streams.id;
+CREATE TABLE analytics_cycle_analytics_stage_event_hashes (
+ id bigint NOT NULL,
+ hash_sha256 bytea
+);
+
+CREATE SEQUENCE analytics_cycle_analytics_stage_event_hashes_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE analytics_cycle_analytics_stage_event_hashes_id_seq OWNED BY analytics_cycle_analytics_stage_event_hashes.id;
+
CREATE TABLE analytics_devops_adoption_segments (
id bigint NOT NULL,
last_recorded_at timestamp with time zone,
@@ -9550,6 +9622,9 @@ CREATE TABLE application_settings (
encrypted_mailgun_signing_key_iv bytea,
mailgun_events_enabled boolean DEFAULT false NOT NULL,
usage_ping_features_enabled boolean DEFAULT false NOT NULL,
+ encrypted_customers_dot_jwt_signing_key bytea,
+ encrypted_customers_dot_jwt_signing_key_iv bytea,
+ pypi_package_requests_forwarding boolean DEFAULT true 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_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)),
CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)),
@@ -9669,7 +9744,10 @@ CREATE TABLE approval_project_rules (
project_id integer NOT NULL,
approvals_required smallint DEFAULT 0 NOT NULL,
name character varying NOT NULL,
- rule_type smallint DEFAULT 0 NOT NULL
+ rule_type smallint DEFAULT 0 NOT NULL,
+ scanners text[],
+ vulnerabilities_allowed smallint,
+ severity_levels text[] DEFAULT '{}'::text[] NOT NULL
);
CREATE TABLE approval_project_rules_groups (
@@ -9901,6 +9979,12 @@ CREATE SEQUENCE badges_id_seq
ALTER SEQUENCE badges_id_seq OWNED BY badges.id;
+CREATE TABLE banned_users (
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ user_id bigint NOT NULL
+);
+
CREATE TABLE batched_background_migration_jobs (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -10420,11 +10504,11 @@ ALTER SEQUENCE chat_teams_id_seq OWNED BY chat_teams.id;
CREATE TABLE ci_build_needs (
id integer NOT NULL,
- build_id integer NOT NULL,
+ build_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
name text NOT NULL,
artifacts boolean DEFAULT true NOT NULL,
optional boolean DEFAULT false NOT NULL,
- build_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+ build_id bigint NOT NULL
);
CREATE SEQUENCE ci_build_needs_id_seq
@@ -10473,13 +10557,13 @@ ALTER SEQUENCE ci_build_report_results_build_id_seq OWNED BY ci_build_report_res
CREATE TABLE ci_build_trace_chunks (
id bigint NOT NULL,
- build_id integer NOT NULL,
+ build_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
chunk_index integer NOT NULL,
data_store integer NOT NULL,
raw_data bytea,
checksum bytea,
lock_version integer DEFAULT 0 NOT NULL,
- build_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+ build_id bigint NOT NULL
);
CREATE SEQUENCE ci_build_trace_chunks_id_seq
@@ -10491,30 +10575,12 @@ CREATE SEQUENCE ci_build_trace_chunks_id_seq
ALTER SEQUENCE ci_build_trace_chunks_id_seq OWNED BY ci_build_trace_chunks.id;
-CREATE TABLE ci_build_trace_section_names (
- id integer NOT NULL,
- project_id integer NOT NULL,
- name character varying NOT NULL
-);
-
-CREATE SEQUENCE ci_build_trace_section_names_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE ci_build_trace_section_names_id_seq OWNED BY ci_build_trace_section_names.id;
-
-CREATE TABLE ci_build_trace_sections (
- project_id integer NOT NULL,
- date_start timestamp without time zone NOT NULL,
- date_end timestamp without time zone NOT NULL,
- byte_start bigint NOT NULL,
- byte_end bigint NOT NULL,
- build_id integer NOT NULL,
- section_name_id integer NOT NULL,
- build_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+CREATE TABLE ci_build_trace_metadata (
+ build_id bigint NOT NULL,
+ trace_artifact_id bigint,
+ archival_attempts smallint DEFAULT 0 NOT NULL,
+ checksum bytea,
+ remote_checksum bytea
);
CREATE TABLE ci_builds (
@@ -10605,11 +10671,11 @@ ALTER SEQUENCE ci_builds_metadata_id_seq OWNED BY ci_builds_metadata.id;
CREATE TABLE ci_builds_runner_session (
id bigint NOT NULL,
- build_id integer NOT NULL,
+ build_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
url character varying NOT NULL,
certificate character varying,
"authorization" character varying,
- build_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+ build_id bigint NOT NULL
);
CREATE SEQUENCE ci_builds_runner_session_id_seq
@@ -10728,9 +10794,9 @@ CREATE SEQUENCE ci_instance_variables_id_seq
ALTER SEQUENCE ci_instance_variables_id_seq OWNED BY ci_instance_variables.id;
CREATE TABLE ci_job_artifacts (
- id integer NOT NULL,
+ id_convert_to_bigint integer DEFAULT 0 NOT NULL,
project_id integer NOT NULL,
- job_id integer NOT NULL,
+ job_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
file_type integer NOT NULL,
size bigint,
created_at timestamp with time zone NOT NULL,
@@ -10741,8 +10807,8 @@ CREATE TABLE ci_job_artifacts (
file_sha256 bytea,
file_format smallint,
file_location smallint,
- id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
- job_id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
+ id bigint NOT NULL,
+ job_id bigint NOT NULL,
CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL))
);
@@ -10835,7 +10901,9 @@ CREATE TABLE ci_pending_builds (
project_id bigint NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
protected boolean DEFAULT false NOT NULL,
- instance_runners_enabled boolean DEFAULT false NOT NULL
+ instance_runners_enabled boolean DEFAULT false NOT NULL,
+ namespace_id bigint,
+ minutes_exceeded boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE ci_pending_builds_id_seq
@@ -11209,9 +11277,9 @@ CREATE TABLE ci_sources_pipelines (
project_id integer,
pipeline_id integer,
source_project_id integer,
- source_job_id integer,
+ source_job_id_convert_to_bigint integer,
source_pipeline_id integer,
- source_job_id_convert_to_bigint bigint
+ source_job_id bigint
);
CREATE SEQUENCE ci_sources_pipelines_id_seq
@@ -11239,7 +11307,7 @@ CREATE SEQUENCE ci_sources_projects_id_seq
ALTER SEQUENCE ci_sources_projects_id_seq OWNED BY ci_sources_projects.id;
CREATE TABLE ci_stages (
- id integer NOT NULL,
+ id_convert_to_bigint integer DEFAULT 0 NOT NULL,
project_id integer,
pipeline_id integer,
created_at timestamp without time zone,
@@ -11248,7 +11316,7 @@ CREATE TABLE ci_stages (
status integer,
lock_version integer DEFAULT 0,
"position" integer,
- id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
+ id bigint NOT NULL,
CONSTRAINT check_81b431e49b CHECK ((lock_version IS NOT NULL))
);
@@ -11276,38 +11344,6 @@ CREATE SEQUENCE ci_subscriptions_projects_id_seq
ALTER SEQUENCE ci_subscriptions_projects_id_seq OWNED BY ci_subscriptions_projects.id;
-CREATE TABLE ci_test_case_failures (
- id bigint NOT NULL,
- failed_at timestamp with time zone,
- test_case_id bigint NOT NULL,
- build_id bigint NOT NULL
-);
-
-CREATE SEQUENCE ci_test_case_failures_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE ci_test_case_failures_id_seq OWNED BY ci_test_case_failures.id;
-
-CREATE TABLE ci_test_cases (
- id bigint NOT NULL,
- project_id bigint NOT NULL,
- key_hash text NOT NULL,
- CONSTRAINT check_dd3c5d1c15 CHECK ((char_length(key_hash) <= 64))
-);
-
-CREATE SEQUENCE ci_test_cases_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE ci_test_cases_id_seq OWNED BY ci_test_cases.id;
-
CREATE TABLE ci_trigger_requests (
id integer NOT NULL,
trigger_id integer NOT NULL,
@@ -12005,6 +12041,52 @@ CREATE SEQUENCE custom_emoji_id_seq
ALTER SEQUENCE custom_emoji_id_seq OWNED BY custom_emoji.id;
+CREATE TABLE customer_relations_organizations (
+ id bigint NOT NULL,
+ group_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ state smallint DEFAULT 1 NOT NULL,
+ default_rate numeric(18,2),
+ name text NOT NULL,
+ description text,
+ CONSTRAINT check_2ba9ef1c4c CHECK ((char_length(name) <= 255)),
+ CONSTRAINT check_e476b6058e CHECK ((char_length(description) <= 1024))
+);
+
+CREATE SEQUENCE customer_relations_organizations_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE customer_relations_organizations_id_seq OWNED BY customer_relations_organizations.id;
+
+CREATE TABLE dast_profile_schedules (
+ id bigint NOT NULL,
+ project_id bigint NOT NULL,
+ dast_profile_id bigint NOT NULL,
+ user_id bigint,
+ next_run_at timestamp with time zone NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ active boolean DEFAULT true NOT NULL,
+ cron text NOT NULL,
+ CONSTRAINT check_86531ea73f CHECK ((char_length(cron) <= 255))
+);
+
+COMMENT ON TABLE dast_profile_schedules IS '{"owner":"group::dynamic analysis","description":"Scheduling for scans using DAST Profiles"}';
+
+CREATE SEQUENCE dast_profile_schedules_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE dast_profile_schedules_id_seq OWNED BY dast_profile_schedules.id;
+
CREATE TABLE dast_profiles (
id bigint NOT NULL,
project_id bigint NOT NULL,
@@ -12204,6 +12286,33 @@ CREATE SEQUENCE dast_sites_id_seq
ALTER SEQUENCE dast_sites_id_seq OWNED BY dast_sites.id;
+CREATE TABLE dep_ci_build_trace_section_names (
+ id integer NOT NULL,
+ project_id integer NOT NULL,
+ name character varying NOT NULL
+);
+
+CREATE SEQUENCE dep_ci_build_trace_section_names_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE dep_ci_build_trace_section_names_id_seq OWNED BY dep_ci_build_trace_section_names.id;
+
+CREATE TABLE dep_ci_build_trace_sections (
+ project_id integer NOT NULL,
+ date_start timestamp without time zone NOT NULL,
+ date_end timestamp without time zone NOT NULL,
+ byte_start bigint NOT NULL,
+ byte_end bigint NOT NULL,
+ build_id integer NOT NULL,
+ section_name_id integer NOT NULL,
+ build_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+);
+
CREATE TABLE dependency_proxy_blobs (
id integer NOT NULL,
group_id integer NOT NULL,
@@ -12332,7 +12441,7 @@ CREATE TABLE deployments (
tag boolean NOT NULL,
sha character varying NOT NULL,
user_id integer,
- deployable_id integer,
+ deployable_id_convert_to_bigint integer,
deployable_type character varying,
created_at timestamp without time zone,
updated_at timestamp without time zone,
@@ -12340,7 +12449,7 @@ CREATE TABLE deployments (
status smallint NOT NULL,
finished_at timestamp with time zone,
cluster_id integer,
- deployable_id_convert_to_bigint bigint
+ deployable_id bigint
);
CREATE SEQUENCE deployments_id_seq
@@ -12444,6 +12553,24 @@ CREATE SEQUENCE design_user_mentions_id_seq
ALTER SEQUENCE design_user_mentions_id_seq OWNED BY design_user_mentions.id;
+CREATE TABLE detached_partitions (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ drop_after timestamp with time zone NOT NULL,
+ table_name text NOT NULL,
+ CONSTRAINT check_aecee24ba3 CHECK ((char_length(table_name) <= 63))
+);
+
+CREATE SEQUENCE detached_partitions_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE detached_partitions_id_seq OWNED BY detached_partitions.id;
+
CREATE TABLE diff_note_positions (
id bigint NOT NULL,
note_id bigint NOT NULL,
@@ -12579,21 +12706,13 @@ CREATE TABLE elastic_reindexing_tasks (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
- documents_count integer,
state smallint DEFAULT 0 NOT NULL,
in_progress boolean DEFAULT true NOT NULL,
- index_name_from text,
- index_name_to text,
- elastic_task text,
error_message text,
- documents_count_target integer,
delete_original_index_at timestamp with time zone,
max_slices_running smallint DEFAULT 60 NOT NULL,
slice_multiplier smallint DEFAULT 2 NOT NULL,
- CONSTRAINT check_04151aca42 CHECK ((char_length(index_name_from) <= 255)),
- CONSTRAINT check_7f64acda8e CHECK ((char_length(error_message) <= 255)),
- CONSTRAINT check_85ebff7124 CHECK ((char_length(index_name_to) <= 255)),
- CONSTRAINT check_942e5aae53 CHECK ((char_length(elastic_task) <= 255))
+ CONSTRAINT check_7f64acda8e CHECK ((char_length(error_message) <= 255))
);
CREATE SEQUENCE elastic_reindexing_tasks_id_seq
@@ -12757,6 +12876,25 @@ CREATE SEQUENCE epics_id_seq
ALTER SEQUENCE epics_id_seq OWNED BY epics.id;
+CREATE TABLE error_tracking_client_keys (
+ id bigint NOT NULL,
+ project_id bigint NOT NULL,
+ active boolean DEFAULT true NOT NULL,
+ public_key text NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ CONSTRAINT check_840b719790 CHECK ((char_length(public_key) <= 255))
+);
+
+CREATE SEQUENCE error_tracking_client_keys_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE error_tracking_client_keys_id_seq OWNED BY error_tracking_client_keys.id;
+
CREATE TABLE error_tracking_error_events (
id bigint NOT NULL,
error_id bigint NOT NULL,
@@ -12793,6 +12931,7 @@ CREATE TABLE error_tracking_errors (
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
events_count bigint DEFAULT 0 NOT NULL,
+ status smallint DEFAULT 0 NOT NULL,
CONSTRAINT check_18a758e537 CHECK ((char_length(name) <= 255)),
CONSTRAINT check_b5cb4d3888 CHECK ((char_length(actor) <= 255)),
CONSTRAINT check_c739788b12 CHECK ((char_length(description) <= 1024)),
@@ -13181,9 +13320,9 @@ ALTER SEQUENCE geo_hashed_storage_migrated_events_id_seq OWNED BY geo_hashed_sto
CREATE TABLE geo_job_artifact_deleted_events (
id bigint NOT NULL,
- job_artifact_id integer NOT NULL,
+ job_artifact_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
file_path character varying NOT NULL,
- job_artifact_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+ job_artifact_id bigint NOT NULL
);
CREATE SEQUENCE geo_job_artifact_deleted_events_id_seq
@@ -13872,9 +14011,12 @@ ALTER SEQUENCE incident_management_escalation_policies_id_seq OWNED BY incident_
CREATE TABLE incident_management_escalation_rules (
id bigint NOT NULL,
policy_id bigint NOT NULL,
- oncall_schedule_id bigint NOT NULL,
+ oncall_schedule_id bigint,
status smallint NOT NULL,
- elapsed_time_seconds integer NOT NULL
+ elapsed_time_seconds integer NOT NULL,
+ is_removed boolean DEFAULT false NOT NULL,
+ user_id bigint,
+ CONSTRAINT escalation_rules_one_of_oncall_schedule_or_user CHECK ((num_nonnulls(oncall_schedule_id, user_id) = 1))
);
CREATE SEQUENCE incident_management_escalation_rules_id_seq
@@ -13886,6 +14028,26 @@ CREATE SEQUENCE incident_management_escalation_rules_id_seq
ALTER SEQUENCE incident_management_escalation_rules_id_seq OWNED BY incident_management_escalation_rules.id;
+CREATE TABLE incident_management_issuable_escalation_statuses (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ issue_id bigint NOT NULL,
+ policy_id bigint,
+ escalations_started_at timestamp with time zone,
+ resolved_at timestamp with time zone,
+ status smallint DEFAULT 0 NOT NULL
+);
+
+CREATE SEQUENCE incident_management_issuable_escalation_statuses_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE incident_management_issuable_escalation_statuses_id_seq OWNED BY incident_management_issuable_escalation_statuses.id;
+
CREATE TABLE incident_management_oncall_participants (
id bigint NOT NULL,
oncall_rotation_id bigint NOT NULL,
@@ -14040,7 +14202,9 @@ CREATE TABLE integrations (
comment_detail smallint,
inherit_from_id bigint,
alert_events boolean,
- group_id bigint
+ group_id bigint,
+ type_new text,
+ CONSTRAINT check_a948a0aa7e CHECK ((char_length(type_new) <= 255))
);
CREATE SEQUENCE integrations_id_seq
@@ -14123,7 +14287,9 @@ ALTER SEQUENCE issuable_severities_id_seq OWNED BY issuable_severities.id;
CREATE TABLE issuable_slas (
id bigint NOT NULL,
issue_id bigint NOT NULL,
- due_at timestamp with time zone NOT NULL
+ due_at timestamp with time zone NOT NULL,
+ label_applied boolean DEFAULT false NOT NULL,
+ issuable_closed boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE issuable_slas_id_seq
@@ -14271,6 +14437,7 @@ CREATE TABLE issues (
issue_type smallint DEFAULT 0 NOT NULL,
blocking_issues_count integer DEFAULT 0 NOT NULL,
upvotes_count integer DEFAULT 0 NOT NULL,
+ work_item_type_id bigint,
CONSTRAINT check_fba63f706d CHECK ((lock_version IS NOT NULL))
);
@@ -15821,17 +15988,16 @@ CREATE TABLE packages_debian_group_distributions (
label text,
version text,
description text,
- encrypted_signing_keys text,
- encrypted_signing_keys_iv text,
file text,
file_signature text,
+ signed_file text,
+ signed_file_store smallint DEFAULT 1 NOT NULL,
+ CONSTRAINT check_0007e0bf61 CHECK ((char_length(signed_file) <= 255)),
CONSTRAINT check_310ac457b8 CHECK ((char_length(description) <= 255)),
CONSTRAINT check_3d6f87fc31 CHECK ((char_length(file_signature) <= 4096)),
CONSTRAINT check_3fdadf4a0c CHECK ((char_length(version) <= 255)),
CONSTRAINT check_590e18405a CHECK ((char_length(codename) <= 255)),
- CONSTRAINT check_9b90bc0f07 CHECK ((char_length(encrypted_signing_keys_iv) <= 255)),
CONSTRAINT check_b057cd840a CHECK ((char_length(origin) <= 255)),
- CONSTRAINT check_b811ec1218 CHECK ((char_length(encrypted_signing_keys) <= 2048)),
CONSTRAINT check_be5ed8d307 CHECK ((char_length(file) <= 255)),
CONSTRAINT check_d3244bfc0b CHECK ((char_length(label) <= 255)),
CONSTRAINT check_e7c928a24b CHECK ((char_length(suite) <= 255))
@@ -15947,20 +16113,19 @@ CREATE TABLE packages_debian_project_distributions (
label text,
version text,
description text,
- encrypted_signing_keys text,
- encrypted_signing_keys_iv text,
file text,
file_signature text,
+ signed_file text,
+ signed_file_store smallint DEFAULT 1 NOT NULL,
CONSTRAINT check_6177ccd4a6 CHECK ((char_length(origin) <= 255)),
CONSTRAINT check_6f6b55a4c4 CHECK ((char_length(label) <= 255)),
CONSTRAINT check_834dabadb6 CHECK ((char_length(codename) <= 255)),
CONSTRAINT check_96965792c2 CHECK ((char_length(version) <= 255)),
+ CONSTRAINT check_9e5e22b7ff CHECK ((char_length(signed_file) <= 255)),
CONSTRAINT check_a56ae58a17 CHECK ((char_length(suite) <= 255)),
CONSTRAINT check_a5a2ac6af2 CHECK ((char_length(file_signature) <= 4096)),
CONSTRAINT check_b93154339f CHECK ((char_length(description) <= 255)),
- CONSTRAINT check_c25603a25b CHECK ((char_length(encrypted_signing_keys) <= 2048)),
- CONSTRAINT check_cb4ac9599e CHECK ((char_length(file) <= 255)),
- CONSTRAINT check_d488f8cce3 CHECK ((char_length(encrypted_signing_keys_iv) <= 255))
+ CONSTRAINT check_cb4ac9599e CHECK ((char_length(file) <= 255))
);
CREATE SEQUENCE packages_debian_project_distributions_id_seq
@@ -16430,7 +16595,8 @@ CREATE TABLE plan_limits (
ci_daily_pipeline_schedule_triggers integer DEFAULT 0 NOT NULL,
ci_max_artifact_size_running_container_scanning integer DEFAULT 0 NOT NULL,
ci_max_artifact_size_cluster_image_scanning integer DEFAULT 0 NOT NULL,
- ci_jobs_trace_size_limit integer DEFAULT 100 NOT NULL
+ ci_jobs_trace_size_limit integer DEFAULT 100 NOT NULL,
+ pages_file_entries integer DEFAULT 200000 NOT NULL
);
CREATE SEQUENCE plan_limits_id_seq
@@ -16476,6 +16642,39 @@ CREATE SEQUENCE pool_repositories_id_seq
ALTER SEQUENCE pool_repositories_id_seq OWNED BY pool_repositories.id;
+CREATE TABLE postgres_async_indexes (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ name text NOT NULL,
+ definition text NOT NULL,
+ table_name text NOT NULL,
+ CONSTRAINT check_083b21157b CHECK ((char_length(definition) <= 2048)),
+ CONSTRAINT check_b732c6cd1d CHECK ((char_length(name) <= 63)),
+ CONSTRAINT check_e64ff4359e CHECK ((char_length(table_name) <= 63))
+);
+
+CREATE SEQUENCE postgres_async_indexes_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE postgres_async_indexes_id_seq OWNED BY postgres_async_indexes.id;
+
+CREATE VIEW postgres_foreign_keys AS
+ SELECT pg_constraint.oid,
+ pg_constraint.conname AS name,
+ (((constrained_namespace.nspname)::text || '.'::text) || (constrained_table.relname)::text) AS constrained_table_identifier,
+ (((referenced_namespace.nspname)::text || '.'::text) || (referenced_table.relname)::text) AS referenced_table_identifier
+ FROM ((((pg_constraint
+ JOIN pg_class constrained_table ON ((constrained_table.oid = pg_constraint.conrelid)))
+ JOIN pg_class referenced_table ON ((referenced_table.oid = pg_constraint.confrelid)))
+ JOIN pg_namespace constrained_namespace ON ((constrained_table.relnamespace = constrained_namespace.oid)))
+ JOIN pg_namespace referenced_namespace ON ((referenced_table.relnamespace = referenced_namespace.oid)))
+ WHERE (pg_constraint.contype = 'f'::"char");
+
CREATE VIEW postgres_index_bloat_estimates AS
SELECT (((relation_stats.nspname)::text || '.'::text) || (relation_stats.idxname)::text) AS identifier,
(
@@ -16764,6 +16963,22 @@ CREATE SEQUENCE project_ci_cd_settings_id_seq
ALTER SEQUENCE project_ci_cd_settings_id_seq OWNED BY project_ci_cd_settings.id;
+CREATE TABLE project_ci_feature_usages (
+ id bigint NOT NULL,
+ project_id bigint NOT NULL,
+ feature smallint NOT NULL,
+ default_branch boolean DEFAULT false NOT NULL
+);
+
+CREATE SEQUENCE project_ci_feature_usages_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE project_ci_feature_usages_id_seq OWNED BY project_ci_feature_usages.id;
+
CREATE TABLE project_compliance_framework_settings (
project_id bigint NOT NULL,
framework_id bigint,
@@ -16836,7 +17051,8 @@ CREATE TABLE project_error_tracking_settings (
encrypted_token character varying,
encrypted_token_iv character varying,
project_name character varying,
- organization_name character varying
+ organization_name character varying,
+ integrated boolean DEFAULT false NOT NULL
);
CREATE TABLE project_export_jobs (
@@ -17446,7 +17662,7 @@ ALTER SEQUENCE protected_tags_id_seq OWNED BY protected_tags.id;
CREATE TABLE push_event_payloads (
commit_count bigint NOT NULL,
- event_id integer NOT NULL,
+ event_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
action smallint NOT NULL,
ref_type smallint NOT NULL,
commit_from bytea,
@@ -17454,7 +17670,7 @@ CREATE TABLE push_event_payloads (
ref text,
commit_title character varying(70),
ref_count integer,
- event_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+ event_id bigint NOT NULL
);
CREATE TABLE push_rules (
@@ -17895,10 +18111,11 @@ CREATE TABLE security_findings (
scanner_id bigint NOT NULL,
severity smallint NOT NULL,
confidence smallint NOT NULL,
- project_fingerprint text NOT NULL,
+ project_fingerprint text,
deduplicated boolean DEFAULT false NOT NULL,
"position" integer,
uuid uuid,
+ overridden_uuid uuid,
CONSTRAINT check_b9508c6df8 CHECK ((char_length(project_fingerprint) <= 40))
);
@@ -17940,6 +18157,7 @@ CREATE TABLE security_orchestration_policy_rule_schedules (
user_id bigint NOT NULL,
policy_index integer NOT NULL,
cron text NOT NULL,
+ rule_index integer DEFAULT 0 NOT NULL,
CONSTRAINT check_915825a76e CHECK ((char_length(cron) <= 255))
);
@@ -17960,7 +18178,9 @@ CREATE TABLE security_scans (
updated_at timestamp with time zone NOT NULL,
build_id bigint NOT NULL,
scan_type smallint NOT NULL,
- info jsonb DEFAULT '{}'::jsonb NOT NULL
+ info jsonb DEFAULT '{}'::jsonb NOT NULL,
+ project_id bigint,
+ pipeline_id bigint
);
CREATE SEQUENCE security_scans_id_seq
@@ -18732,9 +18952,11 @@ CREATE TABLE user_details (
other_role text,
provisioned_by_group_id bigint,
pronouns text,
+ pronunciation text,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)),
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100)),
- CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50))
+ CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50)),
+ CONSTRAINT check_f932ed37db CHECK ((char_length(pronunciation) <= 255))
);
CREATE SEQUENCE user_details_user_id_seq
@@ -19181,10 +19403,11 @@ CREATE TABLE vulnerability_finding_evidence_requests (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
- vulnerability_finding_evidence_id bigint NOT NULL,
+ vulnerability_finding_evidence_id bigint,
method text,
url text,
body text,
+ vulnerability_finding_evidence_supporting_message_id bigint,
CONSTRAINT check_7e37f2d01a CHECK ((char_length(body) <= 2048)),
CONSTRAINT check_8152fbb236 CHECK ((char_length(url) <= 2048)),
CONSTRAINT check_d9d11300f4 CHECK ((char_length(method) <= 32))
@@ -19203,10 +19426,11 @@ CREATE TABLE vulnerability_finding_evidence_responses (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
- vulnerability_finding_evidence_id bigint NOT NULL,
+ vulnerability_finding_evidence_id bigint,
status_code integer,
reason_phrase text,
body text,
+ vulnerability_finding_evidence_supporting_message_id bigint,
CONSTRAINT check_58b124ab48 CHECK ((char_length(reason_phrase) <= 2048)),
CONSTRAINT check_76bac0c32b CHECK ((char_length(body) <= 2048))
);
@@ -19686,6 +19910,30 @@ CREATE SEQUENCE wiki_page_slugs_id_seq
ALTER SEQUENCE wiki_page_slugs_id_seq OWNED BY wiki_page_slugs.id;
+CREATE TABLE work_item_types (
+ id bigint NOT NULL,
+ base_type smallint DEFAULT 0 NOT NULL,
+ cached_markdown_version integer,
+ name text NOT NULL,
+ description text,
+ description_html text,
+ icon_name text,
+ namespace_id bigint,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ CONSTRAINT check_104d2410f6 CHECK ((char_length(name) <= 255)),
+ CONSTRAINT check_fecb3a98d1 CHECK ((char_length(icon_name) <= 255))
+);
+
+CREATE SEQUENCE work_item_types_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE work_item_types_id_seq OWNED BY work_item_types.id;
+
CREATE TABLE x509_certificates (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -19744,6 +19992,30 @@ CREATE SEQUENCE x509_issuers_id_seq
ALTER SEQUENCE x509_issuers_id_seq OWNED BY x509_issuers.id;
+CREATE TABLE zentao_tracker_data (
+ id bigint NOT NULL,
+ integration_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ encrypted_url bytea,
+ encrypted_url_iv bytea,
+ encrypted_api_url bytea,
+ encrypted_api_url_iv bytea,
+ encrypted_zentao_product_xid bytea,
+ encrypted_zentao_product_xid_iv bytea,
+ encrypted_api_token bytea,
+ encrypted_api_token_iv bytea
+);
+
+CREATE SEQUENCE zentao_tracker_data_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE zentao_tracker_data_id_seq OWNED BY zentao_tracker_data.id;
+
CREATE TABLE zoom_meetings (
id bigint NOT NULL,
project_id bigint NOT NULL,
@@ -19783,6 +20055,8 @@ ALTER TABLE ONLY analytics_cycle_analytics_project_stages ALTER COLUMN id SET DE
ALTER TABLE ONLY analytics_cycle_analytics_project_value_streams ALTER COLUMN id SET DEFAULT nextval('analytics_cycle_analytics_project_value_streams_id_seq'::regclass);
+ALTER TABLE ONLY analytics_cycle_analytics_stage_event_hashes ALTER COLUMN id SET DEFAULT nextval('analytics_cycle_analytics_stage_event_hashes_id_seq'::regclass);
+
ALTER TABLE ONLY analytics_devops_adoption_segments ALTER COLUMN id SET DEFAULT nextval('analytics_devops_adoption_segments_id_seq'::regclass);
ALTER TABLE ONLY analytics_devops_adoption_snapshots ALTER COLUMN id SET DEFAULT nextval('analytics_devops_adoption_snapshots_id_seq'::regclass);
@@ -19887,8 +20161,6 @@ ALTER TABLE ONLY ci_build_report_results ALTER COLUMN build_id SET DEFAULT nextv
ALTER TABLE ONLY ci_build_trace_chunks ALTER COLUMN id SET DEFAULT nextval('ci_build_trace_chunks_id_seq'::regclass);
-ALTER TABLE ONLY ci_build_trace_section_names ALTER COLUMN id SET DEFAULT nextval('ci_build_trace_section_names_id_seq'::regclass);
-
ALTER TABLE ONLY ci_builds ALTER COLUMN id SET DEFAULT nextval('ci_builds_id_seq'::regclass);
ALTER TABLE ONLY ci_builds_metadata ALTER COLUMN id SET DEFAULT nextval('ci_builds_metadata_id_seq'::regclass);
@@ -19959,10 +20231,6 @@ ALTER TABLE ONLY ci_stages ALTER COLUMN id SET DEFAULT nextval('ci_stages_id_seq
ALTER TABLE ONLY ci_subscriptions_projects ALTER COLUMN id SET DEFAULT nextval('ci_subscriptions_projects_id_seq'::regclass);
-ALTER TABLE ONLY ci_test_case_failures ALTER COLUMN id SET DEFAULT nextval('ci_test_case_failures_id_seq'::regclass);
-
-ALTER TABLE ONLY ci_test_cases ALTER COLUMN id SET DEFAULT nextval('ci_test_cases_id_seq'::regclass);
-
ALTER TABLE ONLY ci_trigger_requests ALTER COLUMN id SET DEFAULT nextval('ci_trigger_requests_id_seq'::regclass);
ALTER TABLE ONLY ci_triggers ALTER COLUMN id SET DEFAULT nextval('ci_triggers_id_seq'::regclass);
@@ -20023,6 +20291,10 @@ ALTER TABLE ONLY csv_issue_imports ALTER COLUMN id SET DEFAULT nextval('csv_issu
ALTER TABLE ONLY custom_emoji ALTER COLUMN id SET DEFAULT nextval('custom_emoji_id_seq'::regclass);
+ALTER TABLE ONLY customer_relations_organizations ALTER COLUMN id SET DEFAULT nextval('customer_relations_organizations_id_seq'::regclass);
+
+ALTER TABLE ONLY dast_profile_schedules ALTER COLUMN id SET DEFAULT nextval('dast_profile_schedules_id_seq'::regclass);
+
ALTER TABLE ONLY dast_profiles ALTER COLUMN id SET DEFAULT nextval('dast_profiles_id_seq'::regclass);
ALTER TABLE ONLY dast_scanner_profiles ALTER COLUMN id SET DEFAULT nextval('dast_scanner_profiles_id_seq'::regclass);
@@ -20037,6 +20309,8 @@ ALTER TABLE ONLY dast_site_validations ALTER COLUMN id SET DEFAULT nextval('dast
ALTER TABLE ONLY dast_sites ALTER COLUMN id SET DEFAULT nextval('dast_sites_id_seq'::regclass);
+ALTER TABLE ONLY dep_ci_build_trace_section_names ALTER COLUMN id SET DEFAULT nextval('dep_ci_build_trace_section_names_id_seq'::regclass);
+
ALTER TABLE ONLY dependency_proxy_blobs ALTER COLUMN id SET DEFAULT nextval('dependency_proxy_blobs_id_seq'::regclass);
ALTER TABLE ONLY dependency_proxy_group_settings ALTER COLUMN id SET DEFAULT nextval('dependency_proxy_group_settings_id_seq'::regclass);
@@ -20059,6 +20333,8 @@ ALTER TABLE ONLY design_management_versions ALTER COLUMN id SET DEFAULT nextval(
ALTER TABLE ONLY design_user_mentions ALTER COLUMN id SET DEFAULT nextval('design_user_mentions_id_seq'::regclass);
+ALTER TABLE ONLY detached_partitions ALTER COLUMN id SET DEFAULT nextval('detached_partitions_id_seq'::regclass);
+
ALTER TABLE ONLY diff_note_positions ALTER COLUMN id SET DEFAULT nextval('diff_note_positions_id_seq'::regclass);
ALTER TABLE ONLY dora_daily_metrics ALTER COLUMN id SET DEFAULT nextval('dora_daily_metrics_id_seq'::regclass);
@@ -20085,6 +20361,8 @@ ALTER TABLE ONLY epic_user_mentions ALTER COLUMN id SET DEFAULT nextval('epic_us
ALTER TABLE ONLY epics ALTER COLUMN id SET DEFAULT nextval('epics_id_seq'::regclass);
+ALTER TABLE ONLY error_tracking_client_keys ALTER COLUMN id SET DEFAULT nextval('error_tracking_client_keys_id_seq'::regclass);
+
ALTER TABLE ONLY error_tracking_error_events ALTER COLUMN id SET DEFAULT nextval('error_tracking_error_events_id_seq'::regclass);
ALTER TABLE ONLY error_tracking_errors ALTER COLUMN id SET DEFAULT nextval('error_tracking_errors_id_seq'::regclass);
@@ -20193,6 +20471,8 @@ ALTER TABLE ONLY incident_management_escalation_policies ALTER COLUMN id SET DEF
ALTER TABLE ONLY incident_management_escalation_rules ALTER COLUMN id SET DEFAULT nextval('incident_management_escalation_rules_id_seq'::regclass);
+ALTER TABLE ONLY incident_management_issuable_escalation_statuses ALTER COLUMN id SET DEFAULT nextval('incident_management_issuable_escalation_statuses_id_seq'::regclass);
+
ALTER TABLE ONLY incident_management_oncall_participants ALTER COLUMN id SET DEFAULT nextval('incident_management_oncall_participants_id_seq'::regclass);
ALTER TABLE ONLY incident_management_oncall_rotations ALTER COLUMN id SET DEFAULT nextval('incident_management_oncall_rotations_id_seq'::regclass);
@@ -20401,6 +20681,8 @@ ALTER TABLE ONLY plans ALTER COLUMN id SET DEFAULT nextval('plans_id_seq'::regcl
ALTER TABLE ONLY pool_repositories ALTER COLUMN id SET DEFAULT nextval('pool_repositories_id_seq'::regclass);
+ALTER TABLE ONLY postgres_async_indexes ALTER COLUMN id SET DEFAULT nextval('postgres_async_indexes_id_seq'::regclass);
+
ALTER TABLE ONLY postgres_reindex_actions ALTER COLUMN id SET DEFAULT nextval('postgres_reindex_actions_id_seq'::regclass);
ALTER TABLE ONLY product_analytics_events_experimental ALTER COLUMN id SET DEFAULT nextval('product_analytics_events_experimental_id_seq'::regclass);
@@ -20413,6 +20695,8 @@ ALTER TABLE ONLY project_auto_devops ALTER COLUMN id SET DEFAULT nextval('projec
ALTER TABLE ONLY project_ci_cd_settings ALTER COLUMN id SET DEFAULT nextval('project_ci_cd_settings_id_seq'::regclass);
+ALTER TABLE ONLY project_ci_feature_usages ALTER COLUMN id SET DEFAULT nextval('project_ci_feature_usages_id_seq'::regclass);
+
ALTER TABLE ONLY project_compliance_framework_settings ALTER COLUMN project_id SET DEFAULT nextval('project_compliance_framework_settings_project_id_seq'::regclass);
ALTER TABLE ONLY project_custom_attributes ALTER COLUMN id SET DEFAULT nextval('project_custom_attributes_id_seq'::regclass);
@@ -20665,12 +20949,16 @@ ALTER TABLE ONLY wiki_page_meta ALTER COLUMN id SET DEFAULT nextval('wiki_page_m
ALTER TABLE ONLY wiki_page_slugs ALTER COLUMN id SET DEFAULT nextval('wiki_page_slugs_id_seq'::regclass);
+ALTER TABLE ONLY work_item_types ALTER COLUMN id SET DEFAULT nextval('work_item_types_id_seq'::regclass);
+
ALTER TABLE ONLY x509_certificates ALTER COLUMN id SET DEFAULT nextval('x509_certificates_id_seq'::regclass);
ALTER TABLE ONLY x509_commit_signatures ALTER COLUMN id SET DEFAULT nextval('x509_commit_signatures_id_seq'::regclass);
ALTER TABLE ONLY x509_issuers ALTER COLUMN id SET DEFAULT nextval('x509_issuers_id_seq'::regclass);
+ALTER TABLE ONLY zentao_tracker_data ALTER COLUMN id SET DEFAULT nextval('zentao_tracker_data_id_seq'::regclass);
+
ALTER TABLE ONLY zoom_meetings ALTER COLUMN id SET DEFAULT nextval('zoom_meetings_id_seq'::regclass);
ALTER TABLE ONLY product_analytics_events_experimental
@@ -20898,6 +21186,9 @@ ALTER TABLE ONLY analytics_cycle_analytics_project_stages
ALTER TABLE ONLY analytics_cycle_analytics_project_value_streams
ADD CONSTRAINT analytics_cycle_analytics_project_value_streams_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY analytics_cycle_analytics_stage_event_hashes
+ ADD CONSTRAINT analytics_cycle_analytics_stage_event_hashes_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY analytics_devops_adoption_segments
ADD CONSTRAINT analytics_devops_adoption_segments_pkey PRIMARY KEY (id);
@@ -20979,6 +21270,9 @@ ALTER TABLE ONLY background_migration_jobs
ALTER TABLE ONLY badges
ADD CONSTRAINT badges_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY banned_users
+ ADD CONSTRAINT banned_users_pkey PRIMARY KEY (user_id);
+
ALTER TABLE ONLY batched_background_migration_jobs
ADD CONSTRAINT batched_background_migration_jobs_pkey PRIMARY KEY (id);
@@ -21078,10 +21372,10 @@ ALTER TABLE ONLY ci_build_report_results
ALTER TABLE ONLY ci_build_trace_chunks
ADD CONSTRAINT ci_build_trace_chunks_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY ci_build_trace_section_names
- ADD CONSTRAINT ci_build_trace_section_names_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY ci_build_trace_metadata
+ ADD CONSTRAINT ci_build_trace_metadata_pkey PRIMARY KEY (build_id);
-ALTER TABLE ONLY ci_build_trace_sections
+ALTER TABLE ONLY dep_ci_build_trace_sections
ADD CONSTRAINT ci_build_trace_sections_pkey PRIMARY KEY (build_id, section_name_id);
ALTER TABLE ONLY ci_builds_metadata
@@ -21189,12 +21483,6 @@ ALTER TABLE ONLY ci_stages
ALTER TABLE ONLY ci_subscriptions_projects
ADD CONSTRAINT ci_subscriptions_projects_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY ci_test_case_failures
- ADD CONSTRAINT ci_test_case_failures_pkey PRIMARY KEY (id);
-
-ALTER TABLE ONLY ci_test_cases
- ADD CONSTRAINT ci_test_cases_pkey PRIMARY KEY (id);
-
ALTER TABLE ONLY ci_trigger_requests
ADD CONSTRAINT ci_trigger_requests_pkey PRIMARY KEY (id);
@@ -21294,6 +21582,12 @@ ALTER TABLE ONLY csv_issue_imports
ALTER TABLE ONLY custom_emoji
ADD CONSTRAINT custom_emoji_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY customer_relations_organizations
+ ADD CONSTRAINT customer_relations_organizations_pkey PRIMARY KEY (id);
+
+ALTER TABLE ONLY dast_profile_schedules
+ ADD CONSTRAINT dast_profile_schedules_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY dast_profiles_pipelines
ADD CONSTRAINT dast_profiles_pipelines_pkey PRIMARY KEY (dast_profile_id, ci_pipeline_id);
@@ -21327,6 +21621,9 @@ ALTER TABLE ONLY dast_site_validations
ALTER TABLE ONLY dast_sites
ADD CONSTRAINT dast_sites_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY dep_ci_build_trace_section_names
+ ADD CONSTRAINT dep_ci_build_trace_section_names_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY dependency_proxy_blobs
ADD CONSTRAINT dependency_proxy_blobs_pkey PRIMARY KEY (id);
@@ -21366,6 +21663,9 @@ ALTER TABLE ONLY design_management_versions
ALTER TABLE ONLY design_user_mentions
ADD CONSTRAINT design_user_mentions_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY detached_partitions
+ ADD CONSTRAINT detached_partitions_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY diff_note_positions
ADD CONSTRAINT diff_note_positions_pkey PRIMARY KEY (id);
@@ -21411,6 +21711,9 @@ ALTER TABLE ONLY epic_user_mentions
ALTER TABLE ONLY epics
ADD CONSTRAINT epics_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY error_tracking_client_keys
+ ADD CONSTRAINT error_tracking_client_keys_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY error_tracking_error_events
ADD CONSTRAINT error_tracking_error_events_pkey PRIMARY KEY (id);
@@ -21585,6 +21888,9 @@ ALTER TABLE ONLY incident_management_escalation_policies
ALTER TABLE ONLY incident_management_escalation_rules
ADD CONSTRAINT incident_management_escalation_rules_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY incident_management_issuable_escalation_statuses
+ ADD CONSTRAINT incident_management_issuable_escalation_statuses_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY incident_management_oncall_participants
ADD CONSTRAINT incident_management_oncall_participants_pkey PRIMARY KEY (id);
@@ -21960,6 +22266,9 @@ ALTER TABLE ONLY plans
ALTER TABLE ONLY pool_repositories
ADD CONSTRAINT pool_repositories_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY postgres_async_indexes
+ ADD CONSTRAINT postgres_async_indexes_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY postgres_reindex_actions
ADD CONSTRAINT postgres_reindex_actions_pkey PRIMARY KEY (id);
@@ -21984,6 +22293,9 @@ ALTER TABLE ONLY project_auto_devops
ALTER TABLE ONLY project_ci_cd_settings
ADD CONSTRAINT project_ci_cd_settings_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY project_ci_feature_usages
+ ADD CONSTRAINT project_ci_feature_usages_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY project_compliance_framework_settings
ADD CONSTRAINT project_compliance_framework_settings_pkey PRIMARY KEY (project_id);
@@ -22413,6 +22725,9 @@ ALTER TABLE ONLY wiki_page_meta
ALTER TABLE ONLY wiki_page_slugs
ADD CONSTRAINT wiki_page_slugs_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY work_item_types
+ ADD CONSTRAINT work_item_types_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY x509_certificates
ADD CONSTRAINT x509_certificates_pkey PRIMARY KEY (id);
@@ -22422,6 +22737,9 @@ ALTER TABLE ONLY x509_commit_signatures
ALTER TABLE ONLY x509_issuers
ADD CONSTRAINT x509_issuers_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY zentao_tracker_data
+ ADD CONSTRAINT zentao_tracker_data_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY zoom_meetings
ADD CONSTRAINT zoom_meetings_pkey PRIMARY KEY (id);
@@ -22577,7 +22895,7 @@ CREATE INDEX ci_builds_gitlab_monitor_metrics ON ci_builds USING btree (status,
CREATE INDEX code_owner_approval_required ON protected_branches USING btree (project_id, code_owner_approval_required) WHERE (code_owner_approval_required = true);
-CREATE INDEX commit_id_and_note_id_index ON commit_user_mentions USING btree (commit_id, note_id);
+CREATE UNIQUE INDEX commit_user_mentions_on_commit_id_and_note_id_unique_index ON commit_user_mentions USING btree (commit_id, note_id);
CREATE INDEX composer_cache_files_index_on_deleted_at ON packages_composer_cache_files USING btree (delete_at, id);
@@ -22587,7 +22905,7 @@ CREATE UNIQUE INDEX dast_site_profiles_builds_on_ci_build_id ON dast_site_profil
CREATE UNIQUE INDEX design_management_designs_versions_uniqueness ON design_management_designs_versions USING btree (design_id, version_id);
-CREATE INDEX design_user_mentions_on_design_id_and_note_id_index ON design_user_mentions USING btree (design_id, note_id);
+CREATE UNIQUE INDEX design_user_mentions_on_design_id_and_note_id_unique_index ON design_user_mentions USING btree (design_id, note_id);
CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_and_note_id_index ON epic_user_mentions USING btree (epic_id, note_id);
@@ -22601,8 +22919,12 @@ CREATE INDEX finding_evidence_header_on_finding_evidence_response_id ON vulnerab
CREATE INDEX finding_evidence_requests_on_finding_evidence_id ON vulnerability_finding_evidence_requests USING btree (vulnerability_finding_evidence_id);
+CREATE INDEX finding_evidence_requests_on_supporting_evidence_id ON vulnerability_finding_evidence_requests USING btree (vulnerability_finding_evidence_supporting_message_id);
+
CREATE INDEX finding_evidence_responses_on_finding_evidences_id ON vulnerability_finding_evidence_responses USING btree (vulnerability_finding_evidence_id);
+CREATE INDEX finding_evidence_responses_on_supporting_evidence_id ON vulnerability_finding_evidence_responses USING btree (vulnerability_finding_evidence_supporting_message_id);
+
CREATE INDEX finding_evidence_sources_on_finding_evidence_id ON vulnerability_finding_evidence_sources USING btree (vulnerability_finding_evidence_id);
CREATE INDEX finding_evidence_supporting_messages_on_finding_evidence_id ON vulnerability_finding_evidence_supporting_messages USING btree (vulnerability_finding_evidence_id);
@@ -23011,11 +23333,7 @@ CREATE INDEX index_ci_build_report_results_on_project_id ON ci_build_report_resu
CREATE UNIQUE INDEX index_ci_build_trace_chunks_on_build_id_and_chunk_index ON ci_build_trace_chunks USING btree (build_id, chunk_index);
-CREATE UNIQUE INDEX index_ci_build_trace_section_names_on_project_id_and_name ON ci_build_trace_section_names USING btree (project_id, name);
-
-CREATE INDEX index_ci_build_trace_sections_on_project_id ON ci_build_trace_sections USING btree (project_id);
-
-CREATE INDEX index_ci_build_trace_sections_on_section_name_id ON ci_build_trace_sections USING btree (section_name_id);
+CREATE INDEX index_ci_build_trace_metadata_on_trace_artifact_id ON ci_build_trace_metadata USING btree (trace_artifact_id);
CREATE UNIQUE INDEX index_ci_builds_metadata_on_build_id ON ci_builds_metadata USING btree (build_id);
@@ -23085,8 +23403,6 @@ CREATE UNIQUE INDEX index_ci_group_variables_on_group_id_and_key_and_environment
CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON ci_instance_variables USING btree (key);
-CREATE INDEX index_ci_job_artifacts_dast_for_devops_adoption ON ci_job_artifacts USING btree (project_id, created_at) WHERE (file_type = 8);
-
CREATE INDEX index_ci_job_artifacts_for_terraform_reports ON ci_job_artifacts USING btree (project_id, id) WHERE (file_type = 18);
CREATE INDEX index_ci_job_artifacts_id_for_terraform_reports ON ci_job_artifacts USING btree (id) WHERE (file_type = 18);
@@ -23103,8 +23419,6 @@ CREATE INDEX index_ci_job_artifacts_on_project_id ON ci_job_artifacts USING btre
CREATE INDEX index_ci_job_artifacts_on_project_id_for_security_reports ON ci_job_artifacts USING btree (project_id) WHERE (file_type = ANY (ARRAY[5, 6, 7, 8]));
-CREATE INDEX index_ci_job_artifacts_sast_for_devops_adoption ON ci_job_artifacts USING btree (project_id, created_at) WHERE (file_type = 5);
-
CREATE INDEX index_ci_job_token_project_scope_links_on_added_by_id ON ci_job_token_project_scope_links USING btree (added_by_id);
CREATE INDEX index_ci_job_token_project_scope_links_on_target_project_id ON ci_job_token_project_scope_links USING btree (target_project_id);
@@ -23121,6 +23435,8 @@ CREATE INDEX index_ci_pending_builds_id_on_protected_partial ON ci_pending_build
CREATE UNIQUE INDEX index_ci_pending_builds_on_build_id ON ci_pending_builds USING btree (build_id);
+CREATE INDEX index_ci_pending_builds_on_namespace_id ON ci_pending_builds USING btree (namespace_id);
+
CREATE INDEX index_ci_pending_builds_on_project_id ON ci_pending_builds USING btree (project_id);
CREATE INDEX index_ci_pipeline_artifacts_failed_verification ON ci_pipeline_artifacts USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
@@ -23269,10 +23585,6 @@ CREATE INDEX index_ci_subscriptions_projects_on_upstream_project_id ON ci_subscr
CREATE UNIQUE INDEX index_ci_subscriptions_projects_unique_subscription ON ci_subscriptions_projects USING btree (downstream_project_id, upstream_project_id);
-CREATE INDEX index_ci_test_case_failures_on_build_id ON ci_test_case_failures USING btree (build_id);
-
-CREATE UNIQUE INDEX index_ci_test_cases_on_project_id_and_key_hash ON ci_test_cases USING btree (project_id, key_hash);
-
CREATE INDEX index_ci_trigger_requests_on_commit_id ON ci_trigger_requests USING btree (commit_id);
CREATE INDEX index_ci_trigger_requests_on_trigger_id_and_id ON ci_trigger_requests USING btree (trigger_id, id DESC);
@@ -23383,8 +23695,20 @@ CREATE INDEX index_custom_emoji_on_creator_id ON custom_emoji USING btree (creat
CREATE UNIQUE INDEX index_custom_emoji_on_namespace_id_and_name ON custom_emoji USING btree (namespace_id, name);
+CREATE UNIQUE INDEX index_customer_relations_organizations_on_unique_name_per_group ON customer_relations_organizations USING btree (group_id, lower(name));
+
+CREATE UNIQUE INDEX index_cycle_analytics_stage_event_hashes_on_hash_sha_256 ON analytics_cycle_analytics_stage_event_hashes USING btree (hash_sha256);
+
CREATE UNIQUE INDEX index_daily_build_group_report_results_unique_columns ON ci_daily_build_group_report_results USING btree (project_id, ref_path, date, group_name);
+CREATE INDEX index_dast_profile_schedules_active_next_run_at ON dast_profile_schedules USING btree (active, next_run_at);
+
+CREATE INDEX index_dast_profile_schedules_on_dast_profile_id ON dast_profile_schedules USING btree (dast_profile_id);
+
+CREATE UNIQUE INDEX index_dast_profile_schedules_on_project_id_and_dast_profile_id ON dast_profile_schedules USING btree (project_id, dast_profile_id);
+
+CREATE INDEX index_dast_profile_schedules_on_user_id ON dast_profile_schedules USING btree (user_id);
+
CREATE INDEX index_dast_profiles_on_dast_scanner_profile_id ON dast_profiles USING btree (dast_scanner_profile_id);
CREATE INDEX index_dast_profiles_on_dast_site_profile_id ON dast_profiles USING btree (dast_site_profile_id);
@@ -23411,6 +23735,12 @@ CREATE INDEX index_dast_sites_on_dast_site_validation_id ON dast_sites USING btr
CREATE UNIQUE INDEX index_dast_sites_on_project_id_and_url ON dast_sites USING btree (project_id, url);
+CREATE UNIQUE INDEX index_dep_ci_build_trace_section_names_on_project_id_and_name ON dep_ci_build_trace_section_names USING btree (project_id, name);
+
+CREATE INDEX index_dep_ci_build_trace_sections_on_project_id ON dep_ci_build_trace_sections USING btree (project_id);
+
+CREATE INDEX index_dep_ci_build_trace_sections_on_section_name_id ON dep_ci_build_trace_sections USING btree (section_name_id);
+
CREATE INDEX index_dependency_proxy_blobs_on_group_id_and_file_name ON dependency_proxy_blobs USING btree (group_id, file_name);
CREATE INDEX index_dependency_proxy_group_settings_on_group_id ON dependency_proxy_group_settings USING btree (group_id);
@@ -23541,6 +23871,8 @@ CREATE INDEX index_environments_on_project_id_and_tier ON environments USING btr
CREATE INDEX index_environments_on_project_id_state_environment_type ON environments USING btree (project_id, state, environment_type);
+CREATE INDEX index_environments_on_state_and_auto_delete_at ON environments USING btree (auto_delete_at) WHERE ((auto_delete_at IS NOT NULL) AND ((state)::text = 'stopped'::text));
+
CREATE INDEX index_environments_on_state_and_auto_stop_at ON environments USING btree (state, auto_stop_at) WHERE ((auto_stop_at IS NOT NULL) AND ((state)::text = 'available'::text));
CREATE UNIQUE INDEX index_epic_board_list_preferences_on_user_and_list ON boards_epic_list_user_preferences USING btree (user_id, epic_list_id);
@@ -23589,6 +23921,8 @@ CREATE INDEX index_epics_on_start_date_sourcing_epic_id ON epics USING btree (st
CREATE INDEX index_epics_on_start_date_sourcing_milestone_id ON epics USING btree (start_date_sourcing_milestone_id);
+CREATE INDEX index_error_tracking_client_keys_on_project_id ON error_tracking_client_keys USING btree (project_id);
+
CREATE INDEX index_error_tracking_error_events_on_error_id ON error_tracking_error_events USING btree (error_id);
CREATE INDEX index_error_tracking_errors_on_project_id ON error_tracking_errors USING btree (project_id);
@@ -23597,6 +23931,10 @@ CREATE INDEX index_esc_protected_branches_on_external_status_check_id ON externa
CREATE INDEX index_esc_protected_branches_on_protected_branch_id ON external_status_checks_protected_branches USING btree (protected_branch_id);
+CREATE UNIQUE INDEX index_escalation_rules_on_all_attributes ON incident_management_escalation_rules USING btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds, user_id);
+
+CREATE INDEX index_escalation_rules_on_user ON incident_management_escalation_rules USING btree (user_id);
+
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);
@@ -23791,16 +24129,22 @@ CREATE INDEX index_group_repository_storage_moves_on_group_id ON group_repositor
CREATE UNIQUE INDEX index_group_stages_on_group_id_group_value_stream_id_and_name ON analytics_cycle_analytics_group_stages USING btree (group_id, group_value_stream_id, name);
+CREATE INDEX index_group_stages_on_stage_event_hash_id ON analytics_cycle_analytics_group_stages USING btree (stage_event_hash_id);
+
CREATE UNIQUE INDEX index_group_wiki_repositories_on_disk_path ON group_wiki_repositories USING btree (disk_path);
CREATE INDEX index_group_wiki_repositories_on_shard_id ON group_wiki_repositories USING btree (shard_id);
+CREATE INDEX index_historical_data_on_recorded_at ON historical_data USING btree (recorded_at);
+
CREATE UNIQUE INDEX index_http_integrations_on_active_and_project_and_endpoint ON alert_management_http_integrations USING btree (active, project_id, endpoint_identifier) WHERE active;
CREATE INDEX index_identities_on_saml_provider_id ON identities USING btree (saml_provider_id) WHERE (saml_provider_id IS NOT NULL);
CREATE INDEX index_identities_on_user_id ON identities USING btree (user_id);
+CREATE INDEX index_im_issuable_escalation_statuses_on_policy_id ON incident_management_issuable_escalation_statuses USING btree (policy_id);
+
CREATE UNIQUE INDEX index_im_oncall_schedules_on_project_id_and_iid ON incident_management_oncall_schedules USING btree (project_id, iid);
CREATE UNIQUE INDEX index_import_export_uploads_on_group_id ON import_export_uploads USING btree (group_id) WHERE (group_id IS NOT NULL);
@@ -23881,6 +24225,8 @@ CREATE INDEX index_issuable_metric_images_on_issue_id ON issuable_metric_images
CREATE UNIQUE INDEX index_issuable_severities_on_issue_id ON issuable_severities USING btree (issue_id);
+CREATE INDEX index_issuable_slas_on_due_at_id_label_applied_issuable_closed ON issuable_slas USING btree (due_at, id) WHERE ((label_applied = false) AND (issuable_closed = false));
+
CREATE UNIQUE INDEX index_issuable_slas_on_issue_id ON issuable_slas USING btree (issue_id);
CREATE INDEX index_issue_assignees_on_user_id ON issue_assignees USING btree (user_id);
@@ -23929,6 +24275,8 @@ CREATE UNIQUE INDEX index_issues_on_project_id_and_external_key ON issues USING
CREATE UNIQUE INDEX index_issues_on_project_id_and_iid ON issues USING btree (project_id, iid);
+CREATE INDEX index_issues_on_project_id_and_state_id_and_created_at_and_id ON issues USING btree (project_id, state_id, created_at, id);
+
CREATE INDEX index_issues_on_project_id_and_upvotes_count ON issues USING btree (project_id, upvotes_count);
CREATE INDEX index_issues_on_promoted_to_epic_id ON issues USING btree (promoted_to_epic_id) WHERE (promoted_to_epic_id IS NOT NULL);
@@ -23941,6 +24289,8 @@ CREATE INDEX index_issues_on_updated_at ON issues USING btree (updated_at);
CREATE INDEX index_issues_on_updated_by_id ON issues USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL);
+CREATE INDEX index_issues_on_work_item_type_id ON issues USING btree (work_item_type_id);
+
CREATE INDEX index_iterations_cadences_on_group_id ON iterations_cadences USING btree (group_id);
CREATE UNIQUE INDEX index_jira_connect_installations_on_client_key ON jira_connect_installations USING btree (client_key);
@@ -24141,6 +24491,8 @@ CREATE INDEX index_merge_requests_on_target_project_id_and_squash_commit_sha ON
CREATE INDEX index_merge_requests_on_target_project_id_and_target_branch ON merge_requests USING btree (target_project_id, target_branch) WHERE ((state_id = 1) AND (merge_when_pipeline_succeeds = true));
+CREATE INDEX index_merge_requests_on_target_project_id_and_updated_at_and_id ON merge_requests USING btree (target_project_id, updated_at, id);
+
CREATE INDEX index_merge_requests_on_target_project_id_iid_jira_description ON merge_requests USING btree (target_project_id, iid) WHERE (description ~ '[A-Z][A-Z_0-9]+-\d+'::text);
CREATE INDEX index_merge_requests_on_title ON merge_requests USING btree (title);
@@ -24311,8 +24663,6 @@ CREATE INDEX index_on_oncall_schedule_escalation_rule ON incident_management_esc
CREATE INDEX index_on_pages_metadata_not_migrated ON project_pages_metadata USING btree (project_id) WHERE ((deployed = true) AND (pages_deployment_id IS NULL));
-CREATE UNIQUE INDEX index_on_policy_schedule_status_elapsed_time_escalation_rules ON incident_management_escalation_rules USING btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds);
-
CREATE UNIQUE INDEX index_on_project_id_escalation_policy_name_unique ON incident_management_escalation_policies USING btree (project_id, name);
CREATE INDEX index_on_projects_lower_path ON projects USING btree (lower((path)::text));
@@ -24501,6 +24851,8 @@ CREATE INDEX index_pool_repositories_on_shard_id ON pool_repositories USING btre
CREATE UNIQUE INDEX index_pool_repositories_on_source_project_id_and_shard_id ON pool_repositories USING btree (source_project_id, shard_id);
+CREATE UNIQUE INDEX index_postgres_async_indexes_on_name ON postgres_async_indexes USING btree (name);
+
CREATE INDEX index_postgres_reindex_actions_on_index_identifier ON postgres_reindex_actions USING btree (index_identifier);
CREATE UNIQUE INDEX index_programming_languages_on_name ON programming_languages USING btree (name);
@@ -24517,6 +24869,8 @@ CREATE UNIQUE INDEX index_project_auto_devops_on_project_id ON project_auto_devo
CREATE UNIQUE INDEX index_project_ci_cd_settings_on_project_id ON project_ci_cd_settings USING btree (project_id);
+CREATE UNIQUE INDEX index_project_ci_feature_usages_unique_columns ON project_ci_feature_usages USING btree (project_id, feature, default_branch);
+
CREATE INDEX index_project_compliance_framework_settings_on_framework_id ON project_compliance_framework_settings USING btree (framework_id);
CREATE INDEX index_project_compliance_framework_settings_on_project_id ON project_compliance_framework_settings USING btree (project_id);
@@ -24587,6 +24941,8 @@ CREATE INDEX index_project_settings_on_project_id_partially ON project_settings
CREATE UNIQUE INDEX index_project_settings_on_push_rule_id ON project_settings USING btree (push_rule_id);
+CREATE INDEX index_project_stages_on_stage_event_hash_id ON analytics_cycle_analytics_project_stages USING btree (stage_event_hash_id);
+
CREATE INDEX index_project_statistics_on_namespace_id ON project_statistics USING btree (namespace_id);
CREATE INDEX index_project_statistics_on_packages_size_and_project_id ON project_statistics USING btree (packages_size, project_id);
@@ -24901,6 +25257,10 @@ CREATE INDEX index_security_scans_on_created_at ON security_scans USING btree (c
CREATE INDEX index_security_scans_on_date_created_at_and_id ON security_scans USING btree (date(timezone('UTC'::text, created_at)), id);
+CREATE INDEX index_security_scans_on_pipeline_id ON security_scans USING btree (pipeline_id);
+
+CREATE INDEX index_security_scans_on_project_id ON security_scans USING btree (project_id);
+
CREATE INDEX index_self_managed_prometheus_alert_events_on_environment_id ON self_managed_prometheus_alert_events USING btree (environment_id);
CREATE INDEX index_sent_notifications_on_noteable_type_noteable_id ON sent_notifications USING btree (noteable_id) WHERE ((noteable_type)::text = 'Issue'::text);
@@ -25063,8 +25423,6 @@ CREATE UNIQUE INDEX index_terraform_states_on_project_id_and_name ON terraform_s
CREATE UNIQUE INDEX index_terraform_states_on_uuid ON terraform_states USING btree (uuid);
-CREATE UNIQUE INDEX index_test_case_failures_unique_columns ON ci_test_case_failures USING btree (test_case_id, failed_at DESC, build_id);
-
CREATE INDEX index_timelogs_on_issue_id ON timelogs USING btree (issue_id);
CREATE INDEX index_timelogs_on_merge_request_id ON timelogs USING btree (merge_request_id);
@@ -25107,6 +25465,8 @@ CREATE INDEX index_u2f_registrations_on_key_handle ON u2f_registrations USING bt
CREATE INDEX index_u2f_registrations_on_user_id ON u2f_registrations USING btree (user_id);
+CREATE UNIQUE INDEX index_uniq_im_issuable_escalation_statuses_on_issue_id ON incident_management_issuable_escalation_statuses USING btree (issue_id);
+
CREATE UNIQUE INDEX index_unique_issue_metrics_issue_id ON issue_metrics USING btree (issue_id);
CREATE INDEX index_unit_test_failures_failed_at ON ci_unit_test_failures USING btree (failed_at DESC);
@@ -25277,6 +25637,8 @@ CREATE INDEX index_vulnerability_findings_remediations_on_remediation_id ON vuln
CREATE UNIQUE INDEX index_vulnerability_findings_remediations_on_unique_keys ON vulnerability_findings_remediations USING btree (vulnerability_occurrence_id, vulnerability_remediation_id);
+CREATE UNIQUE INDEX index_vulnerability_flags_on_unique_columns ON vulnerability_flags USING btree (vulnerability_occurrence_id, flag_type, origin);
+
CREATE INDEX index_vulnerability_flags_on_vulnerability_occurrence_id ON vulnerability_flags USING btree (vulnerability_occurrence_id);
CREATE INDEX index_vulnerability_historical_statistics_on_date_and_id ON vulnerability_historical_statistics USING btree (date, id);
@@ -25361,6 +25723,8 @@ CREATE INDEX index_x509_commit_signatures_on_x509_certificate_id ON x509_commit_
CREATE INDEX index_x509_issuers_on_subject_key_identifier ON x509_issuers USING btree (subject_key_identifier);
+CREATE INDEX index_zentao_tracker_data_on_integration_id ON zentao_tracker_data USING btree (integration_id);
+
CREATE INDEX index_zoom_meetings_on_issue_id ON zoom_meetings USING btree (issue_id);
CREATE UNIQUE INDEX index_zoom_meetings_on_issue_id_and_issue_status ON zoom_meetings USING btree (issue_id, issue_status) WHERE (issue_status = 1);
@@ -25421,7 +25785,7 @@ CREATE INDEX tmp_idx_deduplicate_vulnerability_occurrences ON vulnerability_occu
CREATE INDEX tmp_idx_on_namespaces_delayed_project_removal ON namespaces USING btree (id) WHERE (delayed_project_removal = true);
-CREATE INDEX tmp_index_merge_requests_draft_and_status ON merge_requests USING btree (id) WHERE ((draft = false) AND (state_id = 1) AND ((title)::text ~* '^\[draft\]|\(draft\)|draft:|draft|\[WIP\]|WIP:|WIP'::text));
+CREATE INDEX tmp_index_approval_project_rules_scanners ON approval_project_rules USING gin (scanners) WHERE (scanners @> '{cluster_image_scanning}'::text[]);
CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_child_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NOT NULL) AND (traversal_ids = '{}'::integer[]));
@@ -25453,6 +25817,8 @@ 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 UNIQUE INDEX work_item_types_namespace_id_and_name_unique ON work_item_types USING btree (namespace_id, btrim(lower(name)));
+
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;
@@ -25729,7 +26095,7 @@ CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipeli
CREATE TRIGGER trigger_8487d4de3e7b BEFORE INSERT OR UPDATE ON ci_builds_metadata FOR EACH ROW EXECUTE FUNCTION trigger_8487d4de3e7b();
-CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6();
+CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON dep_ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6();
CREATE TRIGGER trigger_aebe8b822ad3 BEFORE INSERT OR UPDATE ON taggings FOR EACH ROW EXECUTE FUNCTION trigger_aebe8b822ad3();
@@ -25751,6 +26117,8 @@ CREATE TRIGGER trigger_has_external_wiki_on_insert AFTER INSERT ON integrations
CREATE TRIGGER trigger_has_external_wiki_on_update AFTER UPDATE ON integrations FOR EACH ROW WHEN ((((new.type)::text = 'ExternalWikiService'::text) AND (old.active <> new.active) AND (new.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_wiki();
+CREATE TRIGGER trigger_type_new_on_insert AFTER INSERT ON integrations FOR EACH ROW EXECUTE FUNCTION integrations_set_type_new();
+
ALTER TABLE ONLY chat_names
ADD CONSTRAINT fk_00797a2bf9 FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE;
@@ -25763,15 +26131,15 @@ ALTER TABLE ONLY epics
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;
+
ALTER TABLE ONLY design_management_designs_versions
ADD CONSTRAINT fk_03c671965c FOREIGN KEY (design_id) REFERENCES design_management_designs(id) ON DELETE CASCADE;
ALTER TABLE ONLY terraform_state_versions
ADD CONSTRAINT fk_04b91e4a9f FOREIGN KEY (ci_build_id) REFERENCES ci_builds(id) ON DELETE SET NULL;
-ALTER TABLE ONLY ci_test_cases
- ADD CONSTRAINT fk_0526c30ded FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY issues
ADD CONSTRAINT fk_05f1e72feb FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -25847,6 +26215,9 @@ ALTER TABLE ONLY epics
ALTER TABLE ONLY geo_container_repository_updated_events
ADD CONSTRAINT fk_212c89c706 FOREIGN KEY (container_repository_id) REFERENCES container_repositories(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ci_build_trace_metadata
+ ADD CONSTRAINT fk_21d25cac1a FOREIGN KEY (trace_artifact_id) REFERENCES ci_job_artifacts(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY users_star_projects
ADD CONSTRAINT fk_22cd27ddfc FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -25871,8 +26242,8 @@ ALTER TABLE ONLY projects
ALTER TABLE ONLY ci_pipelines
ADD CONSTRAINT fk_262d4c2d19 FOREIGN KEY (auto_canceled_by_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL;
-ALTER TABLE ONLY ci_build_trace_sections
- ADD CONSTRAINT fk_264e112c66 FOREIGN KEY (section_name_id) REFERENCES ci_build_trace_section_names(id) ON DELETE CASCADE;
+ALTER TABLE ONLY dep_ci_build_trace_sections
+ ADD CONSTRAINT fk_264e112c66 FOREIGN KEY (section_name_id) REFERENCES dep_ci_build_trace_section_names(id) ON DELETE CASCADE;
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_27548c6db3 FOREIGN KEY (hashed_storage_migrated_event_id) REFERENCES geo_hashed_storage_migrated_events(id) ON DELETE CASCADE;
@@ -25892,6 +26263,9 @@ ALTER TABLE ONLY members
ALTER TABLE ONLY lfs_objects_projects
ADD CONSTRAINT fk_2eb33f7a78 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE NOT VALID;
+ALTER TABLE ONLY analytics_cycle_analytics_group_stages
+ ADD CONSTRAINT fk_3078345d6d FOREIGN KEY (stage_event_hash_id) REFERENCES analytics_cycle_analytics_stage_event_hashes(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_30f2a831f4 FOREIGN KEY (iteration_id) REFERENCES sprints(id) ON DELETE CASCADE;
@@ -25955,7 +26329,7 @@ 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 ci_build_trace_sections
+ALTER TABLE ONLY dep_ci_build_trace_sections
ADD CONSTRAINT fk_4ebe41f502 FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE CASCADE;
ALTER TABLE ONLY alert_management_alerts
@@ -26000,6 +26374,9 @@ ALTER TABLE ONLY project_access_tokens
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_6149611a04 FOREIGN KEY (assignee_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY dast_profile_schedules
+ ADD CONSTRAINT fk_61d52aa0e7 FOREIGN KEY (dast_profile_id) REFERENCES dast_profiles(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY events
ADD CONSTRAINT fk_61fbf6ca48 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -26021,6 +26398,9 @@ ALTER TABLE ONLY merge_requests
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_6ada82d42a FOREIGN KEY (container_repository_updated_event_id) REFERENCES geo_container_repository_updated_events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY dast_profile_schedules
+ ADD CONSTRAINT fk_6cca0d8800 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY projects
ADD CONSTRAINT fk_6e5c14658a FOREIGN KEY (pool_repository_id) REFERENCES pool_repositories(id) ON DELETE SET NULL;
@@ -26246,6 +26626,9 @@ ALTER TABLE ONLY alert_management_alerts
ALTER TABLE ONLY identities
ADD CONSTRAINT fk_aade90f0fc FOREIGN KEY (saml_provider_id) REFERENCES saml_providers(id) ON DELETE CASCADE;
+ALTER TABLE ONLY dep_ci_build_trace_sections
+ ADD CONSTRAINT fk_ab7c104e26 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY ci_sources_pipelines
ADD CONSTRAINT fk_acd9737679 FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -26258,6 +26641,9 @@ ALTER TABLE ONLY ci_variables
ALTER TABLE ONLY merge_request_metrics
ADD CONSTRAINT fk_ae440388cc FOREIGN KEY (latest_closed_by_id) REFERENCES users(id) ON DELETE SET NULL;
+ALTER TABLE ONLY dast_profile_schedules
+ ADD CONSTRAINT fk_aef03d62e5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY analytics_cycle_analytics_group_stages
ADD CONSTRAINT fk_analytics_cycle_analytics_group_stages_group_value_stream_id FOREIGN KEY (group_value_stream_id) REFERENCES analytics_cycle_analytics_group_value_streams(id) ON DELETE CASCADE;
@@ -26270,6 +26656,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 issues
+ ADD CONSTRAINT fk_b37be69be6 FOREIGN KEY (work_item_type_id) REFERENCES work_item_types(id);
+
ALTER TABLE ONLY protected_tag_create_access_levels
ADD CONSTRAINT fk_b4eb82fe3c FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -26321,6 +26710,9 @@ ALTER TABLE ONLY packages_packages
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_c1f241c70d FOREIGN KEY (upload_deleted_event_id) REFERENCES geo_upload_deleted_events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY analytics_cycle_analytics_project_stages
+ ADD CONSTRAINT fk_c3339bdfc9 FOREIGN KEY (stage_event_hash_id) REFERENCES analytics_cycle_analytics_stage_event_hashes(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY vulnerability_exports
ADD CONSTRAINT fk_c3d3cb5d0f FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -26384,9 +26776,6 @@ 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 ci_test_case_failures
- ADD CONSTRAINT fk_d69404d827 FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_d6cf4279f7 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -26408,6 +26797,9 @@ ALTER TABLE ONLY label_links
ALTER TABLE ONLY project_group_links
ADD CONSTRAINT fk_daa8cee94c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY security_scans
+ ADD CONSTRAINT fk_dbc89265b9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY epics
ADD CONSTRAINT fk_dccd3f98fc FOREIGN KEY (assignee_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -26510,6 +26902,9 @@ ALTER TABLE ONLY cluster_agents
ALTER TABLE ONLY protected_tag_create_access_levels
ADD CONSTRAINT fk_f7dfda8c51 FOREIGN KEY (protected_tag_id) REFERENCES protected_tags(id) ON DELETE CASCADE;
+ALTER TABLE ONLY dep_ci_build_trace_section_names
+ ADD CONSTRAINT fk_f8cd72cd26 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY ci_stages
ADD CONSTRAINT fk_fb57e6cc56 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE;
@@ -26525,6 +26920,9 @@ ALTER TABLE ONLY ci_daily_build_group_report_results
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_fd82eae0b9 FOREIGN KEY (head_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL;
+ALTER TABLE ONLY ci_pending_builds
+ ADD CONSTRAINT fk_fdc0137e4a FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY project_import_data
ADD CONSTRAINT fk_ffb9ee3a10 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -26579,9 +26977,6 @@ ALTER TABLE ONLY terraform_state_versions
ALTER TABLE ONLY ci_build_report_results
ADD CONSTRAINT fk_rails_056d298d48 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-ALTER TABLE incident_management_pending_alert_escalations
- ADD CONSTRAINT fk_rails_057c1e3d87 FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE SET NULL;
-
ALTER TABLE ONLY ci_daily_build_group_report_results
ADD CONSTRAINT fk_rails_0667f7608c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -26729,6 +27124,9 @@ ALTER TABLE ONLY epic_user_mentions
ALTER TABLE ONLY approver_groups
ADD CONSTRAINT fk_rails_1cdcbd7723 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY project_ci_feature_usages
+ ADD CONSTRAINT fk_rails_1deedbf64b FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY packages_tags
ADD CONSTRAINT fk_rails_1dfc868911 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
@@ -26753,6 +27151,9 @@ ALTER TABLE ONLY approval_merge_request_rules_groups
ALTER TABLE ONLY vulnerability_feedback
ADD CONSTRAINT fk_rails_20976e6fd9 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL;
+ALTER TABLE ONLY work_item_types
+ ADD CONSTRAINT fk_rails_20f694a960 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY user_statuses
ADD CONSTRAINT fk_rails_2178592333 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -26810,6 +27211,9 @@ ALTER TABLE ONLY dast_site_validations
ALTER TABLE ONLY vulnerability_findings_remediations
ADD CONSTRAINT fk_rails_28a8d0cf93 FOREIGN KEY (vulnerability_occurrence_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE;
+ALTER TABLE ONLY incident_management_issuable_escalation_statuses
+ ADD CONSTRAINT fk_rails_29abffe3b9 FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY resource_state_events
ADD CONSTRAINT fk_rails_29af06892a FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -27374,6 +27778,9 @@ ALTER TABLE ONLY required_code_owners_sections
ALTER TABLE ONLY dast_site_profiles
ADD CONSTRAINT fk_rails_83e309d69e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY zentao_tracker_data
+ ADD CONSTRAINT fk_rails_84efda7be0 FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY boards_epic_user_preferences
ADD CONSTRAINT fk_rails_851fe1510a FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
@@ -27467,6 +27874,9 @@ ALTER TABLE ONLY project_error_tracking_settings
ALTER TABLE ONLY list_user_preferences
ADD CONSTRAINT fk_rails_916d72cafd FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+ALTER TABLE ONLY vulnerability_finding_evidence_responses
+ ADD CONSTRAINT fk_rails_929041a499 FOREIGN KEY (vulnerability_finding_evidence_supporting_message_id) REFERENCES vulnerability_finding_evidence_supporting_messages(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY merge_request_cleanup_schedules
ADD CONSTRAINT fk_rails_92dd0e705c FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
@@ -27509,6 +27919,9 @@ ALTER TABLE ONLY board_project_recent_visits
ALTER TABLE ONLY clusters_kubernetes_namespaces
ADD CONSTRAINT fk_rails_98fe21e486 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL;
+ALTER TABLE ONLY error_tracking_client_keys
+ ADD CONSTRAINT fk_rails_99342d1d54 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY pages_deployments
ADD CONSTRAINT fk_rails_993b88f59a FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
@@ -27569,6 +27982,9 @@ ALTER TABLE ONLY jira_connect_subscriptions
ALTER TABLE ONLY fork_network_members
ADD CONSTRAINT fk_rails_a40860a1ca FOREIGN KEY (fork_network_id) REFERENCES fork_networks(id) ON DELETE CASCADE;
+ALTER TABLE ONLY customer_relations_organizations
+ ADD CONSTRAINT fk_rails_a48597902f FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY operations_feature_flag_scopes
ADD CONSTRAINT fk_rails_a50a04d0a4 FOREIGN KEY (feature_flag_id) REFERENCES operations_feature_flags(id) ON DELETE CASCADE;
@@ -27614,9 +28030,6 @@ ALTER TABLE ONLY merge_request_user_mentions
ALTER TABLE ONLY x509_commit_signatures
ADD CONSTRAINT fk_rails_ab07452314 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-ALTER TABLE ONLY ci_build_trace_sections
- ADD CONSTRAINT fk_rails_ab7c104e26 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY resource_iteration_events
ADD CONSTRAINT fk_rails_abf5d4affa FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
@@ -27632,6 +28045,9 @@ ALTER TABLE ONLY analytics_cycle_analytics_group_stages
ALTER TABLE ONLY metrics_dashboard_annotations
ADD CONSTRAINT fk_rails_aeb11a7643 FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE;
+ALTER TABLE ONLY ci_build_trace_metadata
+ ADD CONSTRAINT fk_rails_aebc78111f FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY bulk_import_trackers
ADD CONSTRAINT fk_rails_aed566d3f3 FOREIGN KEY (bulk_import_entity_id) REFERENCES bulk_import_entities(id) ON DELETE CASCADE;
@@ -27824,6 +28240,9 @@ ALTER TABLE ONLY resource_milestone_events
ALTER TABLE ONLY resource_iteration_events
ADD CONSTRAINT fk_rails_cee126f66c FOREIGN KEY (iteration_id) REFERENCES sprints(id) ON DELETE CASCADE;
+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 epic_metrics
ADD CONSTRAINT fk_rails_d071904753 FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE CASCADE;
@@ -27983,9 +28402,6 @@ ALTER TABLE ONLY vulnerability_finding_evidence_sources
ALTER TABLE ONLY protected_branch_unprotect_access_levels
ADD CONSTRAINT fk_rails_e9eb8dc025 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE;
-ALTER TABLE ONLY ci_test_case_failures
- ADD CONSTRAINT fk_rails_eab6349715 FOREIGN KEY (test_case_id) REFERENCES ci_test_cases(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY alert_management_alert_user_mentions
ADD CONSTRAINT fk_rails_eb2de0cdef FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE;
@@ -28049,9 +28465,15 @@ ALTER TABLE ONLY approval_project_rules_users
ALTER TABLE ONLY insights
ADD CONSTRAINT fk_rails_f36fda3932 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE incident_management_pending_alert_escalations
+ ADD CONSTRAINT fk_rails_f3d17bc8af FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY board_group_recent_visits
ADD CONSTRAINT fk_rails_f410736518 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY incident_management_issuable_escalation_statuses
+ ADD CONSTRAINT fk_rails_f4c811fd28 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY resource_state_events
ADD CONSTRAINT fk_rails_f5827a7ccd FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
@@ -28073,15 +28495,15 @@ ALTER TABLE ONLY issues_self_managed_prometheus_alert_events
ALTER TABLE ONLY merge_requests_closing_issues
ADD CONSTRAINT fk_rails_f8540692be FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
-ALTER TABLE ONLY ci_build_trace_section_names
- ADD CONSTRAINT fk_rails_f8cd72cd26 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY merge_trains
ADD CONSTRAINT fk_rails_f90820cb08 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_runner_namespaces
ADD CONSTRAINT fk_rails_f9d9ed3308 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY banned_users
+ ADD CONSTRAINT fk_rails_fa5bb598e5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY requirements_management_test_reports
ADD CONSTRAINT fk_rails_fb3308ad55 FOREIGN KEY (requirement_id) REFERENCES requirements(id) ON DELETE CASCADE;